Fix Trakt
This commit is contained in:
+4
-4
@@ -26,7 +26,7 @@ def auth_trakt():
|
|||||||
post = {'client_id': client_id}
|
post = {'client_id': client_id}
|
||||||
post = jsontools.dump(post)
|
post = jsontools.dump(post)
|
||||||
# Se solicita url y código de verificación para conceder permiso a la app
|
# 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 = httptools.downloadpage(url, post=post, headers=headers).data
|
||||||
data = jsontools.load(data)
|
data = jsontools.load(data)
|
||||||
item.verify_url = data["verification_url"]
|
item.verify_url = data["verification_url"]
|
||||||
@@ -57,14 +57,14 @@ def token_trakt(item):
|
|||||||
try:
|
try:
|
||||||
if item.extra == "renew":
|
if item.extra == "renew":
|
||||||
refresh = config.get_setting("refresh_token_trakt", "trakt")
|
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,
|
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'}
|
'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'grant_type': 'refresh_token'}
|
||||||
post = jsontools.dump(post)
|
post = jsontools.dump(post)
|
||||||
data = httptools.downloadpage(url, post=post, headers=headers).data
|
data = httptools.downloadpage(url, post=post, headers=headers).data
|
||||||
data = jsontools.load(data)
|
data = jsontools.load(data)
|
||||||
elif item.action == "token_trakt":
|
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)
|
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 = httptools.downloadpage(url, post=post, headers=headers).data
|
||||||
data = jsontools.load(data)
|
data = jsontools.load(data)
|
||||||
@@ -83,7 +83,7 @@ def token_trakt(item):
|
|||||||
config.set_setting("trakt_sync", False)
|
config.set_setting("trakt_sync", False)
|
||||||
return
|
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 = {'code': item.device_code, 'client_id': client_id, 'client_secret': client_secret}
|
||||||
post = jsontools.dump(post)
|
post = jsontools.dump(post)
|
||||||
data = httptools.downloadpage(url, post=post, headers=headers).data
|
data = httptools.downloadpage(url, post=post, headers=headers).data
|
||||||
|
|||||||
+10
-3
@@ -1,6 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import re
|
import re
|
||||||
from core import filetools, jsontools, trakt_tools
|
from core import filetools, jsontools, trakt_tools
|
||||||
|
from core import support
|
||||||
from core.tmdb import Tmdb
|
from core.tmdb import Tmdb
|
||||||
from core.scrapertools import htmlclean, decodeHtmlentities
|
from core.scrapertools import htmlclean, decodeHtmlentities
|
||||||
from core.support import thumb, typo, match, Item
|
from core.support import thumb, typo, match, Item
|
||||||
@@ -1910,7 +1911,7 @@ def acciones_trakt(item):
|
|||||||
post = None
|
post = None
|
||||||
if item.post: post = jsontools.dump(item.post)
|
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)
|
data = httptools.downloadpage(url, post=post, headers=headers)
|
||||||
if data.code == "401":
|
if data.code == "401":
|
||||||
trakt_tools.token_trakt(item.clone(args="renew"))
|
trakt_tools.token_trakt(item.clone(args="renew"))
|
||||||
@@ -1966,14 +1967,20 @@ def acciones_trakt(item):
|
|||||||
# try: entry = entry[item.args]
|
# try: entry = entry[item.args]
|
||||||
# except: pass
|
# except: pass
|
||||||
new_item = item.clone(action="details")
|
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']
|
entry = entry['show']
|
||||||
new_item.args = 'show'
|
new_item.args = 'show'
|
||||||
new_item.contentType = 'tvshow'
|
new_item.contentType = 'tvshow'
|
||||||
else:
|
elif 'movie' in entry and 'movie' in item.args:
|
||||||
entry = entry['movie']
|
entry = entry['movie']
|
||||||
new_item.args = 'movie'
|
new_item.args = 'movie'
|
||||||
new_item.contentType = '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.title = entry["title"] + " (%s)" % entry["year"]
|
||||||
new_item.infoLabels["tmdb_id"] = entry["ids"]["tmdb"]
|
new_item.infoLabels["tmdb_id"] = entry["ids"]["tmdb"]
|
||||||
try: ratings.append(entry["rating"])
|
try: ratings.append(entry["rating"])
|
||||||
|
|||||||
@@ -920,7 +920,8 @@ def mark_content_as_watched(item):
|
|||||||
if config.is_xbmc():
|
if config.is_xbmc():
|
||||||
from platformcode import xbmc_videolibrary
|
from platformcode import xbmc_videolibrary
|
||||||
xbmc_videolibrary.mark_content_as_watched_on_kodi(item, item.playcount)
|
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()
|
platformtools.itemlist_refresh()
|
||||||
|
|
||||||
|
|
||||||
@@ -975,6 +976,8 @@ def mark_season_as_watched(item):
|
|||||||
# We update the Kodi database
|
# We update the Kodi database
|
||||||
from platformcode import xbmc_videolibrary
|
from platformcode import xbmc_videolibrary
|
||||||
xbmc_videolibrary.mark_season_as_watched_on_kodi(item, item.playcount)
|
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()
|
platformtools.itemlist_refresh()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user