Closed GRMajestic closed 7 years ago
Hi,
I wrote a script for this some time ago; you can find it here: http://pastebin.com/UAHTd6DD It will download both English and Dutch subtitles, for all the movies for which there aren't any subtitles yet.
It can be easily triggered after a download is completed, or with a cronjob.
Regards! Jeroen
Hi,
I read it and according to my understanding, this script is checking for suffix ("_en" for example) after the basename of the movie. Which is absolutely fine but will not work with the current OpenSubtitlesDownload.py because the downloaded subtitles are not contain this suffix. To be like this (without suffix) is convenient for me because is the only way to be added on the DNLA stream. Any thoughts?
Thank you for your time!
There is a setting in OpenSubtitlesDownload, which allows you to add the language suffix (opt_write_languagecode = 'on'). If you use Kido, it will recognize the subs with the suffix too!
Thank you Jeroenvdw! Kodi is a solution, but cannot be implemented on a raspberry which is not connect on TV screen. My rasp is running a mini DLNA server and the Smart TV is the DLNA player. The problem here is that my TV cannot "see" the subtitles if they haven't the same name with the movie.
then the only option would be to adapt the script, so no language suffix will be searched (you'll only be able to download one language then)
I would not remove the ability to download multiple languages.
In my opinion you should write a script that checks if a subtitle file already exists and exit without launching this OpenSubtitleDownload script in the first place, this should be a reasonably simple script to write.
I purposely rewrite the subtitle file when I see it is wrong, so removing this would make doing this more difficult for me as I'd have to modify my script to remove any existing subtitles before launching the script for files that already have subtitles.
So, your recommendation guys is to adapt this script (http://pastebin.com/UAHTd6DD) in order to check if the .srt file is in place. Am I right?
I was thinking if it is possible to modify the script in order to check if the subtitle(s) is already downloaded looking for a checksum (maybe?) of it. But, at this point my question is, if the xml-rpc server at opensubtitles.org is able to support a such functionality...
Looking forward to your feedback and thank you all for your ideas and time spent on this thread.
Hey guys.
@jeroenvdw Nice script ;-) Beware the 'opt_write_languagecode' setting has been renamed in 'opt_language_suffix' in the latest versions.
Also, the ability to download multiple languages (at once) has kindof already been removed. It not in the documentation but the feature is still in the script. It was causing troubles with GUI and wasn't really tested (by me anyway). I've got no plan to completly remove the feature from the code so using it through CLI will continue to work.
@GRMajestic I can add a setting "opt_overwrite_file" (default = ON), and turning it off would mean searching for a subtitles matching the filename + langage code (if set to ON) for the current language(s) set by setting or arguments. But checking if the subtitles found match one from opensubtitles.org, now that's something else entierly...
I can also add more stuff configurable by arguments if that can help you doing more automation through scripts.
Hi all,
I tried to write my own python script based on the above(http://pastebin.com/UAHTd6DD).
I am sorry for the newbie script (its just a try)...Find below what I did:
`#!/usr/bin/python3
import os import re
startDir = "/media/usbhdd/Downloads/Movies/" #the starting directory to look for movies movies = [] subs = []
def checkDir(dir): for file in os.listdir(dir): if os.path.isdir(os.path.join(dir,file)): checkDir(os.path.join(dir,file)) else:
file = os.path.join(dir,file)
m = re.match("^(.*)\.(mkv|avi|mp4)$",file,re.I)
if m:
movies.append(file)
else:
m = re.match("^(.*)\.(srt|sub)$",file,re.I)
if m:
subs.append(file)
checkDir(startDir)
for movie in movies: subsexistance = False for sub in subs: if sub[:-4].find(movie[:-4]) > -1: if sub[-4:-3] == ".": subsexistance = True if not subsexistance: print("Searching sub for "+movie) cmd = "python3 /home/trnt/OpenSubtitlesDownload.py " cmd = cmd + "\"" + movie + "\""
os.system(cmd)`
I am receiving in some cases the below error:
>> Downloading 'Greek' subtitles for '"The Flash" Invincible' 2017-03-12 21:19:45 URL:http://dl.opensubtitles.org/en/download/src-api/vrf-199f0c50/sid-IcCsMUvAbO5fVMjxTWukmtziGF2/filead/1955210772.gz [20458/20458] -> "-" [1] Traceback (most recent call last): File "/home/trnt/OpenSubtitlesDownload.py", line 655, in <module> if session['token']: osd_server.LogOut(session['token']) File "/usr/lib/python3.2/xmlrpc/client.py", line 1076, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.2/xmlrpc/client.py", line 1403, in __request verbose=self.__verbose File "/usr/lib/python3.2/xmlrpc/client.py", line 1117, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.2/xmlrpc/client.py", line 1149, in single_request dict(resp.getheaders()) xmlrpc.client.ProtocolError: <ProtocolError for api.opensubtitles.org/xml-rpc: 503 Backend fetch failed> 256
Can you please advise me if i am wrong somewhere in my script? Or it's something different?
Thank you,
Hi, the last commit add a setting 'opt_search_overwrite' that can be toggled to 'off' (only by editing OpenSubtitlesDownload.py file however) if you don't want to re-download a subtitles files. Can you try it and tells me if it correspond to what you have in mind?
@emericg Thank you, that was exactly what i want!
Hello,
I would like to provide you some feedback along with a proposal for a new function. First of all, its the first script after a long period which i can use it on my raspberry pi!
Now, what i would like to propose is a new functionality regarding the downloading of the same file. From my side, this script is being triggered automatically every time where a new movie is downloaded on a specific folder. Some times the subtitles are not available the time where the movie is available on my raspberry. So, i have to re-trigger it automatically (via crontab) again every night in order to find the subtitles. The issue is that, there is no exit code or alternative function in case of the subtitles are already available on this folder, as a result the script downloads the same files every night.
I don't know if someone has another solution for my case (which can be scripted through SHELL SCRIPT) or he/she can modify the python script in order to check that there are already subtitles available, or maybe to provide a different exit code in order to catch it (the exit code i mean) via the Unix script.
Looking forward to your feedback,