1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Hi Guest, If you haven't already please like our Facebook Page. We post Discount Codes for the Major online retailers. We saved members a fortune over Xmas and continue to post amazing discounts for everyday items. You need to add us to see what i'm taking about. CLICK HERE - click LIKE, add us to "SEE FIRST". So you don't miss expiring codes.

my first python script to organise recordings into folders/directories

Discussion in 'Zgemma-Star H.2S' started by grog68, Jun 9, 2016.

  1. grog68

    grog68 TK Veteran Forum 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: Jun 23, 2016
  2. BeakyFord

    BeakyFord TK Veteran

    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
  3. jeffsutton

    jeffsutton Registered

    Good Idea. My Mrs is the same with Eastenders, Coranation Street etc, pages of it. Some create a plugin please
  4. Bajan2411

    Bajan2411 Registered

    Grog68, would be good to get a copy of your script if i can please

    Sent from my SM-G901F using Tapatalk
  5. danmed

    danmed Registered

    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!
  6. grog68

    grog68 TK Veteran Forum Supporter

    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: Jun 21, 2016
  7. Willo3092

    Willo3092 TK Veteran Forum Supporter

    East Midlands
    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: Jun 9, 2016
  8. wooshman

    wooshman VIP Member Forum Supporter

    {Bodge Builder
    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: Jun 9, 2016
  9. siilver

    siilver TK Veteran

    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
  10. grog68

    grog68 TK Veteran Forum Supporter

    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.

  11. Burlesy

    Burlesy TK Veteran

    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
  12. gmanpanthro

    gmanpanthro TK Veteran

    I take it moves all the other files associated with the recording and not just the .ts file ?

    Sent from my iPad using Tapatalk
  13. grog68

    grog68 TK Veteran Forum Supporter

    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.
  14. dsayers2014

    dsayers2014 VIP Member

    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
  15. dsayers2014

    dsayers2014 VIP Member

    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
  16. siilver

    siilver TK Veteran

    im guessing it will work for a timer on repeat too
  17. grog68

    grog68 TK Veteran Forum Supporter

    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 ----------

    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 ----------

    Ah I didn't know a plugin existed, although I am not surprised that one does. No point reinventing the wheel,
  18. siilver

    siilver TK Veteran

    i have my set at program name only.
    would that cause a problem
  19. dsayers2014

    dsayers2014 VIP Member

    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.
  20. grog68

    grog68 TK Veteran Forum Supporter

    Yes it does still run in standby