This repository has been archived by the owner on May 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
/
instant_sync.py
52 lines (46 loc) · 2.69 KB
/
instant_sync.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# -*- coding: utf-8 -*-
#
import xbmc,xbmcaddon,xbmcgui
import telnetlib, time
try: import simplejson as json
except ImportError: import json
import threading
from utilities import *
from instant_sync import *
__author__ = "Ralph-Gordon Paul, Adrian Cowan"
__credits__ = ["Ralph-Gordon Paul", "Adrian Cowan", "Justin Nemeth", "Sean Rudford"]
__license__ = "GPL"
__maintainer__ = "Ralph-Gordon Paul"
__email__ = "[email protected]"
__status__ = "Production"
__settings__ = xbmcaddon.Addon( "script.traktutilities" )
__language__ = __settings__.getLocalizedString
# Move this to its own file
def instantSyncPlayCount(data):
if data['params']['data']['item']['type'] == 'episode':
info = getEpisodeDetailsFromXbmc(data['params']['data']['item']['id'], ['tvshowid','showtitle', 'season', 'episode'])
rpccmd = json.dumps({'jsonrpc': '2.0', 'method': 'VideoLibrary.GetTVShowDetails','params':{'tvshowid': info['tvshowid'], 'properties': ['imdbnumber']}, 'id': 1})
result = xbmc.executeJSONRPC(rpccmd)
result = json.loads(result)
Debug("[Instant-sync] (TheTVDB ID: )"+str(result))
if info == None: return
Debug("[Instant-sync] (episode playcount): "+str(info))
if data['params']['data']['playcount'] == 0:
res = setEpisodesUnseenOnTrakt(result['result']['tvshowdetails']['imdbnumber'], info['showtitle'], None, [{'season':info['season'], 'episode':info['episode']}])
elif data['params']['data']['playcount'] == 1:
res = setEpisodesSeenOnTrakt(result['result']['tvshowdetails']['imdbnumber'], info['showtitle'], None, [{'season':info['season'], 'episode':info['episode']}])
else:
return
Debug("[Instant-sync] (episode playcount): responce "+str(res))
if data['params']['data']['item']['type'] == 'movie':
info = getMovieDetailsFromXbmc(data['params']['data']['item']['id'], ['imdbnumber', 'title', 'year', 'playcount', 'lastplayed'])
if info == None: return
Debug("[Instant-sync] (movie playcount): "+str(info))
if 'lastplayed' not in info: info['lastplayed'] = None
if data['params']['data']['playcount'] == 0:
res = setMoviesUnseenOnTrakt([{'imdb_id':info['imdbnumber'], 'title':info['title'], 'year':info['year'], 'plays':data['params']['data']['playcount'], 'last_played':info['lastplayed']}])
elif data['params']['data']['playcount'] == 1:
res = setMoviesSeenOnTrakt([{'imdb_id':info['imdbnumber'], 'title':info['title'], 'year':info['year'], 'plays':data['params']['data']['playcount'], 'last_played':info['lastplayed']}])
else:
return
Debug("[Instant-sync] (movie playcount): responce "+str(res))