From 881a16350aa325e6c4f04e62d3a4c0ee7b618fe0 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Fri, 7 Feb 2020 15:01:26 +0100 Subject: [PATCH 1/2] subdivx: replacing ParseReponseError by APIThrootled --- libs/subliminal_patch/providers/subdivx.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py index 74b3c4f7b..1fa1335e8 100644 --- a/libs/subliminal_patch/providers/subdivx.py +++ b/libs/subliminal_patch/providers/subdivx.py @@ -15,7 +15,7 @@ from subliminal.exceptions import ServiceUnavailable from subliminal.providers import ParserBeautifulSoup, Provider from subliminal.subtitle import SUBTITLE_EXTENSIONS, Subtitle, fix_line_ending,guess_matches from subliminal.video import Episode, Movie -from subliminal_patch.exceptions import ParseResponseError +from subliminal_patch.exceptions import APIThrottled from six.moves import range logger = logging.getLogger(__name__) @@ -132,7 +132,8 @@ class SubdivxSubtitlesProvider(Provider): try: page_subtitles = self._parse_subtitles_page(response, language) except Exception as e: - raise ParseResponseError('Error parsing subtitles list: ' + str(e)) + logger.error('Error parsing subtitles list: ' + str(e)) + break subtitles += page_subtitles @@ -221,9 +222,9 @@ class SubdivxSubtitlesProvider(Provider): if link_soup['href'].startswith('bajar'): return self.server_url + link_soup['href'] except Exception as e: - raise ParseResponseError('Error parsing download link: ' + str(e)) + raise APIThrottled('Error parsing download link: ' + str(e)) - raise ParseResponseError('Download link not found') + raise APIThrottled('Download link not found') def _get_archive(self, content): # open the archive @@ -235,7 +236,7 @@ class SubdivxSubtitlesProvider(Provider): logger.debug('Identified zip archive') archive = zipfile.ZipFile(archive_stream) else: - raise ParseResponseError('Unsupported compressed format') + raise APIThrottled('Unsupported compressed format') return archive @@ -251,4 +252,4 @@ class SubdivxSubtitlesProvider(Provider): return archive.read(name) - raise ParseResponseError('Can not find the subtitle in the compressed file') + raise APIThrottled('Can not find the subtitle in the compressed file') From e0168b7dba35f6ee8376fe6f7851058d7dc1de43 Mon Sep 17 00:00:00 2001 From: German Gutierrez Date: Fri, 7 Feb 2020 20:20:53 +0100 Subject: [PATCH 2/2] subdivx: retrying download when link is not class 'detalle_link' but 'link1' --- libs/subliminal_patch/providers/subdivx.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libs/subliminal_patch/providers/subdivx.py b/libs/subliminal_patch/providers/subdivx.py index 1fa1335e8..d9339e9ae 100644 --- a/libs/subliminal_patch/providers/subdivx.py +++ b/libs/subliminal_patch/providers/subdivx.py @@ -9,6 +9,7 @@ import zipfile import rarfile from subzero.language import Language from requests import Session +from urllib.parse import urlparse from subliminal import __short_version__ from subliminal.exceptions import ServiceUnavailable @@ -221,6 +222,12 @@ class SubdivxSubtitlesProvider(Provider): for link_soup in links_soup: if link_soup['href'].startswith('bajar'): return self.server_url + link_soup['href'] + links_soup = page_soup.find_all ("a", {'class': 'link1'}) + for link_soup in links_soup: + if "bajar.php" in link_soup['href']: + # not using link_soup['href'] directly because it's http:// + dl_link = urlparse(link_soup['href']) + return self.server_url + dl_link.path + '?' + dl_link.query except Exception as e: raise APIThrottled('Error parsing download link: ' + str(e))