Media Center Master community forums
http://forums.MediaCenterMaster.com/

SabNZBd post-processing script for separating downloads
http://forums.MediaCenterMaster.com/viewtopic.php?f=7&t=7299
Page 1 of 2

Author:  Pete [ May 27th, 2013, 6:52 pm ]
Post subject:  SabNZBd post-processing script for separating downloads

If you use Media Center Master with SabNZBd, you may find this little script handy. It simply tries to determine if a download has video in it and if so, it'll move the download to a folder that Media Center Master can process -- otherwise it will move it elsewhere:

Code:
@ECHO OFF
REM **
REM ** If SabNZBd says the processing completed successfully...
REM **
IF %7 == 0 (
   CD /D %1
   IF EXIST *.mkv (
      REM **
      REM ** ... and this folder has an MKV video, then we must have downloaded a movie or TV episode ...
      REM **
      CD \
      ECHO This is a *VIDEO* and is being moved accordingly...
      MOVE %1 D:\Downloads\Auto-scan
      EXIT 0
   )
   
   IF EXIST *.mp4 (
      REM **
      REM ** ... or this folder has an MP4 video, then we must have downloaded a movie or TV episode ...
      REM **
      CD \
      ECHO This is a *VIDEO* and is being moved accordingly...
      MOVE %1 D:\Downloads\Auto-scan
      EXIT 0
   )
   
   IF EXIST *.avi (
      REM **
      REM ** ... or this folder has an AVI video, then we must have downloaded a movie or TV episode ...
      REM **
      CD \
      ECHO This is a *VIDEO* and is being moved accordingly...
      MOVE %1 D:\Downloads\Auto-scan
      EXIT 0
   )

   IF EXIST *.ts (
      REM **
      REM ** ... or this folder has a ts video, then we must have downloaded a movie or TV episode ...
      REM **
      CD \
      ECHO This is a *VIDEO* and is being moved accordingly...
      MOVE %1 D:\Downloads\Auto-scan
      EXIT 0
   )
   
   IF EXIST *.wmv (
      REM **
      REM ** ... or this folder has a wmv video, then we must have downloaded a movie or TV episode ...
      REM **
      CD \
      ECHO This is a *VIDEO* and is being moved accordingly...
      MOVE %1 D:\Downloads\Auto-scan
      EXIT 0
   )
   
   
   REM **
   REM ** ... otherwise ...
   REM **
   CD \
   ECHO This is a miscellaneous download and is being moved accordingly...
   MOVE %1 D:\Downloads\Other
   EXIT 0
)

REM **
REM ** Tell SabNZBd that all is well with our script.
REM **
EXIT 0


Note that I use "D:\Downloads\Auto-Scan" for completed downloads that Media Center Master should parse and "D:\Downloads\Other" for everything else. You'll want to modify the script accordingly. For reference, I have SabNZBd's completed downloads in "D:\Downloads\Completed".

