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

[metadata.tvshows.themoviedb.org.python] v.1.7.0 #545

Merged
merged 1 commit into from
Nov 6, 2024
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
8 changes: 3 additions & 5 deletions metadata.tvshows.themoviedb.org.python/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="metadata.tvshows.themoviedb.org.python"
name="TMDb TV Shows"
version="1.6.6"
version="1.7.0"
provider-name="Team Kodi">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand All @@ -10,10 +10,8 @@
<extension point="xbmc.metadata.scraper.tvshows" library="main.py" cachepersistence="00:15"/>
<extension point="xbmc.addon.metadata">
<reuselanguageinvoker>true</reuselanguageinvoker>
<news>1.6.6
option to get images in different language than descriptions
support for tv show IDs in TV show folder name
updated YouTube addon URL
<news>1.7.0
change method for getting source settings
</news>
<platform>all</platform>
<license>GPL-3.0-or-later</license>
Expand Down
4 changes: 4 additions & 0 deletions metadata.tvshows.themoviedb.org.python/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.7.0
change method for getting source settings to account for different sources
in one run having different settings

1.6.6
option to get images in different language than descriptions
support for tv show IDs in TV show folder name
Expand Down
26 changes: 14 additions & 12 deletions metadata.tvshows.themoviedb.org.python/libs/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@
except ImportError:
pass


SOURCE_SETTINGS = settings.getSourceSettings()
TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR,
'language': settings.LANG_DETAILS}
'language': SOURCE_SETTINGS["LANG_DETAILS"]}
BASE_URL = 'https://api.themoviedb.org/3/{}'
FIND_URL = BASE_URL.format('find/{}')
TAG_RE = re.compile(r'<[^>]+>')
Expand Down Expand Up @@ -144,7 +146,7 @@ def _set_rating(the_info, vtag):
# type: (InfoType, ListItem) -> None
"""Set show/episode rating"""
first = True
for rating_type in settings.RATING_TYPES:
for rating_type in SOURCE_SETTINGS["RATING_TYPES"]:
logger.debug('adding rating type of %s' % rating_type)
rating = float(the_info.get('ratings', {}).get(
rating_type, {}).get('rating', '0'))
Expand Down Expand Up @@ -211,7 +213,7 @@ def set_show_artwork(show_info, list_item):
fanart_list = []
for image in image_list:
theurl, previewurl = get_image_urls(image)
if image.get('iso_639_1') != None and settings.CATLANDSCAPE and theurl:
if image.get('iso_639_1') != None and SOURCE_SETTINGS["CATLANDSCAPE"] and theurl:
vtag.addAvailableArtwork(
theurl, arttype="landscape", preview=previewurl)
elif theurl:
Expand All @@ -238,7 +240,7 @@ def add_main_show_info(list_item, show_info, full_info=True):
"""Add main show info to a list item"""
vtag = list_item.getVideoInfoTag()
original_name = show_info.get('original_name')
if settings.KEEPTITLE and original_name:
if SOURCE_SETTINGS["KEEPTITLE"] and original_name:
showname = original_name
else:
showname = show_info['name']
Expand All @@ -259,7 +261,7 @@ def add_main_show_info(list_item, show_info, full_info=True):
if full_info:
vtag.setTvShowStatus(safe_get(show_info, 'status', ''))
vtag.setGenres(_get_names(show_info.get('genres', [])))
if settings.SAVETAGS:
if SOURCE_SETTINGS["SAVETAGS"]:
vtag.setTags(_get_names(show_info.get(
'keywords', {}).get('results', [])))
networks = show_info.get('networks', [])
Expand All @@ -269,7 +271,7 @@ def add_main_show_info(list_item, show_info, full_info=True):
else:
network = None
country = None
if network and country and settings.STUDIOCOUNTRY:
if network and country and SOURCE_SETTINGS["STUDIOCOUNTRY"]:
vtag.setStudios(['{0} ({1})'.format(network['name'], country)])
elif network:
vtag.setStudios([network['name']])
Expand All @@ -284,14 +286,14 @@ def add_main_show_info(list_item, show_info, full_info=True):
iso = content_rating.get('iso_3166_1', '').lower()
if iso == 'us':
mpaa_backup = content_rating.get('rating')
if iso == settings.CERT_COUNTRY.lower():
if iso == SOURCE_SETTINGS["CERT_COUNTRY"].lower():
mpaa = content_rating.get('rating', '')
if not mpaa:
mpaa = mpaa_backup
if mpaa:
vtag.setMpaa(settings.CERT_PREFIX + mpaa)
vtag.setMpaa(SOURCE_SETTINGS["CERT_PREFIX"] + mpaa)
vtag.setWriters(_get_credits(show_info))
if settings.ENABTRAILER:
if SOURCE_SETTINGS["ENABTRAILER"]:
trailer = _parse_trailer(show_info.get(
'videos', {}).get('results', {}))
if trailer:
Expand Down Expand Up @@ -427,12 +429,12 @@ def _parse_trailer(results):
# type: (Text) -> Text
"""create a valid Tubed or YouTube plugin trailer URL"""
if results:
if settings.PLAYERSOPT == 'tubed':
if SOURCE_SETTINGS["PLAYERSOPT"] == 'tubed':
addon_player = 'plugin://plugin.video.tubed/?mode=play&video_id='
elif settings.PLAYERSOPT == 'youtube':
elif SOURCE_SETTINGS["PLAYERSOPT"] == 'youtube':
addon_player = 'plugin://plugin.video.youtube/play/?video_id='
backup_keys = []
for video_lang in [settings.LANG_DETAILS[0:2], 'en']:
for video_lang in [SOURCE_SETTINGS["LANG_DETAILS"][0:2], 'en']:
for result in results:
if result.get('site') == 'YouTube' and result.get('iso_639_1') == video_lang:
key = result.get('key')
Expand Down
3 changes: 2 additions & 1 deletion metadata.tvshows.themoviedb.org.python/libs/imdbratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ def get_details(imdb_id):
def _get_ratinginfo(imdb_id):
# type: (Text) -> Tuple[Text, Text]
"""get the IMDB ratings details"""
source_settings = settings.getSourceSettings()
response = api_utils.load_info(IMDB_RATINGS_URL.format(
imdb_id), default='', resp_type='text', verboselog=settings.VERBOSELOG)
imdb_id), default='', resp_type='text', verboselog=source_settings["VERBOSELOG"])
return _parse_imdb_result(response)


