Skip to content

Commit

Permalink
Add support for banners and background images to tvmaze indexer.
Browse files Browse the repository at this point in the history
  • Loading branch information
p0psicles committed Jan 6, 2022
1 parent fe0d720 commit 0b2dcd3
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 93 deletions.
54 changes: 45 additions & 9 deletions medusa/indexers/tvmaze/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,20 +316,56 @@ def _parse_images(self, tvmaze_id):
log.debug('Getting show banners for {0}', tvmaze_id)

try:
image_medium = self.shows[tvmaze_id]['image_medium']
images = self.tvmaze_api.show_images(tvmaze_id)
# image_medium = self.shows[tvmaze_id]['image_medium']
except Exception:
log.debug('Could not parse Poster for showid: {0}', tvmaze_id)
return False

# Set the poster (using the original uploaded poster for now, as the medium formated is 210x195
_images = {u'poster': {u'1014x1500': {u'1': {u'rating': 1,
u'language': u'en',
u'ratingcount': 1,
u'bannerpath': image_medium.split('/')[-1],
u'bannertype': u'poster',
u'bannertype2': u'210x195',
u'_bannerpath': image_medium,
u'id': u'1035106'}}}}
_images = {}
for image in images:
if image.type not in _images:
_images[image.type] = {}

if not image.resolutions:
continue

if image.type == 'poster' and not image.main:
continue

# For banner, poster and fanart use the origin size.
_images[image.type] = {
f"{image.resolutions['original']['width']}x{image.resolutions['original']['height']}": {
image.id: {
'rating': 1,
'language': u'en',
'ratingcount': 1,
'bannerpath': image.resolutions['original']['url'].split('/')[-1],
'bannertype': image.type,
'bannertype2': f"{image.resolutions['original']['width']}x{image.resolutions['original']['height']}",
'_bannerpath': image.resolutions['original']['url'],
'id': image.id
}
}
}

if image.type == 'poster':
# Save the main poster as a poster thumb.
_images['poster_thumb'] = {
f"{image.resolutions['medium']['width']}x{image.resolutions['medium']['height']}": {
image.id: {
'rating': 1,
'language': u'en',
'ratingcount': 1,
'bannerpath': image.resolutions['medium']['url'].split('/')[-1],
'bannertype': 'poster_thumb',
'bannertype2': f"{image.resolutions['medium']['width']}x{image.resolutions['medium']['height']}",
'_bannerpath': image.resolutions['medium']['url'],
'id': image.id
}
}
}

season_images = self._parse_season_images(tvmaze_id)
if season_images:
Expand Down
4 changes: 2 additions & 2 deletions themes/dark/assets/js/medusa-runtime.js

Large diffs are not rendered by default.

Loading

0 comments on commit 0b2dcd3

Please sign in to comment.