Author:  theimmortal [ September 30th, 2013, 4:22 am ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

Very nice script! I had it up and running nicely with SABnzbd up until a couple days ago. I am running a development build of 0.8.x and for some reason when it passes the folder name to the script it prefixes it with \\?\ (\\?\D:\Downloads\... instead of D:\Downloads\...) which of course throws a UNC error. I realize this is a bug/WIP issue with SABnzbd since I am running the development version, but I was hoping you could help me with a work around until this is fixed. Thank you!

Author:  Pete [ September 30th, 2013, 12:35 pm ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

Sure -- don't use a dev build of SabNZBd. ;)

No, but seriously -- is there something in the dev builds you need? Clearly they're breaking essential functionality.

Author:  theimmortal [ October 1st, 2013, 6:42 pm ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

I hear you about running development software... I just can't help but play with things, even when they are working as intended. :)

Nothing that I absolutely needed. I was getting a lot of downloads that needed repairs, and it was a lengthy process that was backing up my queue (completed downloads waiting for post-processing). The development version has some really nice features that dramatically improve the repair process as well as more features/options to manage your queue that I really like. I was thinking maybe something like a regex to strip the \\?\ from the variable before continuing, but I don't know how to implement something like that. Currently that is the only problem I have run into in 0.8.x.

Author:  theimmortal [ October 9th, 2013, 7:44 am ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

I thought I would report back since I was able to get this working correctly again. Apparently the \\?\ is a built-in Windows function that allows commands to override the long filenames limitation. However, it isn't universally implemented throughout Windows, so CMD see's it as a network address and refuses to continue. So first I had to disable UNC checking with this registry entry:

Under the registry path:
HKEY_CURRENT_USER
\Software
\Microsoft
\Command Processor

add the value DisableUNCCheck REG_DWORD and set the value to 0 x 1 (Hex).

The next obstacle was correcting some commands in the script to work with the new variables. It seems that CMD can utilize \\?\ for everything except changing directories (wierd). You can create a directory using md \\?\d:\new and it works just fine. You can also copy, move, etc. You just can't change directories. To overcome this I removed the "CD /D %1" from line 6, and changed all the IF statements to read "IF EXIST %1\*.ext". And SUCCESS! After that I was able to resume normal usage of the script. :)

Author:  chongwho [ December 11th, 2013, 3:23 am ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

I'm looking to get some help with the above script.


I have Sickbeard working well with SAB, and once a download is completed it runs SabToSickbeard.exe

When there is a movie completed in SAB, I would like to run a post processing script that moves the file to sab\downloads\complete\auto-scan folder (similar to above).

I am an absolute beginner with Scripts but it looks what you have above would work for my purposes. What I want to know is, how do I create the script above to work with SAB? Do I need to create an .exe like with SabToSickbeard? I tried creating a text file, but that does not seem to register as a usable script in SAB.

I know this is real beiginner stuff, but i nearly have everything running perfectly, and would like this last piece of the puzzle to be sorted.

Thanks

Author:  stixx [ January 11th, 2014, 3:35 pm ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

Pete -I am having problems using your script with SABnzdb (see attachment)

I am using the following script. Any ideas?

@ECHO OFF
REM **
REM ** If SabNZBd says the processing completed successfully...
REM **
IF %7 == 0 (
CD /D %1
IF EXIST *.mkv (
REM **
REM ** ... and this folder has an MKV video, then we must have downloaded a movie or TV episode ...
REM **
CD \
ECHO This is a *VIDEO* and is being moved accordingly...
MOVE %1 E:\Recorded TV
EXIT 0
)

IF EXIST *.mp4 (
REM **
REM ** ... or this folder has an MP4 video, then we must have downloaded a movie or TV episode ...
REM **
CD \
ECHO This is a *VIDEO* and is being moved accordingly...
MOVE %1 E:\Recorded TV
EXIT 0
)

IF EXIST *.avi (
REM **
REM ** ... or this folder has an AVI video, then we must have downloaded a movie or TV episode ...
REM **
CD \
ECHO This is a *VIDEO* and is being moved accordingly...
MOVE %1 E:\Recorded TV
EXIT 0
)

IF EXIST *.ts (
REM **
REM ** ... or this folder has a ts video, then we must have downloaded a movie or TV episode ...
REM **
CD \
ECHO This is a *VIDEO* and is being moved accordingly...
MOVE %1 E:\Recorded TV
EXIT 0
)

IF EXIST *.wmv (
REM **
REM ** ... or this folder has a wmv video, then we must have downloaded a movie or TV episode ...
REM **
CD \
ECHO This is a *VIDEO* and is being moved accordingly...
MOVE %1 E:\Recorded TV
EXIT 0
)


REM **
REM ** ... otherwise ...
REM **
CD \
ECHO This is a miscellaneous download and is being moved accordingly...
MOVE %1 E:\
EXIT 0
)

REM **
REM ** Tell SabNZBd that all is well with our script.
REM **
EXIT 0

Attachments:
File comment: Error
SABnzdb.PNG
SABnzdb.PNG [ 8.21 KiB | Viewed 17301 times ]

Author:  Pete [ January 11th, 2014, 10:39 pm ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

You need quotes around "E:\Recorded TV".

Author:  stixx [ January 12th, 2014, 12:11 am ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

Pete wrote:
You need quotes around "E:\Recorded TV".


Thanks. I will give that a try

Author:  stixx [ January 13th, 2014, 11:56 am ]
Post subject:  Re: SabNZBd post-processing script for separating downloads

Pete wrote:
You need quotes around "E:\Recorded TV".


Yep - that worked. Thanks again!

Page 1 of 2 All times are UTC - 7 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/