Skip to content

Commit

Permalink
Merge pull request #541 from pkscout/tmdb-tvshows-166
Browse files Browse the repository at this point in the history
[metadata.tvshows.themoviedb.org.python]v1.6.6
  • Loading branch information
rmrector authored Apr 23, 2024
2 parents d16d354 + 8171284 commit 73f47a2
Show file tree
Hide file tree
Showing 84 changed files with 1,042 additions and 259 deletions.
12 changes: 7 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.5"
version="1.6.6"
provider-name="Team Kodi">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand All @@ -10,9 +10,10 @@
<extension point="xbmc.metadata.scraper.tvshows" library="main.py" cachepersistence="00:15"/>
<extension point="xbmc.addon.metadata">
<reuselanguageinvoker>true</reuselanguageinvoker>
<news>1.6.5
made search of NFO file for a UniqueID less aggressive
updated language files
<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>
<platform>all</platform>
<license>GPL-3.0-or-later</license>
Expand All @@ -36,14 +37,15 @@ updated language files
<summary lang="hr_HR">Preuzmite metapodatke TV serija s themoviedb.org</summary>
<summary lang="id_ID">Ambil metadata Acara TV dari themoviedb.org</summary>
<summary lang="is_IS">Sækja lýsigögn sjónvarpsþátta frá themoviedb.org</summary>
<summary lang="it_IT">Recupera i metadati dei programmi TV da themovedb.org</summary>
<summary lang="it_IT">Recupera i metadati delle serie TV da themovedb.org</summary>
<summary lang="ko_KR">themoviedb.org에서 TV쇼 메타데이터를 가져옵니다</summary>
<summary lang="lv_LV">Iegūst TV pārraides datus no themoviedb.org vietnes</summary>
<summary lang="my_MM">themoviedb.org မှ TV Show မက်တာဒေတာကို ရယူပါ</summary>
<summary lang="nl_NL">Haal metadata van tv-programma&apos;s op van themoviedb.org</summary>
<summary lang="pl_PL">Pobieraj metadane programów telewizyjnch z themoviedb.org</summary>
<summary lang="pt_BR">Obter metadados de Séries em themoviedb.org</summary>
<summary lang="ru_RU">Получение метаданных о сериалах с сайта themoviedb.org</summary>
<summary lang="sk_SK">Získať metadáta pre seriály z themoviedb.org</summary>
<summary lang="sv_SE">Hämta metadata för TV-serier från themoviedb.org</summary>
<summary lang="tr_TR">TV Programları meta verilerini themoviedb.org sitesinden al</summary>
<summary lang="zh_CN">从 themoviedb.org 获取剧集信息</summary>
Expand Down
7 changes: 6 additions & 1 deletion metadata.tvshows.themoviedb.org.python/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
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

1.6.5
made search of NFO file for a UniqueID less aggressive
made search of NFO file for a UniqueID less agressive
updated language files

1.6.4
Expand Down
22 changes: 21 additions & 1 deletion metadata.tvshows.themoviedb.org.python/libs/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,24 @@ def get_show_id_from_nfo(nfo):
)


def get_show_id(unique_ids):
"""
Get show ID by unique IDs
In case there is a tmdb identifier in the unique IDs, use that.
Else use the find_by_id method to get the show ID by an external ID.
:param unique_ids: dictionary of unique IDs
"""
if unique_ids.get('tmdb'):
return unique_ids['tmdb']
else:
res = tmdb.find_by_id(unique_ids)
if len(res) > 0:
return res[0].get('id')
return None


def get_details(show_id):
# type: (Text) -> None
"""Get details about a specific show"""
Expand Down Expand Up @@ -226,7 +244,9 @@ def router(paramstring):
get_show_id_from_nfo(params['nfo'])
elif params['action'] == 'getdetails':
logger.debug('performing getdetails action')
get_details(params['url'])
show_id = params.get('url') or get_show_id(json.loads(params.get('uniqueIDs')))
if show_id:
get_details(show_id)
elif params['action'] == 'getepisodelist':
logger.debug('performing getepisodelist action')
get_episode_list(params['url'])
Expand Down
7 changes: 4 additions & 3 deletions metadata.tvshows.themoviedb.org.python/libs/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
except ImportError:
pass

TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR, 'language': settings.LANG}
TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR,
'language': 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 @@ -429,9 +430,9 @@ def _parse_trailer(results):
if settings.PLAYERSOPT == 'tubed':
addon_player = 'plugin://plugin.video.tubed/?mode=play&video_id='
elif settings.PLAYERSOPT == 'youtube':
addon_player = 'plugin://plugin.video.youtube/?action=play_video&videoid='
addon_player = 'plugin://plugin.video.youtube/play/?video_id='
backup_keys = []
for video_lang in [settings.LANG[0:2], 'en']:
for video_lang in [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
7 changes: 6 additions & 1 deletion metadata.tvshows.themoviedb.org.python/libs/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,18 @@ def _load_base_urls():
'players_opt', ADDON.getSettingString('players_opt')).lower()
VERBOSELOG = source_settings.get(
'verboselog', ADDON.getSettingBool('verboselog'))
LANG = source_settings.get('language', ADDON.getSettingString('language'))
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'))
Expand Down
40 changes: 29 additions & 11 deletions metadata.tvshows.themoviedb.org.python/libs/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
)
api_utils.set_headers(dict(HEADERS))

TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR, 'language': settings.LANG}
TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR, 'language': settings.LANG_DETAILS}
BASE_URL = 'https://api.themoviedb.org/3/{}'
EPISODE_GROUP_URL = BASE_URL.format('tv/episode_group/{}')
SEARCH_URL = BASE_URL.format('search/tv')
Expand Down Expand Up @@ -93,6 +93,24 @@ def search_show(title, year=None):
return results


def find_by_id(unique_ids):
"""
Find a show by external IDs
:param unique_ids: dict of external IDs
:return: a list with found TV shows
"""
supported_ids = ['imdb', 'facebook', 'instagram', 'tvdb', 'tiktok', 'twitter', 'wikidata', 'youtube']
params = TMDB_PARAMS.copy()
for key, value in unique_ids.items():
if key in supported_ids:
params['external_source'] = key + '_id'
search_url = FIND_URL.format(value)
resp = api_utils.load_info(search_url, params=params, verboselog=settings.VERBOSELOG)
if resp is not None:
return resp.get('tv_results', [])
return []


