my first python script to organise recordings into folders/directories

grog68

VIP Member
TK Supporter
i've written my first ever python script for use on my zgemma, it's a simple script that runs via cron manager to create sub directories within the /media/hdd/movie directory for series that we have recorded, ie the boss records eastenders, so the script checks how many eastenders ts files are in the movie directory and if more than one (multiple recordings) it then creates an eastenders sub directory and moves all eastender files into it, If there is only one recording of a show then no directory is created. Each time it runs any recording that has a directory already created is moved into it's respective directory. It checks that the file has not been modified for at least 5 minutes so not to move files that are still being recorded.

It's not a plugin as such as I haven't looked at how to right a plugin yet.

This script is now a plugin and a download link and instructions can be found at http://www.techkings.org/zgemma-sta...gs-into-folders-directories-5.html#post547058
 
Last edited:
For those that do a lot of recording like my Mrs this will make finding what your after so much easier, kudos for your efforts & will give this a go IF you upload to your dropbox
 
I'd love this as setting folders on auto timers can be a pain and you can't seem to administer them successfully from the web interface.. It might be worth talking to Whooshman too.. i think he's on the brink of releasing a new build and he might want to include this....

Paging Whooshman!
 
Please go to http://www.techkings.org/zgemma-sta...gs-into-folders-directories-5.html#post547058 for the latest files and instructions. Those below no longer work.



The script has been changed and although the below still works a newer version is available from another download link. Please read the post at http://www.techkings.org/zgemma-sta...olders-directories-post543686.html#post543686 for up to date version and instructions

OK please note this is a rough and ready script and my first attempt at python, it works on my zgemma h2s using wooshmans build, however I offer no warranty with it, you use at your own risk.

The script can be downloaded from https://goo.gl/opveNE if you know python and think I could have done something in a better way please let me know.

The script assumes the path to your recordings is /media/hdd/movie if yours are stored somewhere else then change the path setting in line 8.

FTP the file to your box, I have uploaded it to /home/root to keep it out of the way but you should be able to put it anywhere but make a note of where it is stored.

Now on your box go to the cron manager menu -> Timers -> CronTimers
Press the Add (green) button and then set the cron up as below:

Run how often? : Hourly
Command type : Custom
Cammand to run : python /home/root/ordermovies.py (make sure this points to the correct path where you uploaded it to)

Then click on the save button (green)

Make sure your cron manager is running and autostart is active

Your recording will initially be recorded in the normal location, the script will now run once an hour and move recordings as explained in my first post.

When you look at file list you will see folders, click on the relevant folder and you should then see a list of your recordings of that show, to return to the first list click on the folder at the top '..' .

All feedback welcome and appreciated in this thread
 
Last edited:
Works great on OpenATV 5.3 and OpenVIX 4.0.004 thanks. It even works to my NAS drive and has tidied up my documentaries folder!
I daren't try it on the missus's WooshBuild box though!

Quick question: Will it still run in standby, like recordings or does the box need to be on?
 
Last edited:
Grog, a great move to making your box even closer to sky and something I have thought about myself and seen questions about it.

Well done you :-) I will try asap.
 
Last edited by a moderator:
Got it installed last night. Took me a age to type it in with the keypad, back in the day no problems lol will test it out and give feedback.


is there anything else out there like this, that does custom things to the boxes
 
Thanks for trying

As far as I know this shouldn't have any effect on anything else on the box as it is only moving already recorded files.

After getting feedback to make some modifications to the script over the next few days, i'm busy at the weekend so it may have to wait till monday, 1 thing i forgot to do was it doesn't do is remove empty directories, so what I am planning on is once there is just one show left in a directory, move it back to the main list and remove the directory so it's even more like $sky.

Got it installed last night. Took me a age to type it in with the keypad, back in the day no problems lol will test it out and give feedback.


is there anything else out there like this, that does custom things to the boxes
 
Good work!
I always have to create a folder after they have all been dumped in the movies folder, I'll be trying this out soon
 
I take it moves all the other files associated with the recording and not just the .ts file ?


Sent from my iPad using Tapatalk
 
I take it moves all the other files associated with the recording and not just the .ts file ?


Sent from my iPad using Tapatalk
Yes, All files
are moved,I just use the .ts file to check modification date as that is the actual recording, I don't want to move the file if its still being written to/recorded.
 
does this work when you record them individually or only via autotimers?

i've just recorded 15 minutes of the same program to test it now waiting to see if it works
 
just thinking this will do it for one of recordings like movies

from what it says in the post it needs more than one recording of the same film/program to create a folder that's why i asked about making individual recordings or if it needs to be with autotimer
 
Quick question: Will it still run in standby, like recordings or does the box need to be on?

I expected it to run just when it was on not knowing the machine but when I checked the box's logs it shows the cron us running every hour 24 hours a day, when the box is in standby which would suggest the script would run normally in standby but I will double check that shortly.

---------- Post Merged at 06:37 PM ----------

does this work when you record them individually or only via autotimers?

i've just recorded 15 minutes of the same program to test it now waiting to see if it works

The script doesn't actually touch anything to do with the timers it just sorts by the name, so if there are 2 recordings with the name Eastenders then they should be put into the same folder, if you record 'The Big Bang' and then 'New: The Big Bang' then they will be treated differently.

To explain a bit more, recordings are stored with the following filename structure

date time - channel name - program name
20160607 1928 - BBC One HD - EastEnders

the script just skims through the movies folder and checks the program name and then groups those that are the same.

Let me know how your test goes please.

---------- Post Merged at 06:41 PM ----------

I obviously appreciate anything anyone does on here to improve what we use and don't want to undermine the time and effort you've put in but there is already a plugin you can download called auto organiser that does exactly what your script does I've been using it for ages and it works a treat on both vix and atv, it may be worth having a look at this yourself as it might give you some pointers, anything you can do to maybe improve on this existing plugin and make yours better would be greatly appreciated.
The ipk can be downloaded from here.

**EDIT** I've removed the link as its a link to another forum if the OP or anyone wants it PM me.

Ah I didn't know a plugin existed, although I am not surprised that one does. No point reinventing the wheel,
 
I expected it to run just when it was on not knowing the machine but when I checked the box's logs it shows the cron us running every hour 24 hours a day, when the box is in standby which would suggest the script would run normally in standby but I will double check that shortly.

---------- Post Merged at 06:37 PM ----------

does this work when you record them individually or only via autotimers?

i've just recorded 15 minutes of the same program to test it now waiting to see if it works

The script doesn't actually touch anything to do with the timers it just sorts by the name, so if there are 2 recordings with the name Eastenders then they should be put into the same folder, if you record 'The Big Bang' and then 'New: The Big Bang' then they will be treated differently.

To explain a bit more, recordings are stored with the following filename structure

date time - channel name - program name
20160607 1928 - BBC One HD - EastEnders

the script just skims through the movies folder and checks the program name and then groups those that are the same.

Let me know how your test goes please.

I've recorded 2 10 minuets of dickinsons real deal and they haven't placed them in a folder I'll double check the settings later.
 
Back
Top