Expand Down
100 changes: 53 additions & 47 deletions metadata.tvshows.themoviedb.org.python/libs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,60 @@ def _load_base_urls():
return image_root_url, preview_root_url


def getSourceSettings():
settings = {}
logger.debug('Got settings of: {}'.format(sys.argv[2]))
try:
source_params = dict(urllib.parse.parse_qsl(sys.argv[2]))
except IndexError:
source_params = {}
source_settings = json.loads(source_params.get('pathSettings', '{}'))
settings["KEEPTITLE"] = source_settings.get(
'keeporiginaltitle', ADDON.getSettingBool('keeporiginaltitle'))
settings["CATLANDSCAPE"] = source_settings.get('cat_landscape', True)
settings["STUDIOCOUNTRY"] = source_settings.get('studio_country', False)
settings["ENABTRAILER"] = source_settings.get(
'enab_trailer', ADDON.getSettingBool('enab_trailer'))
settings["PLAYERSOPT"] = source_settings.get(
'players_opt', ADDON.getSettingString('players_opt')).lower()
settings["VERBOSELOG"] = source_settings.get(
'verboselog', ADDON.getSettingBool('verboselog'))
settings["CERT_COUNTRY"] = source_settings.get(
'tmdbcertcountry', ADDON.getSettingString('tmdbcertcountry')).lower()
settings["SAVETAGS"] = source_settings.get(
'keywordsastags', ADDON.getSettingBool('keywordsastags'))
settings["LANG_DETAILS"] = source_settings.get(
'languageDetails', ADDON.getSettingString('languageDetails'))
if source_settings.get('usedifferentlangforimages', ADDON.getSettingBool('usedifferentlangforimages')):
settings["LANG_IMAGES"] = source_settings.get(
'languageImages', ADDON.getSettingString('languageImages'))
else:
settings["LANG_IMAGES"] = settings["LANG_DETAILS"]
if source_settings.get('usecertprefix', ADDON.getSettingBool('usecertprefix')):
settings["CERT_PREFIX"] = source_settings.get(
'certprefix', ADDON.getSettingString('certprefix'))
else:
settings["CERT_PREFIX"] = ''
primary_rating = source_settings.get(
'ratings', ADDON.getSettingString('ratings')).lower()
RATING_TYPES = [primary_rating]
if source_settings.get('imdbanyway', ADDON.getSettingBool('imdbanyway')) and primary_rating != 'imdb':
RATING_TYPES.append('imdb')
if source_settings.get('traktanyway', ADDON.getSettingBool('traktanyway')) and primary_rating != 'trakt':
RATING_TYPES.append('trakt')
if source_settings.get('tmdbanyway', ADDON.getSettingBool('tmdbanyway')) and primary_rating != 'tmdb':
RATING_TYPES.append('tmdb')
settings["RATING_TYPES"] = RATING_TYPES
settings["FANARTTV_ENABLE"] = source_settings.get(
'enable_fanarttv', ADDON.getSettingBool('enable_fanarttv'))
settings["FANARTTV_CLIENTKEY"] = source_settings.get(
'fanarttv_clientkey', ADDON.getSettingString('fanarttv_clientkey'))
logger.debug('Sending back settings of: {}'.format(settings))
return settings


