39
39
root_url = 'https://www.opensubtitles.org/en/search/sublanguageid-ara/uploader-morafbi/idmovie-'
40
40
main_url = "https://www.opensubtitles.org"
41
41
main_download_url = 'https://www.opensubtitles.org/en/subtitleserve/sub/'
42
-
43
- s = requests .Session ()
42
+
43
+ s = requests .Session ()
44
44
debug_pretext = ""
45
45
ses = requests .Session ()
46
46
73
73
# log(__name__, " Failed to get url:%s" % (url))
74
74
# content = None
75
75
# return(content)
76
-
76
+
77
77
78
78
def getSearchTitle (title , year = None ): # new Add
79
79
title = prepare_search_string (title ).replace ('%26' , '&' )
@@ -94,7 +94,7 @@ def getSearchTitle(title, year=None): # new Add
94
94
href = root_url + str (movie_id )
95
95
print (("href" , href ))
96
96
return movie_id
97
-
97
+
98
98
except :
99
99
break
100
100
return movie_id
@@ -108,8 +108,8 @@ def find_movie(content, title, year):
108
108
for matches in re .finditer (movie_season_pattern , content , re .IGNORECASE | re .DOTALL ):
109
109
print ((tuple (matches .groups ())))
110
110
found_title = matches .group ('title' )
111
- found_title = html .unescape (found_title )
112
- print (("found_title" , found_title ))
111
+ found_title = html .unescape (found_title )
112
+ print (("found_title" , found_title ))
113
113
log (__name__ , "Found movie on search page: %s (%s)" % (found_title , matches .group ('year' )))
114
114
if found_title .lower ().find (title .lower ()) > - 1 :
115
115
if matches .group ('year' ) == year :
@@ -129,7 +129,7 @@ def find_tv_show_season(content, tvshow, season):
129
129
for matches in re .finditer (movie_season_pattern , content , re .IGNORECASE | re .DOTALL ):
130
130
found_title = matches .group ('title' )
131
131
found_title = html .unescape (found_title )
132
- print (("found_title2" , found_title ))
132
+ print (("found_title2" , found_title ))
133
133
log (__name__ , "Found tv show season on search page: %s" % found_title )
134
134
s = difflib .SequenceMatcher (None , string .lower (found_title + ' ' + matches .group ('year' )), tvshow .lower ())
135
135
all_tvshows .append (matches .groups () + (s .ratio () * int (matches .group ('numsubtitles' )),))
@@ -149,8 +149,8 @@ def find_tv_show_season(content, tvshow, season):
149
149
url_found = all_tvshows [0 ][0 ]
150
150
log (__name__ , "Selecting tv show with highest fuzzy string score: %s (score: %s subtitles: %s)" % (
151
151
all_tvshows [0 ][1 ], all_tvshows [0 ][4 ], all_tvshows [0 ][3 ]))
152
-
153
- return url_found
152
+
153
+ return url_found
154
154
155
155
156
156
def getallsubs (content , allowed_languages , filename = "" , search_string = "" ):
@@ -163,7 +163,7 @@ def getallsubs(content, allowed_languages, filename="", search_string=""):
163
163
soup = soup .find ('form' , method = "post" ).find ('table' , id = "search_results" ).tbody
164
164
blocks1 = soup .findAll ('tr' , class_ = "change even expandable" )
165
165
blocks2 = soup .findAll ('tr' , class_ = "change odd expandable" )
166
- blocks = blocks1 + blocks2
166
+ blocks = blocks1 + blocks2
167
167
i = 0
168
168
subtitles = []
169
169
if len (blocks ) == 0 :
@@ -276,7 +276,7 @@ def getallsubs(content, allowed_languages, filename="", search_string=""):
276
276
def prepare_search_string (s ):
277
277
#s = s.strip()
278
278
s = re .sub (r'\(\d\d\d\d\)$' , '' , s ) # remove year from title
279
-
279
+
280
280
s = quote_plus (s )
281
281
return s
282
282
@@ -376,7 +376,7 @@ def download_subtitles(subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, s
376
376
filmid = 0
377
377
postparams = {'__EVENTTARGET' : 's$lc$bcr$downloadLink' , '__EVENTARGUMENT' : '' , '__VIEWSTATE' : viewstate , '__PREVIOUSPAGE' : previouspage , 'subtitleId' : subtitleid , 'typeId' : typeid , 'filmId' : filmid }
378
378
log (__name__ , "%s Fetching subtitles using url '%s' with referer header '%s' and post parameters '%s'" % (debug_pretext , downloadlink , url , postparams ))
379
- response = requests .get (downloadlink , verify = False , allow_redirects = True )
379
+ response = requests .get (downloadlink , verify = False , allow_redirects = True )
380
380
local_tmp_file = zip_subs
381
381
try :
382
382
log (__name__ , "%s Saving subtitles to '%s'" % (debug_pretext , local_tmp_file ))
@@ -410,4 +410,3 @@ def download_subtitles(subtitles_list, pos, zip_subs, tmp_sub_dir, sub_folder, s
410
410
subs_file = typeid
411
411
log (__name__ , "%s Subtitles saved to '%s'" % (debug_pretext , local_tmp_file ))
412
412
return packed , language , subs_file # standard output
413
-
0 commit comments