In this post, I want to show you how to have a good media center at home with Raspberry PI
Press enter or click to view image in full size
For pursuing this you should have these items:
- TV :D
- Raspberry PI (I prefer last version https://www.raspberrypi.org/products/raspberry-pi-3-model-b/)
- HDMI Cable
- Micro USB power supply (2.1 A) for Raspberry PI
- External Hard disk
- Micro SD card
Instal Kodi
What is Kodi? Kodi is a free and open-source media center software application developed by the XBMC Foundation.
with Kodi, you can do most things that everyone can do with a media player.
But how can we install this over the Raspberry PI?
One of the easiest ways is by using OSMC.
What is OSMC? OSMC (Open Source Media Center) is a free and open source media player based on Linux. Founded in 2014, OSMC lets you play back media from your local network, attached storage, and the Internet. OSMC is the leading media center in terms of feature set and community and is based on the Kodi project.
Also, OSMC already integrated with Raspberry PI.
You should download an image from here (Disk images)
https://osmc.tv/download/
After that connect you Micro SD to your PC, and copy downloaded image to your Micro SD with dd
I don’t know how to use dd in non-Linux os but for Linux, you can
dd bs=4M if=/dev/sdX of=osmc.imgcommand or Etcher (https://www.balena.io/etcher/)
there are many articles for this step. If you have any problem you can check those articles too,
i.e
https://howtoraspberrypi.com/media-center-osmc-raspberry-pi/
That’s it
Dropbox or any other cloud ( Box, Mega, Google drive and … )
One of my main problem with other media centers was Dropbox. I want to copy files to Dropbox and watch them later on my Raspberry PI. Also, I want to add links or torrents file ( legal files :) ) to Dropbox and watch them later on my tv.
Press enter or click to view image in full size
So, first of all, I create a folder named tv-shared-content in dropbox
then I create 3 folders under this folder
- torrents
- links
- videos
now I should install a client inside the device to connect to Dropbox, but you can’t install regular application inside the device, because it is not compatible with ARM.
I found another thing that helped me so much
Rclone
https://rclone.org/
with this tool, you can download from any cloud into your device.
Install
You should ssh to your device
find your device IP from Kodi, for this go to `settings` menu in the top left corner. Next, select ‘Sytem Information’.
Now just ssh to your device like this
ssh osmc@<your device ip>Default Username and Password
username = osmc
password = osmc
- don’t forget to change your password
Now you are in your Raspberry PI shell, you should download RClone
from here https://rclone.org/downloads/ download Arm 64bit with `.deb` extension
for example, the latest file is 1.47
mkdir apps
cd apps
wget https://downloads.rclone.org/v1.47.0/rclone-v1.47.0-linux-arm64.deb
then install it
sudo dpkg -i rclone-v1.47.0-linux-arm64.deb
also, you can use the generic script that described here https://rclone.org/install/
now you should login with this command
rclone configthen push `n` to define new remote.
you can see this manual for more detail https://rclone.org/dropbox/
Sync
now you have Dropbox integration, you need to automate download files, so you should add them to crontab
crontab -eadd these three lines, each row download related files in specific folder, don’t forget to create those destination folders. also if you use different cloud, you can just replace Dropbox with that
* * * * * rclone copy dropbox:/tv-shared-content/torrents “/media/hdd/Torrent/tfiles”
0 * * * * rclone copy dropbox:/tv-shared-content/videos “/media/hdd/Video/shared-videos”
* * * * * rclone copy dropbox:/tv-shared-content/links “/media/hdd/links”Download links
for downloading links I defined a convention for my self. each day I create a list with this name <whatever…>.links and push each link in separate line.
then I install Axel for download faster
sudo apt install axelafter that, I add a rule in crontab same as sync step
0 0 * * * /media/My\ Passport/links/*.links | xargs -i axel -n 20 “{}” -o /media/My\ Passport/Video/directFilm/in the midnight it starts to download my links
Download torrents
for downloading torrents you have many ways, you can use transmission, aria2 or whatever you like, you just monitor torrent folder.
Transmission
for using transmission you should install it first
sudo apt install transmission-daemonthen you can use my config
{
“alt-speed-down”: 50,
“alt-speed-enabled”: false,
“alt-speed-time-begin”: 540,
“alt-speed-time-day”: 127,
“alt-speed-time-enabled”: false,
“alt-speed-time-end”: 1020,
“alt-speed-up”: 50,
“bind-address-ipv4”: “0.0.0.0”,
“bind-address-ipv6”: “::”,
“blocklist-enabled”: false,
“blocklist-url”: “http://www.example.com/blocklist",
“cache-size-mb”: 4,
“dht-enabled”: true,
“download-dir”: “/media/hdd/Torrent/films”,
“download-limit”: 100,
“download-limit-enabled”: 0,
“download-queue-enabled”: true,
“download-queue-size”: 5,
“encryption”: 1,
“idle-seeding-limit”: 30,
“idle-seeding-limit-enabled”: false,
“incomplete-dir”: “/media/hdd/Torrent/incomp”,
“incomplete-dir-enabled”: false,
“lpd-enabled”: false,
“max-peers-global”: 200,
“message-level”: 1,
“peer-congestion-algorithm”: “”,
“peer-id-ttl-hours”: 6,
“peer-limit-global”: 200,
“peer-limit-per-torrent”: 50,
“peer-port”: 80,
“peer-port-random-high”: 65535,
“peer-port-random-low”: 49152,
“peer-port-random-on-start”: false,
“peer-socket-tos”: “default”,
“pex-enabled”: true,
“port-forwarding-enabled”: false,
“preallocation”: 1,
“prefetch-enabled”: true,
“queue-stalled-enabled”: true,
“queue-stalled-minutes”: 30,
“ratio-limit”: 2,
“ratio-limit-enabled”: false,
“rename-partial-files”: true,
“rpc-authentication-required”: true,
“rpc-bind-address”: “0.0.0.0”,
“rpc-enabled”: true,
“rpc-host-whitelist”: “0.0.0.0”,
“rpc-host-whitelist-enabled”: true,
“rpc-password”: “{84dc730f53dd9179fa719e37a67ae842512cb840cID9rYVd”,
“rpc-port”: 9091,
“rpc-url”: “/transmission/”,
“rpc-username”: “transmission”,
“rpc-whitelist”: “*.*.*.*”,
“rpc-whitelist-enabled”: true,
“scrape-paused-torrents-enabled”: true,
“script-torrent-done-enabled”: false,
“script-torrent-done-filename”: “”,
“seed-queue-enabled”: false,
“seed-queue-size”: 10,
“speed-limit-down”: 100000,
“speed-limit-down-enabled”: false,
“speed-limit-up”: 10,
“speed-limit-up-enabled”: true,
“start-added-torrents”: true,
“trash-original-torrent-files”: false,
“umask”: 18,
“upload-limit”: 100,
“upload-limit-enabled”: 0,
“upload-slots-per-torrent”: 14,
“utp-enabled”: true,
“watch-dir”: “/media/hdd/Torrent/tfiles”,
“watch-dir-enabled”: true
}you can open web UI in this address http://<your device ip>:9091
and use default credentials
username: transmission
password: transmission
Also don’t forget to create those tree folders
- /media/hdd/Torrent/films
- /media/hdd/Torrent/tfiles
- /media/hdd/Torrent/incomp
Aria2
Install Aria2 first
then add this rule in crontab, same as sync
0 */8 * * * aria2c /media/hdd/Torrent/tfiles/* -d /media/hdd/Torrent/films/ -c -l /var/log/torrents.logdon’t forget to create /var/log/torrents.log and /media/hdd/Torrent/films/
Management
for management you can get static IP from your ISP or use ddns, but I think easiest way is use https://remote-iot.com service.
after registration, install it like this
curl -s -L https://remote-iot.com/install/remote-iot-install.sh | sudo -s bashthen run the integration
sudo /etc/remote-iot/services/setup.sh “your_login_email” “your_password” “device_name”for more detail, check this place
https://remote-iot.com/web/help.htm#Install
that’s it
conclusion
I know working with Chromecast and other media centers is easier, but when you are making your tools, you will be more comfortable, because you can add whatever you want.