[PP-Script / Scan-Script] Automatically Fetch Subtitles

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.
hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by hugbug » 03 Aug 2014, 21:45

Sorry for not having checked your script yet.

Actually I'm not interested in development of the script myself. I'd be more than happy If you could take the further development and maintenance of the script. And it looks like you did this already ;).

I can host your version of the script if you want but it would be more convenient for you and users if you host the script yourself - on your own web-site, on github or elsewhere. I'd put the link into the first post of the topic. This way you can update the script as often as you want/need.

However if you don't have intention to develop the script further I can of course take your version with thanks and put it online.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by hugbug » 03 Aug 2014, 22:07

l2g wrote:Can you give me just few quick points about Scheduler scripts?
Take your pp-script and change the signature to:

Code: Select all

### NZBGET POST-PROCESSING/SCHEDULER SCRIPT
After that you should be able to select the script in the option PostScript (as it worked before) and in the option TaskX.Script.

When the script is launched as scheduler script it becomes similar env vars as pp-script. Only the pp-script-related specific env vars (such as NZBPP_NZBNAME) are not available. To be more precise the following env. vars categories are available for both pp-script and scheduler script:
  • NZBGet configuration options - NZBOP_XXX;
  • Script configuration options - NZBPO_XXX.
In addition to that scheduler script is supposed to become its own specific env. vars but there is only one of this category:
  • NZBSP_TASKID - number of the task.
Using the id number the script can access NZBGet configuration options (NZBOP_XXX) to read the options which define the task (NZBOP_TASK1_TIME, etc.). However I don't see how this info could be useful for subliminal script.
l2g wrote:I understand your instructions involving the checking of NZBOP_DESTDIR to determine what mode i'm in.
No, you use NZBPP_DIRECTORY to determine the mode. NZBPP_DIRECTORY is passed to pp-script but not to scheduler script. NZBPP_-vars hold nzb-file specific infos, which don't exist in scheduler script.