ADDON = Addon()
IMAGEROOTURL, PREVIEWROOTURL = _load_base_urls()
TMDB_CLOWNCAR = 'af3a53eb387d57fc935e9128468b1899'
FANARTTV_CLOWNCAR = 'b018086af0e1478479adfc55634db97d'
TRAKT_CLOWNCAR = '90901c6be3b2de5a4fa0edf9ab5c75e9a5a0fef2b4ee7373d8b63dcf61f95697'
Expand All @@ -69,50 +122,3 @@ def _load_base_urls():
'seasonbanner': 'seasonbanner',
'seasonthumb': 'seasonlandscape'
}

try:
source_params = dict(urllib.parse.parse_qsl(sys.argv[2]))
except IndexError:
source_params = {}
source_settings = json.loads(source_params.get('pathSettings', '{}'))

KEEPTITLE = source_settings.get(
'keeporiginaltitle', ADDON.getSettingBool('keeporiginaltitle'))
CATLANDSCAPE = source_settings.get('cat_landscape', True)
STUDIOCOUNTRY = source_settings.get('studio_country', False)
ENABTRAILER = source_settings.get(
'enab_trailer', ADDON.getSettingBool('enab_trailer'))
PLAYERSOPT = source_settings.get(
'players_opt', ADDON.getSettingString('players_opt')).lower()
VERBOSELOG = source_settings.get(
'verboselog', ADDON.getSettingBool('verboselog'))
CERT_COUNTRY = source_settings.get(
'tmdbcertcountry', ADDON.getSettingString('tmdbcertcountry')).lower()
SAVETAGS = source_settings.get(
'keywordsastags', ADDON.getSettingBool('keywordsastags'))
IMAGEROOTURL, PREVIEWROOTURL = _load_base_urls()

LANG_DETAILS = source_settings.get('languageDetails', ADDON.getSettingString('languageDetails'))
if source_settings.get('usedifferentlangforimages', ADDON.getSettingBool('usedifferentlangforimages')):
LANG_IMAGES = source_settings.get('languageImages', ADDON.getSettingString('languageImages'))
else:
LANG_IMAGES = LANG_DETAILS

if source_settings.get('usecertprefix', ADDON.getSettingBool('usecertprefix')):
CERT_PREFIX = source_settings.get(
'certprefix', ADDON.getSettingString('certprefix'))
else:
CERT_PREFIX = ''
primary_rating = source_settings.get(
'ratings', ADDON.getSettingString('ratings')).lower()
RATING_TYPES = [primary_rating]
if source_settings.get('imdbanyway', ADDON.getSettingBool('imdbanyway')) and primary_rating != 'imdb':
RATING_TYPES.append('imdb')
if source_settings.get('traktanyway', ADDON.getSettingBool('traktanyway')) and primary_rating != 'trakt':
RATING_TYPES.append('trakt')
if source_settings.get('tmdbanyway', ADDON.getSettingBool('tmdbanyway')) and primary_rating != 'tmdb':
RATING_TYPES.append('tmdb')
FANARTTV_ENABLE = source_settings.get(
'enable_fanarttv', ADDON.getSettingBool('enable_fanarttv'))
FANARTTV_CLIENTKEY = source_settings.get(
'fanarttv_clientkey', ADDON.getSettingString('fanarttv_clientkey'))
Loading
Loading