mirror of https://github.com/morpheus65535/bazarr
LegendasDivs: cleaning up debug logging
This commit is contained in:
parent
46b59cdae7
commit
b4b7a3ed2e
|
@ -49,9 +49,6 @@ class LegendasdivxSubtitle(Subtitle):
|
||||||
def get_matches(self, video):
|
def get_matches(self, video):
|
||||||
matches = set()
|
matches = set()
|
||||||
|
|
||||||
logger.info('got %s' % self.videoname)
|
|
||||||
logger.info('got %s' % self.description)
|
|
||||||
logger.info('title %s' % video.title)
|
|
||||||
if self.videoname.lower() in self.description:
|
if self.videoname.lower() in self.description:
|
||||||
matches.update(['title'])
|
matches.update(['title'])
|
||||||
matches.update(['season'])
|
matches.update(['season'])
|
||||||
|
@ -59,33 +56,26 @@ class LegendasdivxSubtitle(Subtitle):
|
||||||
|
|
||||||
# episode
|
# episode
|
||||||
if video.title and video.title.lower() in self.description:
|
if video.title and video.title.lower() in self.description:
|
||||||
logger.info('title matched')
|
|
||||||
matches.update(['title'])
|
matches.update(['title'])
|
||||||
if video.year and '{:04d}'.format(video.year) in self.description:
|
if video.year and '{:04d}'.format(video.year) in self.description:
|
||||||
logger.info('year matched')
|
|
||||||
matches.update(['year'])
|
matches.update(['year'])
|
||||||
|
|
||||||
if isinstance(video, Episode):
|
if isinstance(video, Episode):
|
||||||
# already matched in search query
|
# already matched in search query
|
||||||
if video.season and 's{:02d}'.format(video.season) in self.description:
|
if video.season and 's{:02d}'.format(video.season) in self.description:
|
||||||
logger.info('season matched')
|
|
||||||
matches.update(['season'])
|
matches.update(['season'])
|
||||||
if video.episode and 'e{:02d}'.format(video.episode) in self.description:
|
if video.episode and 'e{:02d}'.format(video.episode) in self.description:
|
||||||
logger.info('episode matched')
|
|
||||||
matches.update(['episode'])
|
matches.update(['episode'])
|
||||||
if video.episode and video.season and video.series:
|
if video.episode and video.season and video.series:
|
||||||
if '{}.s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description:
|
if '{}.s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description:
|
||||||
logger.info('series matched')
|
|
||||||
matches.update(['series'])
|
matches.update(['series'])
|
||||||
matches.update(['season'])
|
matches.update(['season'])
|
||||||
matches.update(['episode'])
|
matches.update(['episode'])
|
||||||
if '{} s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description:
|
if '{} s{:02d}e{:02d}'.format(video.series.lower(),video.season,video.episode) in self.description:
|
||||||
logger.info('series matched')
|
|
||||||
matches.update(['series'])
|
matches.update(['series'])
|
||||||
matches.update(['season'])
|
matches.update(['season'])
|
||||||
matches.update(['episode'])
|
matches.update(['episode'])
|
||||||
|
|
||||||
logger.info('matches: %s' % matches)
|
|
||||||
# release_group
|
# release_group
|
||||||
if video.release_group and video.release_group.lower() in self.description:
|
if video.release_group and video.release_group.lower() in self.description:
|
||||||
matches.update(['release_group'])
|
matches.update(['release_group'])
|
||||||
|
@ -157,7 +147,7 @@ class LegendasdivxProvider(Provider):
|
||||||
self.session.close()
|
self.session.close()
|
||||||
|
|
||||||
def login(self):
|
def login(self):
|
||||||
logger.info('Starting login')
|
logger.info('Logging in')
|
||||||
self.headers['Referer'] = self.site + '/index.php'
|
self.headers['Referer'] = self.site + '/index.php'
|
||||||
self.session.headers.update(self.headers.items())
|
self.session.headers.update(self.headers.items())
|
||||||
res = self.session.get(self.loginpage)
|
res = self.session.get(self.loginpage)
|
||||||
|
@ -167,7 +157,6 @@ class LegendasdivxProvider(Provider):
|
||||||
fields = {}
|
fields = {}
|
||||||
for field in _allinputs:
|
for field in _allinputs:
|
||||||
fields[field.get('name')] = field.get('value')
|
fields[field.get('name')] = field.get('value')
|
||||||
logger.debug('%s: %s' % (field.get('name'), field.get('value')))
|
|
||||||
|
|
||||||
fields['username'] = self.username
|
fields['username'] = self.username
|
||||||
fields['password'] = self.password
|
fields['password'] = self.password
|
||||||
|
@ -204,10 +193,8 @@ class LegendasdivxProvider(Provider):
|
||||||
|
|
||||||
language_ids = '0'
|
language_ids = '0'
|
||||||
if isinstance(language, (tuple, list, set)):
|
if isinstance(language, (tuple, list, set)):
|
||||||
logger.error('language %s' % language)
|
|
||||||
if len(language) == 1:
|
if len(language) == 1:
|
||||||
language_ids = ','.join(sorted(l.opensubtitles for l in language))
|
language_ids = ','.join(sorted(l.opensubtitles for l in language))
|
||||||
logger.error('language_ids %s' % language_ids)
|
|
||||||
if language_ids == 'por':
|
if language_ids == 'por':
|
||||||
language_ids = '&form_cat=28'
|
language_ids = '&form_cat=28'
|
||||||
else:
|
else:
|
||||||
|
@ -230,21 +217,18 @@ class LegendasdivxProvider(Provider):
|
||||||
if "A legenda não foi encontrada" in res.text:
|
if "A legenda não foi encontrada" in res.text:
|
||||||
logger.warning('%s not found', querytext)
|
logger.warning('%s not found', querytext)
|
||||||
return []
|
return []
|
||||||
logger.warning(self.searchurl.format(query=querytext))
|
|
||||||
|
|
||||||
bsoup = ParserBeautifulSoup(res.content, ['html.parser'])
|
bsoup = ParserBeautifulSoup(res.content, ['html.parser'])
|
||||||
_allsubs = bsoup.findAll("div", {"class": "sub_box"})
|
_allsubs = bsoup.findAll("div", {"class": "sub_box"})
|
||||||
subtitles = []
|
subtitles = []
|
||||||
lang = Language.fromopensubtitles("pob")
|
lang = Language.fromopensubtitles("pob")
|
||||||
for _subbox in _allsubs:
|
for _subbox in _allsubs:
|
||||||
logger.info("============================================")
|
|
||||||
hits=0
|
hits=0
|
||||||
for th in _subbox.findAll("th", {"class": "color2"}):
|
for th in _subbox.findAll("th", {"class": "color2"}):
|
||||||
if th.string == 'Hits:':
|
if th.string == 'Hits:':
|
||||||
hits = int(th.parent.find("td").string)
|
hits = int(th.parent.find("td").string)
|
||||||
if th.string == 'Idioma:':
|
if th.string == 'Idioma:':
|
||||||
lang = th.parent.find("td").find ("img").get ('src')
|
lang = th.parent.find("td").find ("img").get ('src')
|
||||||
logger.debug('lang img %s' % lang)
|
|
||||||
if 'brazil' in lang:
|
if 'brazil' in lang:
|
||||||
lang = Language.fromopensubtitles('pob')
|
lang = Language.fromopensubtitles('pob')
|
||||||
else:
|
else:
|
||||||
|
@ -255,15 +239,12 @@ class LegendasdivxProvider(Provider):
|
||||||
download = _subbox.find("a", {"class": "sub_download"})
|
download = _subbox.find("a", {"class": "sub_download"})
|
||||||
try:
|
try:
|
||||||
# sometimes BSoup just doesn't get the link
|
# sometimes BSoup just doesn't get the link
|
||||||
logger.debug(download.get('href'))
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('skipping subbox on %s' % self.searchurl.format(query=querytext))
|
logger.warning('skipping subbox on %s' % self.searchurl.format(query=querytext))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.info(hits)
|
|
||||||
exact_match = False
|
exact_match = False
|
||||||
if video.name.lower() in description.get_text().lower():
|
if video.name.lower() in description.get_text().lower():
|
||||||
logger.info("exact match!")
|
|
||||||
exact_match = True
|
exact_match = True
|
||||||
data = {'link': self.site + '/modules.php' + download.get('href'),
|
data = {'link': self.site + '/modules.php' + download.get('href'),
|
||||||
'exact_match': exact_match,
|
'exact_match': exact_match,
|
||||||
|
@ -311,7 +292,6 @@ class LegendasdivxProvider(Provider):
|
||||||
return archive
|
return archive
|
||||||
|
|
||||||
def _get_subtitle_from_archive(self, archive):
|
def _get_subtitle_from_archive(self, archive):
|
||||||
logger.warning(archive.namelist())
|
|
||||||
for name in archive.namelist():
|
for name in archive.namelist():
|
||||||
# discard hidden files
|
# discard hidden files
|
||||||
if os.path.split(name)[-1].startswith('.'):
|
if os.path.split(name)[-1].startswith('.'):
|
||||||
|
@ -321,7 +301,6 @@ class LegendasdivxProvider(Provider):
|
||||||
if not name.lower().endswith(SUBTITLE_EXTENSIONS):
|
if not name.lower().endswith(SUBTITLE_EXTENSIONS):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
logger.warning(name)
|
|
||||||
return archive.read(name)
|
return archive.read(name)
|
||||||
|
|
||||||
raise ParseResponseError('Can not find the subtitle in the compressed file')
|
raise ParseResponseError('Can not find the subtitle in the compressed file')
|
||||||
|
|
Loading…
Reference in New Issue