From 3950ad91ef5a31a11772bc616396b1a1ecebb9bc Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Tue, 13 Jul 2021 15:57:46 +0200 Subject: [PATCH] Fix Trakt --- core/trakt_tools.py | 8 ++++---- specials/tvmoviedb.py | 13 ++++++++++--- specials/videolibrary.py | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/core/trakt_tools.py b/core/trakt_tools.py index f1fb8aca..bf00588a 100644 --- a/core/trakt_tools.py +++ b/core/trakt_tools.py @@ -26,7 +26,7 @@ def auth_trakt(): post = {'client_id': client_id} post = jsontools.dump(post) # Se solicita url y código de verificación para conceder permiso a la app - url = "http://api-v2launch.trakt.tv/oauth/device/code" + url = "http://api.trakt.tv/oauth/device/code" data = httptools.downloadpage(url, post=post, headers=headers).data data = jsontools.load(data) item.verify_url = data["verification_url"] @@ -57,14 +57,14 @@ def token_trakt(item): try: if item.extra == "renew": refresh = config.get_setting("refresh_token_trakt", "trakt") - url = "http://api-v2launch.trakt.tv/oauth/device/token" + url = "http://api.trakt.tv/oauth/device/token" post = {'refresh_token': refresh, 'client_id': client_id, 'client_secret': client_secret, 'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'grant_type': 'refresh_token'} post = jsontools.dump(post) data = httptools.downloadpage(url, post=post, headers=headers).data data = jsontools.load(data) elif item.action == "token_trakt": - url = "http://api-v2launch.trakt.tv/oauth/device/token" + url = "http://api.trakt.tv/oauth/device/token" post = "code=%s&client_id=%s&client_secret=%s" % (item.device_code, client_id, client_secret) data = httptools.downloadpage(url, post=post, headers=headers).data data = jsontools.load(data) @@ -83,7 +83,7 @@ def token_trakt(item): config.set_setting("trakt_sync", False) return - url = "http://api-v2launch.trakt.tv/oauth/device/token" + url = "http://api.trakt.tv/oauth/device/token" post = {'code': item.device_code, 'client_id': client_id, 'client_secret': client_secret} post = jsontools.dump(post) data = httptools.downloadpage(url, post=post, headers=headers).data diff --git a/specials/tvmoviedb.py b/specials/tvmoviedb.py index 8861e2fe..d2a2a142 100644 --- a/specials/tvmoviedb.py +++ b/specials/tvmoviedb.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import re from core import filetools, jsontools, trakt_tools +from core import support from core.tmdb import Tmdb from core.scrapertools import htmlclean, decodeHtmlentities from core.support import thumb, typo, match, Item @@ -1910,7 +1911,7 @@ def acciones_trakt(item): post = None if item.post: post = jsontools.dump(item.post) - url = "http://api-v2launch.trakt.tv/%s" % item.url + url = "http://api.trakt.tv/%s" % item.url data = httptools.downloadpage(url, post=post, headers=headers) if data.code == "401": trakt_tools.token_trakt(item.clone(args="renew")) @@ -1966,14 +1967,20 @@ def acciones_trakt(item): # try: entry = entry[item.args] # except: pass new_item = item.clone(action="details") - if 'show' in entry or 'show' in item.args: + if 'show' in entry and 'show' in item.args: entry = entry['show'] new_item.args = 'show' new_item.contentType = 'tvshow' - else: + elif 'movie' in entry and 'movie' in item.args: entry = entry['movie'] new_item.args = 'movie' new_item.contentType = 'movie' + elif 'show' in item.args: + new_item.args = 'show' + new_item.contentType = 'tvshow' + else: + new_item.args = 'movie' + new_item.contentType = 'movie' new_item.title = entry["title"] + " (%s)" % entry["year"] new_item.infoLabels["tmdb_id"] = entry["ids"]["tmdb"] try: ratings.append(entry["rating"]) diff --git a/specials/videolibrary.py b/specials/videolibrary.py index f3d20e28..fcf2a3fb 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -920,7 +920,8 @@ def mark_content_as_watched(item): if config.is_xbmc(): from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_content_as_watched_on_kodi(item, item.playcount) - + if config.get_setting("trakt_sync"): + xbmc_videolibrary.sync_trakt_kodi() platformtools.itemlist_refresh() @@ -975,6 +976,8 @@ def mark_season_as_watched(item): # We update the Kodi database from platformcode import xbmc_videolibrary xbmc_videolibrary.mark_season_as_watched_on_kodi(item, item.playcount) + if config.get_setting("trakt_sync"): + xbmc_videolibrary.sync_trakt_kodi() platformtools.itemlist_refresh()