NZBOP_DESTDIR holds default destination directory (which can be overridden for categories though). As all other env vars from category "NZBGet configuration options" it is passed to both scripts (pp-script and scheduler script). You can use it in the scheduler mode as the root category to scan for files which need downloading of subtitles. However you better should provide a specific option in the script for that path (and use NZBOP_DESTDIR if the user didn't set the path).
l2g wrote:Yet it may be an option for the post-process part. Is there a way to separate the options apart... or just write 2 seperate scripts?
Most options work in both mode, except for that root-path. Still if you want you can define option sections. PP-scripts usually have only one section "OPTIONS":

Code: Select all

### OPTIONS                                                                ###
But you can define more:

Code: Select all

### GENERAL                                                                ###
#OneOption=yes

### SCHEDULER MODE                                                         ###
#Option_for_scheduler_mode=1
#Another_option_for_scheduler_mode=1
You can name sections as you like.
I wouldn't create new section for a single option but if you need to group more of them - why not.

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by l2g » 04 Aug 2014, 06:44

Thanks hugbug for all your help and the information you provided is just awesome!

I made one last update here: subliminal-ppscript-0.7.4-0-003.zip for those reading and want to test it out.

I wiil see about checking all this into github if that's what you'd prefer. Give me a few days and i'll add it when i have time. In the meantime, i still plan on enhancing pynzbget. I am adding support so you can declare your variables like this:

Code: Select all

from nzbget import PostProcessScript
from nzbget import SchedulerScript

class MyNZBGetScript(PostProcessScript, SchedulerScript):
     def scheduler_main(self):
        # all of your code here for schedule scripting

     def postprocess_main(self):
        # all of your code here for postprocess scripting
You'll be able to declare a class with as many SubScript classes as you want. Right now, the set() and get() functions, nzbparsing and easy interaction with a shared sqlite database really make it really easy to integrate with NZBGet.

I'm already drifting into a different topic then this thread pertains, but i just have 1 more question for you: Is there a common ID or instance # that you could associate uniquely with every nzb/download/extract/postprocess (as a group)? I was looking for a way of creating a primary key. Right now i'm using the nzbfilename... it's pretty unique per transaction (unless you force-run the commands again; then it gets reused). i saw NZBPP_NZBID and was curious if that's similar to just using the nzb file. Is it constant throughout the entire post processing?

I was also thinking about using ppid() (parent pid). I haven't looked into your code yet, but i assume you fork() before executing the post process scripts? Would the ppid() be constant thoughout an entire transaction (all scripts?)
Last edited by l2g on 05 Aug 2014, 16:55, edited 1 time in total.

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by hugbug » 04 Aug 2014, 12:01

NZBID is indeed what you need. When adding to queue nzb-file becomes NZBID assigned and it remains constant. It's even better than nzb-name because the name is editable by user (although it cannot be changed once the post-processing began).

Parent pid should be the same, I think. However keep in mind that it is not available on Windows.

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

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by kloaknet » 04 Aug 2014, 14:39

first test of 003 on a random file:

error Mon Aug 04 2014 16:34:18 Post-process-script subliminal/Subliminal.py for xxx failed (terminated with unknown status)
info Mon Aug 04 2014 16:34:18 Subliminal: ImportError: No module named guessit
info Mon Aug 04 2014 16:34:18 Subliminal: import guessit
info Mon Aug 04 2014 16:34:18 Subliminal: File "/share/Apps/NZBget/ppscripts/subliminal/Subliminal.py", line 117, in <module>
info Mon Aug 04 2014 16:34:18 Subliminal: Traceback (most recent call last):
info Mon Aug 04 2014 16:34:18 Executing post-process-script subliminal/Subliminal.py for xxx

NZBGet 13.0-testing-r963

Note also that windows 7 gives some error on the .zip file, 7zip works. (cannot open folder, file invalid)

hope to do some more testing this evening.

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by l2g » 04 Aug 2014, 18:45

Updated link: subliminal-ppscript-0.7.4-0-004.zip
kloaknet wrote:first test of 003 on a random file:
info Mon Aug 04 2014 16:34:18 Subliminal: ImportError: No module named guessit
Should work now in attached file
kloaknet wrote: Note also that windows 7 gives some error on the .zip file, 7zip works. (cannot open folder, file invalid)
hope to do some more testing this evening.
I appreciate you testing this, Please try the new release I attached.

BigBossman
Posts: 6
Joined: 30 Jul 2014, 01:19

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by BigBossman » 04 Aug 2014, 23:15

Still getting import error on new version

Subliminal: ImportError: No module named guessit

It looks like its adding scripts/lib instead of scripts/subliminal/lib to the sys.path

hugbug
Developer & Admin
Posts: 7645
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by hugbug » 04 Aug 2014, 23:36

1. One "dirname" too much here:

Code: Select all

sys.path.insert(0, join(dirname(dirname(__file__)), 'lib'))
2. Lib "stevedore" is missing in lib-directory.

3. It didn't find any subs for me. it prints a strange message about nzb-file missing "WARNING - NZB-File not found":

Code: Select all

info	Tue Aug 05 2014 01:33:35	Post-process-script subliminal-new/Subliminal.py for Californication.S07E01.HDTV.x264-EXCELLENCE skipped
info	Tue Aug 05 2014 01:33:35	subliminal-new/Subliminal: 2014-08-05 01:33:35,392 - 23110 - WARNING - No subtitles were found.
info	Tue Aug 05 2014 01:33:35	subliminal-new/Subliminal: 2014-08-05 01:33:35,380 - 23110 - INFO - Connected to SQLite Database
info	Tue Aug 05 2014 01:33:35	subliminal-new/Subliminal: 2014-08-05 01:33:35,027 - 23110 - WARNING - NZB-File not found: /Volumes/Storage/Usenet-Downloads/Californication.S07E01.HDTV.x264-EXCELLENCE.nzb
info	Tue Aug 05 2014 01:33:35	subliminal-new/Subliminal: 2014-08-05 01:33:35,026 - 23110 - INFO - Script Mode: POSTPROCESS
info	Tue Aug 05 2014 01:33:34	Executing post-process-script subliminal-new/Subliminal.py for Californication.S07E01.HDTV.x264-EXCELLENCE

l2g
Posts: 228
Joined: 27 Jun 2014, 22:13
Contact:

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by l2g » 05 Aug 2014, 01:45

Updated link: subliminal-ppscript-0.7.4-0-005.zip
- added stevedore
- fixed dirname()

Don't worry about the warning about the nzbfile. It's because it wraps the pynzbget framework i wrote. Had it found the nzbfile it would have further parsed it for more meta information to help look up the subtiltes with.

I appologize for submitting non-working stuff. I can't test this since it works for me because the missing libraries were available globally in my environment. I appreciate you guys testing this out, I"ll keep fixing what you find and i'll get a VM going soon with a better environment to test with in the future.

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

Re: [PP-Script] Subliminal - Subtitles, faster than your tho

Post by kloaknet » 05 Aug 2014, 16:05

l2g wrote: I appologize for submitting non-working stuff. I can't test this since it works for me because the missing libraries were available globally in my environment. I appreciate you guys testing this out, I"ll keep fixing what you find and i'll get a VM going soon with a better environment to test with in the future.
No problem, I just really appreciate what you are doing :D, and I am happy to test the stuff for you. No .zip error this time btw.

for 005:

Code: Select all

error	Tue Aug 05 2014 18:00:02	Post-process-script subliminal/Subliminal.py for Crossbones.S01E09.480p.HDTV.x264-REenCO failed (terminated with unknown status)
info	Tue Aug 05 2014 18:00:02	Subliminal: ImportError: No module named pkg_resources
info	Tue Aug 05 2014 18:00:02	Subliminal: import pkg_resources
info	Tue Aug 05 2014 18:00:02	Subliminal: File "/share/Apps/NZBget/ppscripts/subliminal/lib/guessit/__init__.py", line 23, in <module>
info	Tue Aug 05 2014 18:00:02	Subliminal: import guessit
info	Tue Aug 05 2014 18:00:02	Subliminal: File "/share/Apps/NZBget/ppscripts/subliminal/Subliminal.py", line 117, in <module>
info	Tue Aug 05 2014 18:00:02	Subliminal: Traceback (most recent call last):
info	Tue Aug 05 2014 18:00:02	Executing post-process-script subliminal/Subliminal.py for Crossbones.S01E09.480p.HDTV.x264-REenCO
So guessit is imported! but cannot find the pkg_resources stuff in the guessit folder(s) ;)

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 29 guests