From 2887703c2de2d5c73d9d891407b2baf85aeb270b Mon Sep 17 00:00:00 2001 From: Brian Damage Date: Mon, 2 Dec 2013 15:56:39 +0100 Subject: [PATCH 1/6] Some changes to Addic7ed plugin: - added some more debugging output for easier troubleshooting later on - made some changes to the page parsing, tested it on 4 releases with good results for me but needs more testing --- periscope/plugins/Addic7ed.py | 14 +++++++++++--- periscope/plugins/__init__.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/periscope/plugins/Addic7ed.py b/periscope/plugins/Addic7ed.py index 13781d1..eccd78b 100644 --- a/periscope/plugins/Addic7ed.py +++ b/periscope/plugins/Addic7ed.py @@ -60,7 +60,8 @@ def __init__(self, config, cache_folder_path): super(Addic7ed, self).__init__(langs=None,revertlangs=LANGUAGES) #http://www.addic7ed.com/serie/Smallville/9/11/Absolute_Justice self.host = "http://www.addic7ed.com" - self.release_pattern = re.compile(" \nVersion (.+), ([0-9]+).([0-9])+ MBs") + self.release_pattern = re.compile("Version (.+), ([0-9]+).([0-9])+ MBs") + logging.debug("Addic7ed plugin initialized") def process(self, filepath, langs): @@ -68,8 +69,10 @@ def process(self, filepath, langs): languages and it will query the subtitles source ''' fname = unicode(self.getFileName(filepath).lower()) guessedData = self.guessFileData(fname) + #logging.debug("Guessed data type: " + guessedData['type']) if guessedData['type'] == 'tvshow': subs = self.query(guessedData['name'], guessedData['season'], guessedData['episode'], guessedData['teams'], langs) +# logging.debug(guessedData['teams']) return subs else: return [] @@ -95,8 +98,11 @@ def query(self, name, season, episode, teams, langs=None): content = content.replace("The safer, easier way", "The safer, easier way \" />") soup = BeautifulSoup(content) + #logging.debug(soup) for subs in soup("td", {"class":"NewsTitle", "colspan" : "3"}): + #logging.debug(soup) if not self.release_pattern.match(str(subs.contents[1])): + logging.debug("No match found for: " + subs.contents[1]) continue subteams = self.release_pattern.match(str(subs.contents[1])).groups()[0].lower() @@ -111,17 +117,19 @@ def query(self, name, season, episode, teams, langs=None): logging.debug("[Addic7ed] Team from file: %s" %teams) logging.debug("[Addic7ed] match ? %s" %subteams.issubset(teams)) langs_html = subs.findNext("td", {"class" : "language"}) + #logging.debug(langs_html) + #logging.debug("[Addic7ed] Languages found: " + ','.join(langs_html)) lang = self.getLG(langs_html.contents[0].strip().replace(' ', '')) #logging.debug("[Addic7ed] Language : %s - lang : %s" %(langs_html, lang)) statusTD = langs_html.findNext("td") - status = statusTD.find("strong").string.strip() + status = statusTD.find("b").string.strip() # take the last one (most updated if it exists) links = statusTD.findNext("td").findAll("a") link = "%s%s"%(self.host,links[len(links)-1]["href"]) - #logging.debug("%s - match : %s - lang : %s" %(status == "Completed", subteams.issubset(teams), (not langs or lang in langs))) + logging.debug("%s - match : %s - lang : %s" %(status == "Completed", subteams.issubset(teams), (not langs or lang in langs))) if status == "Completed" and subteams.issubset(teams) and (not langs or lang in langs) : result = {} result["release"] = "%s.S%.2dE%.2d.%s" %(name.replace("_", ".").title(), int(season), int(episode), '.'.join(subteams) diff --git a/periscope/plugins/__init__.py b/periscope/plugins/__init__.py index 712f027..07c6aa7 100644 --- a/periscope/plugins/__init__.py +++ b/periscope/plugins/__init__.py @@ -31,7 +31,7 @@ #from SubScene import SubScene # Don't want to be included -#from Addic7ed import Addic7ed +from Addic7ed import Addic7ed #from TvSubtitles import TvSubtitles # API not working From aff3f11da46318822cdbbf359b2d50330e4563b7 Mon Sep 17 00:00:00 2001 From: Bart Baus Date: Mon, 2 Dec 2013 16:03:39 +0100 Subject: [PATCH 2/6] Some changes to Addic7ed plugin: - added some more debugging output for easier troubleshooting later on - made some changes to the page parsing, tested it on 4 releases with good results for me but needs more testing --- periscope/plugins/Addic7ed.py | 14 +++++++++++--- periscope/plugins/__init__.py | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/periscope/plugins/Addic7ed.py b/periscope/plugins/Addic7ed.py index 13781d1..eccd78b 100644 --- a/periscope/plugins/Addic7ed.py +++ b/periscope/plugins/Addic7ed.py @@ -60,7 +60,8 @@ def __init__(self, config, cache_folder_path): super(Addic7ed, self).__init__(langs=None,revertlangs=LANGUAGES) #http://www.addic7ed.com/serie/Smallville/9/11/Absolute_Justice self.host = "http://www.addic7ed.com" - self.release_pattern = re.compile(" \nVersion (.+), ([0-9]+).([0-9])+ MBs") + self.release_pattern = re.compile("Version (.+), ([0-9]+).([0-9])+ MBs") + logging.debug("Addic7ed plugin initialized") def process(self, filepath, langs): @@ -68,8 +69,10 @@ def process(self, filepath, langs): languages and it will query the subtitles source ''' fname = unicode(self.getFileName(filepath).lower()) guessedData = self.guessFileData(fname) + #logging.debug("Guessed data type: " + guessedData['type']) if guessedData['type'] == 'tvshow': subs = self.query(guessedData['name'], guessedData['season'], guessedData['episode'], guessedData['teams'], langs) +# logging.debug(guessedData['teams']) return subs else: return [] @@ -95,8 +98,11 @@ def query(self, name, season, episode, teams, langs=None): content = content.replace("The safer, easier way", "The safer, easier way \" />") soup = BeautifulSoup(content) + #logging.debug(soup) for subs in soup("td", {"class":"NewsTitle", "colspan" : "3"}): + #logging.debug(soup) if not self.release_pattern.match(str(subs.contents[1])): + logging.debug("No match found for: " + subs.contents[1]) continue subteams = self.release_pattern.match(str(subs.contents[1])).groups()[0].lower() @@ -111,17 +117,19 @@ def query(self, name, season, episode, teams, langs=None): logging.debug("[Addic7ed] Team from file: %s" %teams) logging.debug("[Addic7ed] match ? %s" %subteams.issubset(teams)) langs_html = subs.findNext("td", {"class" : "language"}) + #logging.debug(langs_html) + #logging.debug("[Addic7ed] Languages found: " + ','.join(langs_html)) lang = self.getLG(langs_html.contents[0].strip().replace(' ', '')) #logging.debug("[Addic7ed] Language : %s - lang : %s" %(langs_html, lang)) statusTD = langs_html.findNext("td") - status = statusTD.find("strong").string.strip() + status = statusTD.find("b").string.strip() # take the last one (most updated if it exists) links = statusTD.findNext("td").findAll("a") link = "%s%s"%(self.host,links[len(links)-1]["href"]) - #logging.debug("%s - match : %s - lang : %s" %(status == "Completed", subteams.issubset(teams), (not langs or lang in langs))) + logging.debug("%s - match : %s - lang : %s" %(status == "Completed", subteams.issubset(teams), (not langs or lang in langs))) if status == "Completed" and subteams.issubset(teams) and (not langs or lang in langs) : result = {} result["release"] = "%s.S%.2dE%.2d.%s" %(name.replace("_", ".").title(), int(season), int(episode), '.'.join(subteams) diff --git a/periscope/plugins/__init__.py b/periscope/plugins/__init__.py index 712f027..07c6aa7 100644 --- a/periscope/plugins/__init__.py +++ b/periscope/plugins/__init__.py @@ -31,7 +31,7 @@ #from SubScene import SubScene # Don't want to be included -#from Addic7ed import Addic7ed +from Addic7ed import Addic7ed #from TvSubtitles import TvSubtitles # API not working From 947b4cb9a45b9028120218288d2cdc0de5a08f77 Mon Sep 17 00:00:00 2001 From: birt Date: Tue, 3 Dec 2013 08:14:34 +0100 Subject: [PATCH 3/6] Added a command-line option to store all downloaded subs in a separate subtitles folder. ( --subtitles-folder) This will still first download the subtitles file in the directory where the media file is located. So it updates the time on that file/directory which is something we want to avoid if we have scripts processing our media files based on the age of the files. We have to assume the underlying filesystem doesn't support "time of birth" after stat() call. See http://unix.stackexchange.com/questions/24441/get-file-created-creation-time --- bin/periscope | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/periscope b/bin/periscope index f332fe9..79c7dce 100755 --- a/bin/periscope +++ b/bin/periscope @@ -42,6 +42,7 @@ def main(): parser.add_option("-i", "--interactive", action="store_true", dest="interactive", help="ask which subtitle to download") parser.add_option("-q", "--query", action="append", dest="queries", help="query to send to the subtitles website") parser.add_option("--lang-in-name", action="store_true", dest='lang_in_name', help="append lang to subtitle filename") + parser.add_option("--subtitles-folder", action="store", type="string", dest="subtitles_folder", help="location of folder to save subtitles in") parser.add_option("--cache-folder", action="store", type="string", dest="cache_folder", help="location of the periscope cache/config folder (default is ~/.config/periscope)") parser.add_option("--list-plugins", action="store_true", dest="show_plugins", help="list all plugins supported by periscope") parser.add_option("--list-active-plugins", action="store_true", dest="show_active_plugins", help="list all plugins used to search subtitles (a subset of all the supported plugins)") @@ -118,6 +119,13 @@ def main(): shutil.move(s['subtitlepath'], new_name) s['subtitlepath'] = new_name + if options.subtitles_folder: + for s in subs: + new_path = "%s%s" % (options.subtitles_folder, os.path.basename(s['subtitlepath'])) + log.debug("New path: " + new_path) + shutil.move(s['subtitlepath'], new_path) + s['subtitlepath'] = new_path + log.info("*"*50) log.info("Downloaded %s subtitles" %len(subs)) for s in subs: From 7aa9fe07b60de21d104f164bac1240c767eaa75f Mon Sep 17 00:00:00 2001 From: birt Date: Mon, 9 Dec 2013 13:05:42 +0100 Subject: [PATCH 4/6] Updated Addic7ed & OpenSubtitles plugins to support separate subtitles dir (not enabled yet) --- bin/periscope | 7 ++++--- periscope/periscope.py | 8 ++++---- periscope/plugins/Addic7ed.py | 2 +- periscope/plugins/OpenSubtitles.py | 2 +- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bin/periscope b/bin/periscope index 79c7dce..75c5ee5 100755 --- a/bin/periscope +++ b/bin/periscope @@ -71,8 +71,7 @@ def main(): exit() options.cache_folder = os.path.join(home, ".config", "periscope") - - periscope_client = periscope.Periscope(options.cache_folder) + periscope_client = periscope.Periscope(options.cache_folder) if options.show_active_plugins: print "Active plugins: " @@ -104,7 +103,7 @@ def main(): langs = periscope_client.preferedLanguages else: langs = options.langs - sub = periscope_client.downloadSubtitle(arg, langs, options.interactive) + sub = periscope_client.downloadSubtitle(arg, langs, options.interactive,options.subtitles_folder) if sub: subs.append(sub) @@ -125,6 +124,8 @@ def main(): log.debug("New path: " + new_path) shutil.move(s['subtitlepath'], new_path) s['subtitlepath'] = new_path + else: + options.subtitles_folder = '.' log.info("*"*50) log.info("Downloaded %s subtitles" %len(subs)) diff --git a/periscope/periscope.py b/periscope/periscope.py index 8c91646..62ab7e8 100755 --- a/periscope/periscope.py +++ b/periscope/periscope.py @@ -206,24 +206,24 @@ def selectBestSubtitle(self, subtitles, langs=["en"], interactive=False): return None #Could not find subtitles - def downloadSubtitle(self, filename, langs=None, interactive=False): + def downloadSubtitle(self, filename, langs=None, interactive=False,subtitles_folder=None): ''' Takes a filename and a language and creates ONE subtitle through plugins if interactive == True asks before downloading''' subtitles = self.listSubtitles(filename, langs) if subtitles: log.debug("All subtitles: ") log.debug(subtitles) - return self.attemptDownloadSubtitle(subtitles, langs, interactive) + return self.attemptDownloadSubtitle(subtitles, langs, interactive, subtitles_folder) else: return None - def attemptDownloadSubtitle(self, subtitles, langs, interactive=False): + def attemptDownloadSubtitle(self, subtitles, langs, interactive=False, subtitles_folder=None): subtitle = self.selectBestSubtitle(subtitles, langs, interactive) if subtitle: log.info("Trying to download subtitle: %s" %subtitle['link']) #Download the subtitle try: - subpath = subtitle["plugin"].createFile(subtitle) + subpath = subtitle["plugin"].createFile(subtitle,subtitles_folder) if subpath: subtitle["subtitlepath"] = subpath return subtitle diff --git a/periscope/plugins/Addic7ed.py b/periscope/plugins/Addic7ed.py index eccd78b..ad10dd1 100644 --- a/periscope/plugins/Addic7ed.py +++ b/periscope/plugins/Addic7ed.py @@ -153,7 +153,7 @@ def splitTeam(self, subteams, sep): teams += t.split(sep) return teams - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] diff --git a/periscope/plugins/OpenSubtitles.py b/periscope/plugins/OpenSubtitles.py index f1c00be..b4f4b45 100644 --- a/periscope/plugins/OpenSubtitles.py +++ b/periscope/plugins/OpenSubtitles.py @@ -99,7 +99,7 @@ def process(self, filepath, langs): fname = self.getFileName(filepath) return self.query(langs=langs, filename=fname) - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] From a163986ce511b47f3c01ac549588e7a5a96781de Mon Sep 17 00:00:00 2001 From: birt Date: Mon, 9 Dec 2013 14:58:25 +0100 Subject: [PATCH 5/6] enabled save to separate subtitles folder --- periscope/plugins/Addic7ed.py | 2 ++ periscope/plugins/LegendasTV.py | 4 +++- periscope/plugins/OpenSubtitles.py | 2 ++ periscope/plugins/Podnapisi.py | 4 ++-- periscope/plugins/SubDivX.py | 4 +++- periscope/plugins/SubScene.py | 6 ++++-- periscope/plugins/SubsWiki.py | 4 +++- periscope/plugins/SubtitleDatabase.py | 4 +++- periscope/plugins/SubtitleSource.py | 4 +++- periscope/plugins/Subtitulos.py | 4 +++- periscope/plugins/TheSubDB.py | 4 +++- 11 files changed, 31 insertions(+), 11 deletions(-) diff --git a/periscope/plugins/Addic7ed.py b/periscope/plugins/Addic7ed.py index ad10dd1..e49b472 100644 --- a/periscope/plugins/Addic7ed.py +++ b/periscope/plugins/Addic7ed.py @@ -159,6 +159,8 @@ def createFile(self, subtitle,subtitles_folder): suburl = subtitle["link"] videofilename = subtitle["filename"] srtbasefilename = videofilename.rsplit(".", 1)[0] + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) srtfilename = srtbasefilename +".srt" self.downloadFile(suburl, srtfilename) return srtfilename diff --git a/periscope/plugins/LegendasTV.py b/periscope/plugins/LegendasTV.py index df2aa74..e739f20 100644 --- a/periscope/plugins/LegendasTV.py +++ b/periscope/plugins/LegendasTV.py @@ -153,12 +153,14 @@ def LegendasTVLogin(self): request = urllib2.Request(self.url+'/login_verificar.php',login_data) response = urllib2.urlopen(request).read() - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the ID of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtfilename = videofilename.rsplit(".", 1)[0] + '.srt' + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) self.downloadFile(suburl, srtfilename) return srtfilename diff --git a/periscope/plugins/OpenSubtitles.py b/periscope/plugins/OpenSubtitles.py index b4f4b45..ec6087e 100644 --- a/periscope/plugins/OpenSubtitles.py +++ b/periscope/plugins/OpenSubtitles.py @@ -105,6 +105,8 @@ def createFile(self, subtitle,subtitles_folder): suburl = subtitle["link"] videofilename = subtitle["filename"] srtbasefilename = videofilename.rsplit(".", 1)[0] + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) self.downloadFile(suburl, srtbasefilename + ".srt.gz") f = gzip.open(srtbasefilename+".srt.gz") dump = open(srtbasefilename+".srt", "wb") diff --git a/periscope/plugins/Podnapisi.py b/periscope/plugins/Podnapisi.py index cbd420a..48c7c5f 100644 --- a/periscope/plugins/Podnapisi.py +++ b/periscope/plugins/Podnapisi.py @@ -102,7 +102,7 @@ def query(self, token, langs=None): log.debug(sublinks) return sublinks - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' subpage = subtitle["page"] @@ -119,5 +119,5 @@ def createFile(self, subtitle): dlimg = soup.find("img", {"title" : "Download"}) subtitle["link"] = self.host + dlimg.parent["href"] - SubtitleDatabase.SubtitleDB.createFile(self, subtitle) + SubtitleDatabase.SubtitleDB.createFile(self, subtitle,subtitles_folder) return subtitle["link"] diff --git a/periscope/plugins/SubDivX.py b/periscope/plugins/SubDivX.py index 2fe5b89..4a6c2cf 100644 --- a/periscope/plugins/SubDivX.py +++ b/periscope/plugins/SubDivX.py @@ -121,7 +121,7 @@ def query(self, name, season=None, episode=None, extra=None): sorted_links = sorted(sublinks, key=lambda k: k['rating'], reverse=True) return sorted_links - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''Download and extract subtitle. Pass the URL of the sub and the file it matches, will unzip it @@ -146,6 +146,8 @@ def createFile(self, subtitle): video_filename = os.path.basename(subtitle["filename"]) base_filename, _ = os.path.splitext(video_filename) base_rar_filename, _ = os.path.splitext(subtitle["filename"]) + if subtitles_folder: + base_rar_filename = subtitles_folder + base_rar_filename rar_filename = '%s%s' % (base_rar_filename, '.rar') self.downloadFile(download_url, rar_filename) diff --git a/periscope/plugins/SubScene.py b/periscope/plugins/SubScene.py index 14aa914..91d9ffe 100644 --- a/periscope/plugins/SubScene.py +++ b/periscope/plugins/SubScene.py @@ -84,7 +84,7 @@ def process(self, filepath, langs): traceback.print_exc() return [] - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' subpage = subtitle["page"] @@ -94,7 +94,9 @@ def createFile(self, subtitle): dlhref = soup.find("div", {"class" : "download"}).find("a")["href"] subtitle["link"] = "http://subscene.com" + dlhref.split('"')[7] format = "zip" - archivefilename = subtitle["filename"].rsplit(".", 1)[0] + '.'+ format + archivefilename = subtitle["filename"].rsplit(".", 1)[0] + '.'+ format + if subtitles_folder: + archivefilename = subtitles_folder + os.path.basename(archivefilename) self.downloadFile(subtitle["link"], archivefilename) subtitlefilename = None diff --git a/periscope/plugins/SubsWiki.py b/periscope/plugins/SubsWiki.py index 15aab68..cde0f5e 100644 --- a/periscope/plugins/SubsWiki.py +++ b/periscope/plugins/SubsWiki.py @@ -118,12 +118,14 @@ def splitTeam(self, subteams, sep): teams += t.split(sep) return teams - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtbasefilename = videofilename.rsplit(".", 1)[0] + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) srtfilename = srtbasefilename +".srt" self.downloadFile(suburl, srtfilename) return srtfilename diff --git a/periscope/plugins/SubtitleDatabase.py b/periscope/plugins/SubtitleDatabase.py index 63abef6..e1c8e59 100644 --- a/periscope/plugins/SubtitleDatabase.py +++ b/periscope/plugins/SubtitleDatabase.py @@ -61,12 +61,14 @@ def process(self, filepath, langs): log.exception("Error occured") return [] - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtbasefilename = videofilename.rsplit(".", 1)[0] + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) zipfilename = srtbasefilename +".zip" self.downloadFile(suburl, zipfilename) diff --git a/periscope/plugins/SubtitleSource.py b/periscope/plugins/SubtitleSource.py index 127e1bb..9d0ab50 100644 --- a/periscope/plugins/SubtitleSource.py +++ b/periscope/plugins/SubtitleSource.py @@ -122,12 +122,14 @@ def query(self, token, langs=None): return sublinks - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtfilename = videofilename.rsplit(".", 1)[0] + '.srt' + if subtitles_folder: + srtfilename = subtitles_folder + os.path.basename(subtitle["filename"]) self.downloadFile(suburl, srtfilename) return srtfilename diff --git a/periscope/plugins/Subtitulos.py b/periscope/plugins/Subtitulos.py index 20846c4..ea543fa 100644 --- a/periscope/plugins/Subtitulos.py +++ b/periscope/plugins/Subtitulos.py @@ -109,12 +109,14 @@ def splitTeam(self, subteams, sep): teams += t.split(sep) return teams - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtbasefilename = videofilename.rsplit(".", 1)[0] + if subtitles_folder: + srtbasefilename = subtitles_folder + os.path.basename(subtitle["filename"]) srtfilename = srtbasefilename +".srt" self.downloadFile(suburl, srtfilename) return srtfilename diff --git a/periscope/plugins/TheSubDB.py b/periscope/plugins/TheSubDB.py index 1caa847..1bc60db 100644 --- a/periscope/plugins/TheSubDB.py +++ b/periscope/plugins/TheSubDB.py @@ -92,12 +92,14 @@ def get_hash(self, name): data += f.read(readsize) return hashlib.md5(data).hexdigest() - def createFile(self, subtitle): + def createFile(self, subtitle,subtitles_folder): '''pass the URL of the sub and the file it matches, will unzip it and return the path to the created file''' suburl = subtitle["link"] videofilename = subtitle["filename"] srtfilename = videofilename.rsplit(".", 1)[0] + '.srt' + if subtitles_folder: + srtfilename = subtitles_folder + os.path.basename(subtitle["filename"]) self.downloadFile(suburl, srtfilename) return srtfilename From 97f540f469720e5811f9af42ef0d912de057d0cb Mon Sep 17 00:00:00 2001 From: birt Date: Tue, 31 Dec 2013 07:11:39 +0100 Subject: [PATCH 6/6] added check to see if subtitles exist when in separate folder --- bin/periscope | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/periscope b/bin/periscope index 75c5ee5..8ac9d88 100755 --- a/bin/periscope +++ b/bin/periscope @@ -150,7 +150,8 @@ def recursive_search(entry, options): if mimetype in SUPPORTED_FORMATS: # Add it to the list only if there is not already one (or forced) basepath = os.path.splitext(entry)[0] - if options.force_download or not (os.path.exists(basepath+'.srt') or os.path.exists(basepath + '.sub')): +# print "****************" + options.subtitles_folder + '/' + os.path.basename(entry) + '.srt' + if options.force_download or not (os.path.exists(basepath+'.srt') or os.path.exists(basepath + '.sub') or os.path.exists(options.subtitles_folder + '/' + os.path.basename(entry) + '.srt' )): files.append(os.path.normpath(entry)) else: log.info("Skipping file %s as it already has a subtitle. Use the --force option to force the download" % entry)