mirror of
https://github.com/SickGear/SickGear.git
synced 2024-11-15 01:15:05 +00:00
fix episode loading bugs in tvdb lib
This commit is contained in:
parent
f0951cd87d
commit
51d10fc245
1 changed files with 14 additions and 9 deletions
|
@ -1103,21 +1103,23 @@ class Tvdb(TVInfoBase):
|
|||
# Parse episode data
|
||||
log.debug('Getting all episodes of %s' % sid)
|
||||
|
||||
page = 1
|
||||
episodes = []
|
||||
page = 0 # type: int
|
||||
episodes = [] # type: list
|
||||
episode_data_found = False # type: bool
|
||||
while page <= 400:
|
||||
episode_data = {}
|
||||
if self.is_apikey():
|
||||
episode_data = self._getetsrc(
|
||||
self.config['url_series_episodes_info'] % (sid, page), language=language)
|
||||
episode_data_found |= 0 == page and bool(episode_data)
|
||||
|
||||
if not episode_data:
|
||||
if not episode_data_found and isinstance(show_data, dict) and 'slug' in show_data:
|
||||
response = {'data': None}
|
||||
items_found = False
|
||||
# fallback to page 'all' if dvd is enabled and response has no items
|
||||
for page_type in ('url_series_dvd', 'url_series_all'):
|
||||
if 'dvd' not in page_type or self.config['dvdorder']:
|
||||
response = self._load_url(self.config[page_type] % show_data.get('data').get('slug'))
|
||||
response = self._load_url(self.config[page_type] % show_data.get('slug'))
|
||||
with BS4Parser(response.get('data') or '') as soup:
|
||||
items_found = bool(soup.find_all(class_='list-group-item'))
|
||||
if items_found:
|
||||
|
@ -1129,7 +1131,7 @@ class Tvdb(TVInfoBase):
|
|||
with BS4Parser(response.get('data')) as soup:
|
||||
items = soup.find_all(class_='list-group-item')
|
||||
rc_sxe = re.compile(r'(?i)s(?:pecial\s*)?(\d+)\s*[xe]\s*(\d+)') # Special nxn or SnnEnn
|
||||
rc_episode = re.compile(r'(?i)/series/%s/episodes?/(?P<ep_id>\d+)' % show_data['data']['slug'])
|
||||
rc_episode = re.compile(r'(?i)/series/%s/episodes?/(?P<ep_id>\d+)' % show_data['slug'])
|
||||
rc_date = re.compile(r'\s\d{4}\s*$')
|
||||
season_type, episode_type = ['%s%s' % (('aired', 'dvd')['dvd' in page_type], x)
|
||||
for x in ('season', 'episodenumber')]
|
||||
|
@ -1165,18 +1167,21 @@ class Tvdb(TVInfoBase):
|
|||
'filename': ep_filename, # 'network': ep_network
|
||||
})
|
||||
|
||||
if not show_data['data']['firstaired'] and ep_aired \
|
||||
if not show_data['firstaired'] and ep_aired \
|
||||
and (1, 1) == (ep_season, ep_episode):
|
||||
show_data['data']['firstaired'] = ep_aired
|
||||
show_data['firstaired'] = ep_aired
|
||||
|
||||
episode_data['fallback'] = True
|
||||
except (BaseException, Exception):
|
||||
continue
|
||||
|
||||
if None is episode_data:
|
||||
if episode_data_found and not episode_data:
|
||||
break
|
||||
|
||||
if None is episode_data and not bool(episodes) and not episode_data_found:
|
||||
raise TvdbError('Exception retrieving episodes for show')
|
||||
if isinstance(episode_data, dict) and not episode_data.get('data', []):
|
||||
if 1 != page:
|
||||
if 0 != page:
|
||||
self.not_found = False
|
||||
break
|
||||
if not getattr(self, 'not_found', False) and None is not episode_data.get('data'):
|
||||
|
|
Loading…
Reference in a new issue