Move recordings to NAS after X days? (1 Viewer)

jonm

Portal Pro
January 12, 2009
429
26
Wales
Home Country
Wales Wales
Shouldn't be difficult to hack something together to do this, I'll have a go when I'm home next week.
 

batsi

Portal Member
May 23, 2008
10
3
Munich
Home Country
Germany Germany
Hi all,

I'm currently moving from Windows 7 Media Center to MediaPortal. As I used with Media Center I also wanted to setup moving files from the local disk with only 80GB to my Linux file server with 2TB. I planned to write a small script that could be called by the ComSkipLauncher plugin.
I already created a symlink in the local recording folder pointing to the recording cifs share on the server and configured the TV server service running as the local user instead of the 'network service' (so that it can access the network share).

If I now move files and reimport them to the database afterwards manually everything works fine. So the only thing missing is to find out what commands are actually executed by hitting the buttons 'Remove invalid entries' and 'Import selected files' on the Recording->Database tab in the TV server settings so this all could be automated. Of course this could also be done more nice if only the specific file is updated in the database.

What do you think?

Batsi
 

batsi

Portal Member
May 23, 2008
10
3
Munich
Home Country
Germany Germany
I just wanted to report that I investigated the MP MySQL database and consulted google and found out the needed SQL statement.
From a batch file it can be called by the follwing command:
Code:
mysql -uroot -pMediaPortal mptvdb -e "update `recording` set `fileName` = '<D:\\Recording\\Server\\filename.ts>' where `fileName` = '<D:\\Recording\\filename.ts>'"
(double backslashes are needed)

So far it works fine in my configuration.
If anyone needs it, I can post the whole batch file called by ComSkipLauncher in my MediaPortal.
 

porky996t

MP Donator
  • Premium Supporter
  • May 21, 2008
    1,016
    81
    Bolton, Lancashire, England
    Home Country
    England England
    Thanks Batsi, good of you to report back.

    I have now removed MCE Buddy from my system as it just didn't seem to work well with Powerscheduler++

    It is probably fine if you have a server running 24/7, but my HTPC is set to sleep when idle and this seems to mess MCE Buddy up a bit. Would be great if there was a specific MP plugin to do what MCE Buddy tries to do.
     

    sjevtic

    MP Donator
  • Premium Supporter
  • January 16, 2012
    114
    29
    43
    Chicago, IL
    Home Country
    United States of America United States of America
    I just wanted to report that I investigated the MP MySQL database and consulted google and found out the needed SQL statement.
    From a batch file it can be called by the follwing command:
    Code:
    mysql -uroot -pMediaPortal mptvdb -e "update `recording` set `fileName` = '<D:\\Recording\\Server\\filename.ts>' where `fileName` = '<D:\\Recording\\filename.ts>'"
    (double backslashes are needed)

    So far it works fine in my configuration.
    If anyone needs it, I can post the whole batch file called by ComSkipLauncher in my MediaPortal.
    That looks clever. It might be useful to run the script as a scheduled task though so it can pick up recordings more than x days old as Tommy requested, rather than running it every time a new recording is made. It wouldn't be difficult to look at the endTime field to determine how old a recording is.

    Sasha
     

    batsi

    Portal Member
    May 23, 2008
    10
    3
    Munich
    Home Country
    Germany Germany
    It is probably fine if you have a server running 24/7, but my HTPC is set to sleep when idle and this seems to mess MCE Buddy up a bit. Would be great if there was a specific MP plugin to do what MCE Buddy tries to do.
    My MP also doesn't run 24/7 but is configured to fall into S3 a few minutes after a recording. This is enough time to move the recording files over the network.
    I'm pretty new to MediaPortal, therefore my primary aim was a quick solution. But I guess I will have a look at how MP plugins are designed and maybe I will try to create one for this.

    It might be useful to run the script as a scheduled task though so it can pick up recordings more than x days old as Tommy requested, rather than running it every time a new recording is made. It wouldn't be difficult to look at the endTime field to determine how old a recording is.
    This sounds easily possible as well. Running a scheduled task checking the modify time or the timestamp from the recording filename. But it sounded as if Tommy also just got stuck with the SQL part.
     

    TommySharp

    MP Donator
  • Premium Supporter
  • January 15, 2007
    322
    7
    43
    Auckland
    Home Country
    New Zealand New Zealand
    The SQL part I could probably construct myself as I use it quite a bit at work..... Will have to investigate using a batch file that can only copy files older than x days..... Google should be able to help out there....
     

    batsi

    Portal Member
    May 23, 2008
    10
    3
    Munich
    Home Country
    Germany Germany
    Hi Tommy,
    for this part the command "forfiles" should be perfect. It's included in Windows 7, for XP you have to install a resource kit, I guess.
    It is quite handy, for example it can be called this way...
    Code:
    forfiles /d -14 /m *.ts /p D:\Recordings /c "cmd /c moveTS.cmd @path"
    ...for executing the batch file moveTS.cmd for each *.ts file in D:\Recordings that is older than 14 days.
     

    TommySharp

    MP Donator
  • Premium Supporter
  • January 15, 2007
    322
    7
    43
    Auckland
    Home Country
    New Zealand New Zealand
    Okay well I've got a batch file moving the files now but have an issue with the SQL, can't quite think how I'd achieve it using microsoft SQL either...

    My recordings are all in different folders such as below....

    D:\Recordings\The Wiggles Show\The Wiggles Show - SE -.ts
    D:\Recordings\Sesame Street\Sesame Street - SE -_2.ts

    Now what I need to work out is how to replace everything before the last backslash with the new path on my NAS sucvh as....

    \\server\tv recordings\The Wiggles Show - SE -.ts
    \\server\tv recordings\Sesame Street - SE -_2.ts

    Anyone willing to help me hunt through the interweb to try and work this out?
     

    TommySharp

    MP Donator
  • Premium Supporter
  • January 15, 2007
    322
    7
    43
    Auckland
    Home Country
    New Zealand New Zealand
    Okay quick dirty fix was to instruct TVServer to not save recorded shows in all these fancy folders. :)

    This should make the search and replace a little easier :)

    Replace D:\Recordings with \\server\tv recordings

    Will see how I get on with that.... Having all the recorded stuff all in one folder doesn't bother me...
     

    Users who are viewing this thread

    Top Bottom