Skip to content

Commit

Permalink
Add some artwork preference options - #654
Browse files Browse the repository at this point in the history
  • Loading branch information
jurialmunkey committed Feb 21, 2022
1 parent 40918a3 commit c3d0595
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 27 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.themoviedb.helper"
version="4.6.7"
version="4.6.8"
name="TheMovieDb Helper"
provider-name="jurialmunkey">
<requires>
Expand Down
5 changes: 5 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -2081,6 +2081,11 @@ msgctxt "#32407"
msgid "Get resume points from Trakt (increases load times)"
msgstr ""

#: /resources/settings.xml
msgctxt "#32408"
msgid "Prefer artwork from TMDb first if available"
msgstr ""

msgctxt "#30030"
msgid "Hindi (India)"
msgstr ""
Expand Down
7 changes: 3 additions & 4 deletions resources/lib/api/tmdb/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@
ADDON = xbmcaddon.Addon('plugin.video.themoviedb.helper')
ADDONPATH = ADDON.getAddonInfo('path')
ARTWORK_QUALITY = ADDON.getSettingInt('artwork_quality')
EN_FALLBACK = ADDON.getSettingBool('fanarttv_enfallback')

ARTLANG_FALLBACK = True if ADDON.getSettingBool('fanarttv_enfallback') and not ADDON.getSettingBool('fanarttv_secondpref') else False

