Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix season pack downloads occurring even if not needed #7472

Merged
merged 4 commits into from
Dec 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#### Improvements

#### Fixes
- Fixed season pack downloads occurring even if not needed ([#7472](https://github.com/pymedusa/Medusa/pull/7472))

-----

Expand All @@ -16,7 +17,6 @@
- Improve a number of anime release names parsed by guessit ([#7418](https://github.com/pymedusa/Medusa/pull/7418)) ([#7396](https://github.com/pymedusa/Medusa/pull/7396)) ([#7427](https://github.com/pymedusa/Medusa/pull/7427))

#### Fixes

- Show Header: Fix showing correct amount of stars for the IMDB rating ([#7401](https://github.com/pymedusa/Medusa/pull/7401))
- Re-implement tvdb season poster/banners (was disabled because of tvdb api issues) ([#7460](https://github.com/pymedusa/Medusa/pull/7460))
- Fix showing the data directory in the bottom of some config pages ([#7424](https://github.com/pymedusa/Medusa/pull/7424))
Expand Down
12 changes: 6 additions & 6 deletions medusa/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,14 @@ def _create_episode_objects(self):
if self.actual_season is not None and self.series:
if self.actual_episodes:
self.episodes = [self.series.get_episode(self.actual_season, ep) for ep in self.actual_episodes]
if len(self.actual_episodes) == 1:
self.episode_number = self.actual_episodes[0]
else:
self.episode_number = MULTI_EP_RESULT
else:
self.episodes = self.series.get_all_episodes(self.actual_season)
self.actual_episodes = [ep.episode for ep in self.episodes]
self.episode_number = SEASON_RESULT

return self.episodes

Expand All @@ -245,12 +251,6 @@ def _episodes_from_cache(self):
# Season result
if not sql_episodes:
ep_objs = series_obj.get_all_episodes(actual_season)
if not ep_objs:
# We couldn't get any episodes for this season, which is odd, skip the result.
log.debug("We couldn't get any episodes for season {0} of {1}, skipping",
actual_season, cached_data['name'])
return

self.actual_episodes = [ep.episode for ep in ep_objs]
self.episode_number = SEASON_RESULT

Expand Down
17 changes: 7 additions & 10 deletions medusa/providers/generic_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,23 +424,20 @@ def find_search_results(self, series, episodes, search_mode, forced_search=False

search_result.update_search_result()

if not search_result.actual_episodes:
episode_number = SEASON_RESULT
if search_result.episode_number == SEASON_RESULT:
log.debug('Found season pack result {0} at {1}', search_result.name, search_result.url)
elif len(search_result.actual_episodes) == 1:
episode_number = search_result.actual_episode
log.debug('Found single episode result {0} at {1}', search_result.name, search_result.url)
else:
episode_number = MULTI_EP_RESULT
elif search_result.episode_number == MULTI_EP_RESULT:
log.debug('Found multi-episode ({0}) result {1} at {2}',
', '.join(map(str, search_result.parsed_result.episode_numbers)),
search_result.name,
search_result.url)
else:
log.debug('Found single episode result {0} at {1}', search_result.name, search_result.url)

if episode_number not in final_results:
final_results[episode_number] = [search_result]
if search_result.episode_number not in final_results:
final_results[search_result.episode_number] = [search_result]
else:
final_results[episode_number].append(search_result)
final_results[search_result.episode_number].append(search_result)

if cl:
# Access to a protected member of a client class
Expand Down
9 changes: 4 additions & 5 deletions medusa/tv/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,11 +609,10 @@ def find_episodes(self, episodes):
continue

search_result = self.provider.get_result(series=series_obj, cache=cur_result)
if search_result.episode_number is not None:
if search_result in cache_results[search_result.episode_number]:
continue
# add it to the list
cache_results[search_result.episode_number].append(search_result)
if search_result in cache_results[search_result.episode_number]:
continue
# add it to the list
cache_results[search_result.episode_number].append(search_result)

# datetime stamp this search so cache gets cleared
self.searched = time()
Expand Down