Skip to content

Commit

Permalink
Feature/fix create cache from meta (#5810)
Browse files Browse the repository at this point in the history
* Fix bug where we always check poster path, for every image type.

* Update changelog.

* some styling
  • Loading branch information
p0psicles authored Dec 1, 2018
1 parent f4a2be5 commit 3c3fe6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#### Fixes
- Fixed double absolute numbers for anime shows where thexem sets an absolute which already exists ([#5801](https://github.com/pymedusa/Medusa/pull/5801))
- Fixed image cache not properly created from metadata for images other then posters ([#5810](https://github.com/pymedusa/Medusa/pull/5810))

-----

Expand Down
4 changes: 2 additions & 2 deletions medusa/image_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ def fill_cache(series_obj):
log.debug('Checking {provider.name} metadata for {img}',
{'provider': provider, 'img': IMAGE_TYPES[img_type]})

if os.path.isfile(provider.get_poster_path(series_obj)):
path = provider.get_poster_path(series_obj)
path = provider.get_image_path(series_obj, img_type)
if os.path.isfile(path):
filename = os.path.abspath(path)
file_type = which_type(filename)

Expand Down
16 changes: 16 additions & 0 deletions medusa/metadata/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@
log = BraceAdapter(logging.getLogger(__name__))
log.logger.addHandler(logging.NullHandler())

BANNER = 1
POSTER = 2
BANNER_THUMB = 3
POSTER_THUMB = 4
FANART = 5


class GenericMetadata(object):
"""
Expand Down Expand Up @@ -173,6 +179,16 @@ def get_poster_path(self, show_obj):
def get_banner_path(self, show_obj):
return os.path.join(show_obj.location, self.banner_name)

def get_image_path(self, show_obj, image_type):
"""Based on the image_type (banner, poster, fanart) call the correct method, and return the path."""
banner_path = {
BANNER: self.get_banner_path,
POSTER: self.get_poster_path,
FANART: self.get_fanart_path
}
if banner_path.get(image_type):
return banner_path[image_type](show_obj)

@staticmethod
def get_episode_thumb_path(ep_obj):
"""
Expand Down

0 comments on commit 3c3fe6b

Please sign in to comment.