API_URL = 'https://api.themoviedb.org/3'
APPEND_TO_RESPONSE = 'credits,images,release_dates,content_ratings,external_ids,movie_credits,tv_credits,keywords,reviews,videos,watch/providers'
Expand All @@ -42,10 +41,10 @@ def __init__(
self.language = language
self.iso_language = language[:2]
self.iso_country = language[-2:]
self.req_language = u'{0}-{1}&include_image_language={0},null{2}'.format(self.iso_language, self.iso_country, ',en' if EN_FALLBACK else '')
self.req_language = u'{0}-{1}&include_image_language={0},null{2}'.format(self.iso_language, self.iso_country, ',en' if ARTLANG_FALLBACK else '')
self.mpaa_prefix = mpaa_prefix
self.append_to_response = APPEND_TO_RESPONSE
self.req_strip += [(self.append_to_response, ''), (self.req_language, self.iso_language)]
self.req_strip += [(self.append_to_response, ''), (self.req_language, f'{self.iso_language}{"_en" if ARTLANG_FALLBACK else ""}')]
self.mapper = ItemMapper(self.language, self.mpaa_prefix)

def get_url_separator(self, separator=None):
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/container/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

ADDON = xbmcaddon.Addon('plugin.video.themoviedb.helper')
PREGAME_PARENT = ['seasons', 'episodes', 'episode_groups', 'trakt_upnext', 'episode_group_seasons']
LOG_TIMER_ITEMS = ['item_api', 'item_tmdb', 'item_ftv', 'item_map', 'item_cache', 'item_set', 'item_get', 'item_non']
LOG_TIMER_ITEMS = ['item_api', 'item_tmdb', 'item_ftv', 'item_map', 'item_cache', 'item_set', 'item_get', 'item_non', 'item_art']


class Container(TMDbLists, BaseDirLists, SearchLists, UserDiscoverLists, TraktLists):
Expand Down
30 changes: 22 additions & 8 deletions resources/lib/items/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from resources.lib.addon.timedate import set_timestamp, get_timestamp
from resources.lib.addon.constants import IMAGEPATH_QUALITY_POSTER, IMAGEPATH_QUALITY_FANART, IMAGEPATH_QUALITY_THUMBS, IMAGEPATH_QUALITY_CLOGOS, IMAGEPATH_ALL, ARTWORK_BLACKLIST
from resources.lib.addon.decorators import TimerList, ParallelThread
from resources.lib.addon.plugin import kodi_log

ADDON = xbmcaddon.Addon('plugin.video.themoviedb.helper')
FTV_SECOND_PREF = ADDON.getSettingBool('fanarttv_secondpref')
ARTWORK_QUALITY = ADDON.getSettingInt('artwork_quality')
ARTWORK_QUALITY_FANART = IMAGEPATH_QUALITY_FANART[ARTWORK_QUALITY]
ARTWORK_QUALITY_THUMBS = IMAGEPATH_QUALITY_THUMBS[ARTWORK_QUALITY]
Expand Down Expand Up @@ -220,10 +220,26 @@ def get_item(self, tmdb_type, tmdb_id, season=None, episode=None, cache_refresh=
return self._cache.set_cache(item, name, cache_days=CACHE_DAYS)
# TODO: Remember to include OMDb too!

def get_item_artwork(self, artwork):
art_dict = artwork.get('tmdb') or {}
art_dict.update(artwork.get('fanarttv') or {})
art_dict.update(artwork.get('manual') or {})
def get_item_artwork(self, artwork, art_dict={}):
def set_artwork(details=None, blacklist=[], whitelist=[]):
if not details:
return
for k, v in details.items():
if not v:
continue
if whitelist and k not in whitelist:
continue
if k in blacklist and art_dict.get(k):
continue
art_dict[k] = v
tmdb_art = artwork.get(ARTWORK_QUALITY) or self.map_artwork(artwork.get('tmdb', {}))
if FTV_SECOND_PREF:
set_artwork(artwork.get('fanarttv'))
set_artwork(tmdb_art)
else:
set_artwork(tmdb_art)
set_artwork(artwork.get('fanarttv'), blacklist=ARTWORK_BLACKLIST[ARTWORK_QUALITY])
set_artwork(artwork.get('manual'))
return art_dict

def get_listitem(self, i):
Expand All @@ -237,7 +253,5 @@ def get_listitem(self, i):
if not item or 'listitem' not in item:
return li
li.set_details(item['listitem'])
li.set_artwork(item['artwork'].get(ARTWORK_QUALITY))
li.set_artwork(item['artwork'].get('fanarttv'), blacklist=ARTWORK_BLACKLIST[ARTWORK_QUALITY])
li.set_artwork(item['artwork'].get('manual'))
li.art = self.get_item_artwork(item['artwork'], {})
return li
12 changes: 0 additions & 12 deletions resources/lib/items/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,6 @@ def set_details(self, details=None, reverse=False):
self.unique_ids = merge_two_dicts(details.get('unique_ids', {}), self.unique_ids, reverse=reverse)
self.cast = self.cast or details.get('cast', [])

def set_artwork(self, details=None, blacklist=[], whitelist=[]):
if not details:
return
for k, v in details.items():
if not v:
continue
if whitelist and k not in whitelist:
continue
if k in blacklist and self.art.get(k):
continue
self.art[k] = v

def _set_params_reroute_skinshortcuts(self):
self.params['widget'] = 'true'
# Reroute sortable lists to display options in skinshortcuts
Expand Down
5 changes: 4 additions & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,13 @@
<setting label="$ADDON[plugin.video.themoviedb.helper 32001]" type="text" id="omdb_apikey" />
<setting label="$ADDON[plugin.video.themoviedb.helper 32030]" type="lsep"/>
<setting label="$ADDON[plugin.video.themoviedb.helper 32019]" type="text" id="fanarttv_clientkey" />
<setting label="$ADDON[plugin.video.themoviedb.helper 32399]" type="bool" id="fanarttv_enfallback" default="true" subsetting="true" />

<setting label="$ADDON[plugin.video.themoviedb.helper 32021]" type="bool" id="fanarttv_lookup" default="false" subsetting="true" />
<setting label="$ADDON[plugin.video.themoviedb.helper 32028]" type="bool" id="widget_fanarttv_lookup" default="false" subsetting="true" />
<setting label="$ADDON[plugin.video.themoviedb.helper 32163]" type="bool" id="service_fanarttv_lookup" default="false" subsetting="true" />

<setting label="$ADDON[plugin.video.themoviedb.helper 32408]" type="bool" id="fanarttv_secondpref" default="false" />
<setting label="$ADDON[plugin.video.themoviedb.helper 32399]" type="bool" id="fanarttv_enfallback" default="true" />
</category>
<category label="$ADDON[plugin.video.themoviedb.helper 32083]">
<setting label="$ADDON[plugin.video.themoviedb.helper 32031]" type="lsep"/>
Expand Down

0 comments on commit c3d0595

Please sign in to comment.