Fix Trakt

This commit is contained in:
Alhaziel01
2021-07-13 15:57:46 +02:00
parent d3bde5dd51
commit 3950ad91ef
3 changed files with 18 additions and 8 deletions

View File

@@ -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

View File

@@ -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"])

View File

@@ -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()