mirror of
https://github.com/morpheus65535/bazarr.git
synced 2025-01-01 04:22:07 +08:00
Fix Addic7ed provider: handle language errors, avoid guessit exception and match version for movies
This commit is contained in:
parent
a88f0a7f19
commit
5d8897f675
1 changed files with 25 additions and 5 deletions
|
@ -8,6 +8,7 @@ import time
|
|||
from random import randint
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
import babelfish
|
||||
from dogpile.cache.api import NO_VALUE
|
||||
from requests import Session
|
||||
from subliminal.cache import region
|
||||
|
@ -39,7 +40,8 @@ class Addic7edSubtitle(_Addic7edSubtitle):
|
|||
download_link, uploader=None):
|
||||
super(Addic7edSubtitle, self).__init__(language, hearing_impaired, page_link, series, season, episode,
|
||||
title, year, version, download_link)
|
||||
self.release_info = version.replace('+', ',') if version else None
|
||||
# Guessit will fail if the input is None
|
||||
self.release_info = version.replace('+', ',') if version else ""
|
||||
self.uploader = uploader
|
||||
|
||||
def get_matches(self, video):
|
||||
|
@ -435,7 +437,12 @@ class Addic7edProvider(_Addic7edProvider):
|
|||
continue
|
||||
|
||||
# read the item
|
||||
language = Language.fromaddic7ed(cells[3].text)
|
||||
try:
|
||||
language = Language.fromaddic7ed(cells[3].text)
|
||||
except babelfish.exceptions.LanguageReverseError as error:
|
||||
logger.debug("Language error: %s, Ignoring subtitle", error)
|
||||
continue
|
||||
|
||||
hearing_impaired = bool(cells[6].text)
|
||||
page_link = self.server_url + cells[2].a['href'][1:]
|
||||
season = int(cells[0].text)
|
||||
|
@ -505,11 +512,24 @@ class Addic7edProvider(_Addic7edProvider):
|
|||
continue
|
||||
|
||||
# read the item
|
||||
language = Language.fromaddic7ed(row2.contents[4].text.strip('\n'))
|
||||
try:
|
||||
language = Language.fromaddic7ed(row2.contents[4].text.strip('\n'))
|
||||
except babelfish.exceptions.LanguageReverseError as error:
|
||||
logger.debug("Language error: %s, Ignoring subtitle", error)
|
||||
continue
|
||||
|
||||
hearing_impaired = bool(row3.contents[1].contents[1].attrs['src'].endswith('hi.jpg'))
|
||||
page_link = self.server_url + 'movie/' + movie_id
|
||||
version_matches = re.search(r'Version\s(.+),.+', str(row1.contents[1].contents[1]))
|
||||
version = version_matches.group(1) if version_matches else None
|
||||
|
||||
# Seems like Addic7ed returns the first word in the language of the user (Version, Versión, etc)
|
||||
# As we can't match a regex, we will just strip the first word
|
||||
try:
|
||||
version = " ".join(str(row1.contents[1].contents[1]).split()[1:])
|
||||
version_matches = re.search(r"(.+),.+", version)
|
||||
version = version_matches.group(1) if version_matches else None
|
||||
except IndexError:
|
||||
version = None
|
||||
|
||||
try:
|
||||
download_link = row2.contents[8].contents[3].attrs['href'][1:]
|
||||
except IndexError:
|
||||
|
|
Loading…
Reference in a new issue