def load_episode_list(show_info, season_map, ep_grouping):
# type: (InfoType, Dict, Text) -> Optional[InfoType]
"""get the IMDB ratings details"""
Expand Down Expand Up @@ -156,32 +174,32 @@ def load_show_info(show_id, ep_grouping=None, named_seasons=None):
show_url = SHOW_URL.format(show_id)
params = TMDB_PARAMS.copy()
params['append_to_response'] = 'credits,content_ratings,external_ids,images,videos,keywords'
params['include_image_language'] = '%s,en,null' % settings.LANG[0:2]
params['include_video_language'] = '%s,en,null' % settings.LANG[0:2]
params['include_image_language'] = '%s,en,null' % settings.LANG_IMAGES[0:2]
params['include_video_language'] = '%s,en,null' % settings.LANG_DETAILS[0:2]
show_info = api_utils.load_info(
show_url, params=params, verboselog=settings.VERBOSELOG)
if show_info is None:
return None
if show_info['overview'] == '' and settings.LANG != 'en-US':
if show_info['overview'] == '' and settings.LANG_DETAILS != 'en-US':
params['language'] = 'en-US'
del params['append_to_response']
show_info_backup = api_utils.load_info(
show_url, params=params, verboselog=settings.VERBOSELOG)
if show_info_backup is not None:
show_info['overview'] = show_info_backup.get('overview', '')
params['language'] = settings.LANG
params['language'] = settings.LANG_DETAILS
season_map = {}
params['append_to_response'] = 'credits,images'
for season in show_info.get('seasons', []):
season_url = SEASON_URL.format(
show_id, season.get('season_number', 0))
season_info = api_utils.load_info(
season_url, params=params, default={}, verboselog=settings.VERBOSELOG)
if (season_info.get('overview', '') == '' or season_info.get('name', '').lower().startswith('season')) and settings.LANG != 'en-US':
if (season_info.get('overview', '') == '' or season_info.get('name', '').lower().startswith('season')) and settings.LANG_DETAILS != 'en-US':
params['language'] = 'en-US'
season_info_backup = api_utils.load_info(
season_url, params=params, default={}, verboselog=settings.VERBOSELOG)
params['language'] = settings.LANG
params['language'] = settings.LANG_DETAILS
if season_info.get('overview', '') == '':
season_info['overview'] = season_info_backup.get(
'overview', '')
Expand Down Expand Up @@ -240,7 +258,7 @@ def load_episode_info(show_id, episode_id):
show_info['id'], episode_info['org_seasonnum'], episode_info['org_epnum'])
params = TMDB_PARAMS.copy()
params['append_to_response'] = 'credits,external_ids,images'
params['include_image_language'] = '%s,en,null' % settings.LANG[0:2]
params['include_image_language'] = '%s,en,null' % settings.LANG_IMAGES[0:2]
ep_return = api_utils.load_info(
ep_url, params=params, verboselog=settings.VERBOSELOG)
if ep_return is None:
Expand All @@ -256,7 +274,7 @@ def load_episode_info(show_id, episode_id):
bad_return_name = True
if ep_return.get('overview', '') == '':
bad_return_overview = True
if (bad_return_overview or bad_return_name) and settings.LANG != 'en-US':
if (bad_return_overview or bad_return_name) and settings.LANG_DETAILS != 'en-US':
params['language'] = 'en-US'
del params['append_to_response']
ep_return_backup = api_utils.load_info(
Expand Down Expand Up @@ -344,7 +362,7 @@ def load_fanarttv_art(show_info):
if lang == '' or lang == '00':
lang = None
filepath = ''
if lang is None or lang == settings.LANG[0:2] or lang == 'en':
if lang is None or lang == settings.LANG_DETAILS[0:2] or lang == 'en':
filepath = item.get('url')
if filepath:
if tmdb_type.startswith('season'):
Expand Down Expand Up @@ -450,7 +468,7 @@ def _image_sort(images, image_type):
firstimage = True
for image in images:
image_lang = image.get('iso_639_1')
if image_lang == settings.LANG[0:2]:
if image_lang == settings.LANG_DETAILS[0:2]:
lang_pref.append(image)
elif image_lang == 'en':
lang_en.append(image)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30006 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ msgstr ""
"Project-Id-Version: XBMC Addons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"PO-Revision-Date: 2023-06-30 21:42+0000\n"
"Last-Translator: Christian Gade <[email protected]>\n"
"Language-Team: Azerbaijani <https://kodi.weblate.cloud/projects/kodi-add-ons-information-providers/metadata-tvshows-themoviedb-org-python/az_az/>\n"
"Language: az_az\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.18\n"

msgctxt "Addon Summary"
msgid "Fetch TV Show metadata from themoviedb.org"
Expand Down Expand Up @@ -56,10 +57,18 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
msgstr ""
msgstr "Fanart.tv"

msgctxt "#30101"
msgid "Client key (optional)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
msgid ""
msgstr ""
"Project-Id-Version: XBMC Addons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: 2023-02-19 14:01+0000\n"
"Last-Translator: Christian Gade <[email protected]>\n"
Expand Down Expand Up @@ -57,6 +57,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr "Выкарыстоўваць ключавыя словы як пазнакі"

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ msgctxt "#30007"
msgid "Add keywords as tags"
msgstr ""

msgctxt "#30008"
msgid "Preferred language (Images)"
msgstr ""

msgctxt "#30009"
msgid "Use different language for images"
msgstr ""

# empty strings from 30007 to 30099
msgctxt "#30100"
msgid "Fanart.tv"
Expand Down
Loading

0 comments on commit 73f47a2

Please sign in to comment.