[Request] Copy external .srt files before Sonarr processes

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
vinnytr9
Posts: 4
Joined: 25 Feb 2015, 07:14

[Request] Copy external .srt files before Sonarr processes

Post by vinnytr9 » 25 Feb 2015, 07:28

I was wondering is there a post-process script that can copy files with certain extensions such as ".srt" and the kind to a different directory before Sonarr processes the file and passes it onto my Media folder.

I'm using the mp4 automator from mdhiggins that can extract .srts in the video files; however, when Sonarr processes the folder with the video file it only copies the video and then deletes the rest.

I want a script that can run after the mp4 script to copy all the ".srt" files into another folder so I can manually move them in the the correct Shows or Movies folder after. This is all before Sonarr passes on the video file and then subsequently deletes the folder of course.

So I was wondering if the good people on here can help me with this "issue" lol

kloaknet
Posts: 335
Joined: 23 Jul 2014, 08:52

Re: [Request] Copy external .srt files before Sonarr process

Post by kloaknet » 25 Feb 2015, 15:50

The script you want is not that difficult to make, its just listing the files in the folder where the nzb file is located. Assuming you have python installed:

create a (unix) file like move.py

use NZBPP_DIRECTORY to get the path were your srt file will be

search for a file with the .srt extension:

Code: Select all

file_loc = os.environ['NZBPP_DIRECTORY']

for file in os.listdir(file_loc):
            if file.endswith(".srt")
                    copyfile('/dir/file.ext', '/new/dir/newname.ext')
http://nzbget.net/Extension_scripts and check also some simple example files like this one that also does file handling http://nzbget.net/forum/viewtopic.php?f=8&t=806.


Other way to go is just grab your subs like 1 time a day using the subliminal script, using it as a scheduler script to search for the subtitles on sites like addic7ed etc, in that way you don't even need to move the files manually:

http://nzbget.net/forum/viewtopic.php?f=8&t=1422

vinnytr9
Posts: 4
Joined: 25 Feb 2015, 07:14

Re: [Request] Copy external .srt files before Sonarr process

Post by vinnytr9 » 25 Feb 2015, 17:41

kloaknet wrote:The script you want is not that difficult to make, its just listing the files in the folder where the nzb file is located. Assuming you have python installed:

create a (unix) file like move.py

use NZBPP_DIRECTORY to get the path were your srt file will be

search for a file with the .srt extension:

Code: Select all

file_loc = os.environ['NZBPP_DIRECTORY']

for file in os.listdir(file_loc):
            if file.endswith(".srt")
                    copyfile('/dir/file.ext', '/new/dir/newname.ext')
http://nzbget.net/Extension_scripts and check also some simple example files like this one that also does file handling http://nzbget.net/forum/viewtopic.php?f=8&t=806.


Other way to go is just grab your subs like 1 time a day using the subliminal script, using it as a scheduler script to search for the subtitles on sites like addic7ed etc, in that way you don't even need to move the files manually:

http://nzbget.net/forum/viewtopic.php?f=8&t=1422
Thanks for your reply. I'm not good at coding at all but I was looking through some guides on the shutil action and I've tried to code myself just to see if it works or not.
Here is what my code looks like:

Code: Select all

nzbfulldir = os.environ.get('NZBPP_DIRECTORY','')

for file in os.listdir(nzbfulldir):
  if file.endswith(".srt")
	  src_dir = nzbfulldir
	  dst_dir = "C:\Users\x\Downloads\Subtitles\"
	  shutil.copy2(src_dir,dst_dir)
sys.exit(POSTPROCESS_SUCCESS)
However, that doesn't work for some reason. Maybe it doesn't search the subdirectories in the folder where Sonarr picks ups.
That folder is, let's say, "C:\Users\x\Documents\Downloads\Completed\DRONE". When the file is done downloading and starts to unpack there will be subdirectories within the DRONE folder. So I think that might be the reason why my script did not work.

I have also looked up and tried os.walk() but it also returns error. That's why I turned to the forum lol.

nerotic
Posts: 4
Joined: 28 Feb 2015, 13:35

Re: [Request] Copy external .srt files before Sonarr process

Post by nerotic » 28 Feb 2015, 13:41

Hey guys,

I'm new here and after switching from years of Sab/Sickbeard to NZBGet/Sonarr this past week.

A little bit of growing pains in the transition since I really wanted to perfect my ideal setup and I've finally hit it.

Vinny, take a look at this thread on Sonarr from the last couple of days. I was running into similar issues as you and found a way to get the best of both worlds : https://forums.sonarr.tv/t/need-help-wi ... ating/4362

You might find some answers there to deal with the issue you're trying to resolve.

I should add, it's not *perfect* but I'm still green with both technologies so if I find any other magical settings/configurations I'll update here.

vinnytr9
Posts: 4
Joined: 25 Feb 2015, 07:14

Re: [Request] Copy external .srt files before Sonarr process

Post by vinnytr9 » 28 Feb 2015, 17:29

nerotic wrote:Hey guys,

I'm new here and after switching from years of Sab/Sickbeard to NZBGet/Sonarr this past week.

A little bit of growing pains in the transition since I really wanted to perfect my ideal setup and I've finally hit it.

Vinny, take a look at this thread on Sonarr from the last couple of days. I was running into similar issues as you and found a way to get the best of both worlds : https://forums.sonarr.tv/t/need-help-wi ... ating/4362

You might find some answers there to deal with the issue you're trying to resolve.

I should add, it's not *perfect* but I'm still green with both technologies so if I find any other magical settings/configurations I'll update here.
Hi nerotic, thanks for the suggestion!
I've been messing about but no luck as yet. Anyway I think I figured out a way to simplify things haha.

Basically I would want to flatten the downloaded files into a single root folder so that I can postprocess the .srts file away into another folder. I have tried my luck at clinton's flatten.py script but for some reason it does not work :(. The downloaded files stayed in the subdirectories and then deleted by Sonarr afterwards...

After looking through your thread, I was wondering do you still have the flatten script lying around so I can perhaps try it again haha. But thanks for your reply hey.

nerotic
Posts: 4
Joined: 28 Feb 2015, 13:35

Re: [Request] Copy external .srt files before Sonarr process

Post by nerotic » 28 Feb 2015, 17:34

I'm using Clinton's flatten.py which I got from here : https://github.com/clinton-hall/GetScripts

And you're welcome, I hope you figure out your setup :)

vinnytr9
Posts: 4
Joined: 25 Feb 2015, 07:14

Re: [Request] Copy external .srt files before Sonarr process

Post by vinnytr9 » 28 Feb 2015, 17:51

nerotic wrote:I'm using Clinton's flatten.py which I got from here : https://github.com/clinton-hall/GetScripts

And you're welcome, I hope you figure out your setup :)
That's the one I've tried to use with no success :(
Maybe it's my settings though. Is there anyway you can screenshot your flatten settings page?
I have mine set up like this:

Image

But the files would still be in the /TV-HD/Fav.Show/files.txt,files.mkv
and not /TV-HD/files.mkv,etc...

If that link does not work: http://imgur.com/XYgJ4zx

nerotic
Posts: 4
Joined: 28 Feb 2015, 13:35

Re: [Request] Copy external .srt files before Sonarr process

Post by nerotic » 28 Feb 2015, 17:58

That particular field is blank for me.

I'm set up this way
Image
Image

https://db.tt/FH0mQuda
https://db.tt/aHowUtfX

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests