emericg / OpenSubtitlesDownload

Automatically find and download the right subtitles for your favorite videos!
https://emeric.io/OpenSubtitlesDownload
GNU General Public License v3.0
579 stars 63 forks source link

Feature request: Add subnuker functionality #64

Closed neofright closed 3 years ago

neofright commented 3 years ago

Hi,

I've been using OpenSubtitlesDownload to automate sub downloading for my TV shows and it works really well!

As we are downloading the 'free' version of subtitles they have adverts in them.

I did some research on trying to remove these and I found subnuker. The default regexes of subnuker are dangerous - for example I watch a lot of ER and it attempts to remove subtitles containing "syncope" because it matches the regex for "sync".

Anyway, using the following command line: subnuker --yes --file "$HOME/subnuker_pattern_file.txt" "$srt_file" With the contents of:

[foo@BAR ~]$ cat subnuker_pattern_file.txt
OpenSubtitles

It perfectly cleans downloaded subs.

I think I will either investigate more subsytem or add some additional logic into OpenSubtitlesDownload to make a separate call to subnuker.

Interested in any thoughts / replies you might have!

emericg commented 3 years ago

Hi, I didn't know about subnuker. I can't add a dependency to this script, and besides this must stay an effort made by the user. Ads are there on free accounts for a reason ^^

However I can commit a placeholder for people that want to chain additional commands after this script, that could be potentially usefull for other use cases as well.

If you want to run a command after a subtitles is downloaded, right after the block that begins by # If an error occurs, say so (and at the same level) I believe you can use this line:

process_subtitlesDownload = subprocess.call("(subnuker --stuff " + subPath + ") 2>&1", shell=True)

Let me know how it goes!

neofright commented 3 years ago
# If an error occurs, say so
if process_subtitlesDownload != 0:
    superPrint("error", "Subtitling error!", "An error occurred while downloading or writing <b>" + subtitlesList['data'][subIndex]['LanguageName'] + "</b> subtitles for <b>" + videoTitle + "</b>.")
    osd_server.LogOut(session['token'])
    sys.exit(2)
process_subtitlesDownload = subprocess.call("(subnuker --yes --file " + os.path.join(os.getenv('HOME'), 'subnuker_pattern_file.txt') + " " + subPath + ") 2>&1", shell=True)

It's not pretty, but it works! (I changed the indentation to make it a bit easier to read.)

Thanks for the help :)

emericg commented 3 years ago

Allright good to know it works for you!