From e09d84e09ca9f592c5cb174474f2a406239c79dc Mon Sep 17 00:00:00 2001 From: josdion Date: Sun, 22 Mar 2020 09:58:31 +0200 Subject: [PATCH] add uploader member variable to subtitle class Add uploader member variable to subtitle class and update subssabbz, subsunacs and yavkanet to retrieve the uplader username. --- libs/subliminal_patch/providers/subssabbz.py | 6 +++++- libs/subliminal_patch/providers/subsunacs.py | 20 +++++++++++++------- libs/subliminal_patch/providers/yavkanet.py | 6 +++++- libs/subliminal_patch/subtitle.py | 1 + 4 files changed, 24 insertions(+), 9 deletions(-) diff --git a/libs/subliminal_patch/providers/subssabbz.py b/libs/subliminal_patch/providers/subssabbz.py index 2f9321c12..d5e501edb 100644 --- a/libs/subliminal_patch/providers/subssabbz.py +++ b/libs/subliminal_patch/providers/subssabbz.py @@ -132,7 +132,7 @@ class SubsSabBzProvider(Provider): logger.debug('No subtitles found') return subtitles - soup = BeautifulSoup(response.content, 'html.parser') + soup = BeautifulSoup(response.content, 'lxml') rows = soup.findAll('tr', {'class': 'subs-row'}) # Search on first 20 rows only @@ -142,8 +142,12 @@ class SubsSabBzProvider(Provider): element = a_element_wrapper.find('a') if element: link = element.get('href') + element = row.find('a', href = re.compile(r'.*showuser=.*')) + uploader = element.get_text() if element else None logger.info('Found subtitle link %r', link) subtitles = subtitles + self.download_archive_and_add_subtitle_files(link, language, video) + for s in subtitles: + s.uploader = uploader return subtitles diff --git a/libs/subliminal_patch/providers/subsunacs.py b/libs/subliminal_patch/providers/subsunacs.py index 72e0febc7..99832e19f 100644 --- a/libs/subliminal_patch/providers/subsunacs.py +++ b/libs/subliminal_patch/providers/subsunacs.py @@ -135,16 +135,22 @@ class SubsUnacsProvider(Provider): logger.debug('No subtitles found') return subtitles - soup = BeautifulSoup(response.content, 'html.parser') - rows = soup.findAll('td', {'class': 'tdMovie'}) + soup = BeautifulSoup(response.content, 'lxml') + rows = soup.findAll('tr', onmouseover=True) # Search on first 20 rows only for row in rows[:20]: - element = row.find('a', {'class': 'tooltip'}) - if element: - link = element.get('href') - logger.info('Found subtitle link %r', link) - subtitles = subtitles + self.download_archive_and_add_subtitle_files('https://subsunacs.net' + link, language, video) + a_element_wrapper = row.find('td', {'class': 'tdMovie'}) + if a_element_wrapper: + element = a_element_wrapper.find('a', {'class': 'tooltip'}) + if element: + link = element.get('href') + element = row.find('a', href = re.compile(r'.*/search\.php\?t=1\&memid=.*')) + uploader = element.get_text() if element else None + logger.info('Found subtitle link %r', link) + subtitles = subtitles + self.download_archive_and_add_subtitle_files('https://subsunacs.net' + link, language, video) + for s in subtitles: + s.uploader = uploader return subtitles diff --git a/libs/subliminal_patch/providers/yavkanet.py b/libs/subliminal_patch/providers/yavkanet.py index a74c28038..375d23f5f 100644 --- a/libs/subliminal_patch/providers/yavkanet.py +++ b/libs/subliminal_patch/providers/yavkanet.py @@ -121,7 +121,7 @@ class YavkaNetProvider(Provider): logger.debug('No subtitles found') return subtitles - soup = BeautifulSoup(response.content, 'html.parser') + soup = BeautifulSoup(response.content, 'lxml') rows = soup.findAll('tr', {'class': 'info'}) # Search on first 20 rows only @@ -129,8 +129,12 @@ class YavkaNetProvider(Provider): element = row.find('a', {'class': 'selector'}) if element: link = element.get('href') + element = row.find('a', {'class': 'click'}) + uploader = element.get_text() if element else None logger.info('Found subtitle link %r', link) subtitles = subtitles + self.download_archive_and_add_subtitle_files('http://yavka.net/' + link, language, video) + for s in subtitles: + s.uploader = uploader return subtitles diff --git a/libs/subliminal_patch/subtitle.py b/libs/subliminal_patch/subtitle.py index ad39f031b..ce89e74d3 100644 --- a/libs/subliminal_patch/subtitle.py +++ b/libs/subliminal_patch/subtitle.py @@ -54,6 +54,7 @@ class Subtitle(Subtitle_): is_pack = False asked_for_release_group = None asked_for_episode = None + uploader = None # string - uploader username pack_data = None _guessed_encoding = None