I work in IT, the company owner approached me last month with a problem. He owns a lot of properties and wants his movies available at all properties at all times, most properties are remote and have very slow internet connections due to geography. (Think Mountains, Islands, etc)
Requirements I was given
- Cost was no object (within reason)
- Downloading movies at each location is fine but would have to happen off hours as not to impact internet use during the day.
- All movies/TV had to be purchased (his rules)
- No DRM
- RF remote would be best as many of the AV racks are in an adjacent room
- The interface had to provide cover art, have an ipad app and look slick.
- One of the 5 locations includes a Gulfstream Jet where downloading one movie would cost over $10,000 in internet fees. So i would need to mount an AP in the hanger connected to my own internet and make sure it ONLY used that internet to sync while still connecting to the jets internet for ipad controls. I also had to talk to the ground team to setup a power on scheduled for the unit so it had time to sync.
- Get an unlimited cloud provided storage account with SFTP
- Buy 400 Bluray movies and rip them
- Start with 5 Slice boxes with 4TB HDD's (later found out that they had to be mounted outside, so they are just set on top for now)
- Write a python script that when the box was booted looks for the proper wireless, exits if it cant find it, syncs the movies from an online cloud provider if it can.
Steps taken so far.
So two weeks ago i started doing exactly that.
Ripping and uploading the movies started many weeks ago and to be honest will take me many more weeks, its boring and slow, I use AnyDVD to decrypt the Bluray and Handbrake to encode it. This system works great, i have it all scripted so the drive ejects and i put in the next disk, it encodes, and ejects, etc, etc. The owner now has an account he can order movies on, the movies automatically ship to me, i will encode them, then i upload them to the storage account so he can watch them anywhere.
The Slice units arrived, i quickly found out that the 4TB drives i have wont fit but thats not an issue because I have put them in external cases and Velcro them to the top of the slices.
I started by SSHing into the Slice and editing the autostart.sh file to look like this
echo pcf8523 0x68 > /sys/class/i2c-dev/i2c-0/device/new_device
python /var/media/Master\ Drive/scripts/Download.py
This will run the Download.py script that is on my hard drive. It waits 60 seconds to make sure that the drive is mounted and that Kodi has had a chance to start (the script uses some Kodi Json to invoke the file index after the files have copied)
The Download.py file is a work in progress but here is what i have so far.
Connects to the Wifi, if it cant find the AP it closes.
if we are not connected to the AP but its in range we try to connect, if unsuccessful we close.
Once every 10 times run it will spider though all of the local files deleting the ones that don't line up with the SFTP.
if Still connected it connects to the SFTP and spiders though all files
If a file is found that is missing it downloads it. (only if still connected to the right AP)
If a file is found that is the wrong size it deletes and redownloads it. (only if still connected to the right AP)
It then forces Kodi to index those files. (only if still connected to the right AP)
Saves a log to to the SFTP Site in the log folder
There is a limit for the MB downloaded for each run.
There is a limit for the number of files downloaded for each run
There is a limit for the number of seconds the script can run
Future things to add
Hub and spoke updates
If a file has to be downloaded check local kodi boxes for the file first.
if they have them copy on the local lan, if they are already
downloading skip and move on, come back later to copy off the lan
I tried uploading the code but so far this forum mangles it, if i try to change the ext to jpg it tells me its not valid... i will have to find a new way if anyone is interested.
Worth mentioning that i am not a programmer and this is the first program i have ever written in Python and i only have about 8 hours into programming and testing it so i'm sure it has a few bugs i have not found yet.