chripede/opensubtitle-downloader — Issue #1: goes over files that already have subs wasting opensubtitles time
Author: mogorman
Created: 2012-02-26 11:18:53+00:00
State: open

I am not a python coder, but checking to see if a subtitle exists before queuing it seems like a nice thing to do.
diff --git a/src/opensubtitles.py b/src/opensubtitles.py
index 3018676..9af9d8c 100644
--- a/src/opensubtitles.py
+++ b/src/opensubtitles.py
@@ -26,15 +26,18 @@ class SubtitleDownload:
for root, _, files in os.walk(movie_path):
for file in files:
if file.lower().endswith(".avi") or file.lower().endswith(".mkv"):
- print("Found: " + file)
- filehash = self.hashFile(os.path.join(root, file))
- filesize = os.path.getsize(os.path.join(root, file))
- self.moviefiles.append({'dir': root,
- 'file': file,
- 'hash': filehash,
- 'size': filesize,
- 'subtitleid': None})
-
+ subs = root + "/" + file[:-4] + ".srt"
+ if not os.path.exists(subs):
+ print("Subs needed: " + file + ":" + root)
+ filehash = self.hashFile(os.path.join(root, file))
+ filesize = os.path.getsize(os.path.join(root, file))
+ self.moviefiles.append({'dir': root,
+ 'file': file,
+ 'hash': filehash,
+ 'size': filesize,
+ 'subtitleid': None})
+# else:
+# print("Already has subs: " + file)
try:
print("Login...")
self.login()
@@ -161,4 +164,4 @@ if __name__ == '__main__':
print("Usage: opensubtitles.py [directory]")
exit(1)
downloader = SubtitleDownload(sys.argv[1])
-
\ No newline at end of file
+