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] v1.7.2 #548

Merged
merged 1 commit into from
Dec 11, 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
7 changes: 3 additions & 4 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.7.1"
version="1.7.2"
provider-name="Team Kodi">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
Expand All @@ -10,9 +10,8 @@
<extension point="xbmc.metadata.scraper.tvshows" library="main.py" cachepersistence="00:15"/>
<extension point="xbmc.addon.metadata">
<reuselanguageinvoker>true</reuselanguageinvoker>
<news>1.7.1
fix for crash when getting config from TMDb website
fix for TMDb config never getting updated from website without restart
<news>1.7.2
fix for inability to scrape IMDB ratings
</news>
<platform>all</platform>
<license>GPL-3.0-or-later</license>
Expand Down
3 changes: 3 additions & 0 deletions metadata.tvshows.themoviedb.org.python/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.7.2
fix for inability to scrape IMDB ratings

1.7.1
fix for crash when getting config from TMDb website
fix for TMDb config never getting updated from website without restart
Expand Down
2 changes: 2 additions & 0 deletions metadata.tvshows.themoviedb.org.python/libs/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def load_info(url, params=None, default=None, resp_type='json', verboselog=False
if params:
url = url + '?' + urlencode(params)
logger.debug('Calling URL "{}"'.format(url))
if HEADERS:
logger.debug(str(HEADERS))
req = Request(url, headers=HEADERS)
try:
response = urlopen(req)
Expand Down
7 changes: 7 additions & 0 deletions metadata.tvshows.themoviedb.org.python/libs/imdbratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
IMDB_JSON_REGEX = re.compile(
r'<script type="application\/ld\+json">(.*?)<\/script>')

HEADERS = (
('User-Agent', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'),
('Accept', 'application/json'),
)


def get_details(imdb_id):
# type: (Text) -> Dict
Expand All @@ -46,8 +51,10 @@ def _get_ratinginfo(imdb_id):
# type: (Text) -> Tuple[Text, Text]
"""get the IMDB ratings details"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
response = api_utils.load_info(IMDB_RATINGS_URL.format(
imdb_id), default='', resp_type='text', verboselog=source_settings["VERBOSELOG"])
api_utils.set_headers({})
return _parse_imdb_result(response)


Expand Down
15 changes: 14 additions & 1 deletion metadata.tvshows.themoviedb.org.python/libs/tmdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
('User-Agent', 'Kodi TV Show scraper by Team Kodi; contact [email protected]'),
('Accept', 'application/json'),
)
api_utils.set_headers(dict(HEADERS))

TMDB_PARAMS = {'api_key': settings.TMDB_CLOWNCAR}
BASE_URL = 'https://api.themoviedb.org/3/{}'
Expand Down Expand Up @@ -66,6 +65,7 @@ def search_show(title, year=None):
:return: a list with found TV shows
"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
params = _get_params()
results = []
ext_media_id = data_utils.parse_media_id(title)
Expand Down Expand Up @@ -96,6 +96,7 @@ def search_show(title, year=None):
results = resp.get('tv_results', [])
else:
results = resp.get('results', [])
api_utils.set_headers({})
return results


Expand All @@ -108,6 +109,7 @@ def find_by_id(unique_ids):
supported_ids = ['imdb', 'facebook', 'instagram',
'tvdb', 'tiktok', 'twitter', 'wikidata', 'youtube']
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
params = _get_params()
for key, value in unique_ids.items():
if key in supported_ids:
Expand All @@ -117,6 +119,7 @@ def find_by_id(unique_ids):
search_url, params=params, verboselog=source_settings["VERBOSELOG"])
if resp is not None:
return resp.get('tv_results', [])
api_utils.set_headers()
return []


Expand All @@ -125,6 +128,7 @@ def load_episode_list(show_info, season_map, ep_grouping):
"""get the IMDB ratings details"""
"""Load episode list from themoviedb.org API"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
episode_list = []
if ep_grouping is not None:
logger.debug(
Expand Down Expand Up @@ -163,6 +167,7 @@ def load_episode_list(show_info, season_map, ep_grouping):
episode['org_epnum'] = episode['episode_number']
episode_list.append(episode)
show_info['episodes'] = episode_list
api_utils.set_headers({})
return show_info


Expand All @@ -176,6 +181,8 @@ def load_show_info(show_id, ep_grouping=None, named_seasons=None):
:param named_seasons: the named seasons from the NFO file
:return: show info or None
"""

api_utils.set_headers(dict(HEADERS))
source_settings = settings.getSourceSettings()
if named_seasons == None:
named_seasons = []
Expand Down Expand Up @@ -245,6 +252,7 @@ def load_show_info(show_id, ep_grouping=None, named_seasons=None):
cache.cache_show_info(show_info)
else:
logger.debug('using cached show info')
api_utils.set_headers({})
return show_info


Expand All @@ -258,6 +266,7 @@ def load_episode_info(show_id, episode_id):
:return: episode info or None
"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
show_info = load_show_info(show_id)
if show_info is not None:
try:
Expand Down Expand Up @@ -311,7 +320,9 @@ def load_episode_info(show_id, episode_id):
break
show_info['episodes'][int(episode_id)] = ep_return
cache.cache_show_info(show_info)
api_utils.set_headers({})
return ep_return
api_utils.set_headers({})
return None


Expand Down Expand Up @@ -360,6 +371,7 @@ def load_fanarttv_art(show_info):
:return: show info
"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
if source_settings["FANARTTV_CLIENTKEY"]:
FANARTTV_PARAMS['client_key'] = source_settings["FANARTTV_CLIENTKEY"]

Expand Down Expand Up @@ -396,6 +408,7 @@ def load_fanarttv_art(show_info):
else:
show_info['images'][tmdb_type].append(
{'file_path': filepath, 'type': 'fanarttv', 'iso_639_1': lang})
api_utils.set_headers({})
return show_info


Expand Down
3 changes: 2 additions & 1 deletion metadata.tvshows.themoviedb.org.python/libs/traktratings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
('trakt-api-version', '2'),
('Content-Type', 'application/json'),
)
api_utils.set_headers(dict(HEADERS))

SHOW_URL = 'https://api.trakt.tv/shows/{}'
EP_URL = SHOW_URL + '/seasons/{}/episodes/{}/ratings'
Expand All @@ -50,6 +49,7 @@ def get_details(imdb_id, season=None, episode=None):
:return: trackt ratings
"""
source_settings = settings.getSourceSettings()
api_utils.set_headers(dict(HEADERS))
result = {}
if season and episode:
url = EP_URL.format(imdb_id, season, episode)
Expand All @@ -63,4 +63,5 @@ def get_details(imdb_id, season=None, episode=None):
votes = resp.get('votes')
if votes and rating:
result['ratings'] = {'trakt': {'votes': votes, 'rating': rating}}
api_utils.set_headers({})
return result
Loading