-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.py
More file actions
97 lines (80 loc) · 3.13 KB
/
Copy pathplugin.py
File metadata and controls
97 lines (80 loc) · 3.13 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/python
import xbmcplugin
import xbmcgui
import xbmcaddon
import urllib.parse as urlparse
from helpers import *
import sys
ADDON = xbmcaddon.Addon()
ADDON_ID = ADDON.getAddonInfo('id')
class Main:
def __init__(self):
self.li = list()
self.flist = list()
self.id = int(sys.argv[1])
self.sort_lastplayed = {'order': 'descending', 'method': 'lastplayed'}
self.sort_playcount = {'order': 'ascending', 'method': 'playcount'}
path = sys.argv[2]
try:
args = path[1:]
self.params = dict(urlparse.parse_qsl(args))
except Exception:
self.params = {}
self.info = self.params.get('info', '')
if self.info:
if self.info.lower() == 'inprogress':
self.inprogress()
else:
self.listing()
def listing(self):
# Inprogress TV
list_item = xbmcgui.ListItem(label="Inprogress TV", offscreen=True)
info_tag = ListItemInfoTag(list_item, 'video')
info_tag.set_info({'title': 'Inprogress TV', 'mediatype': 'video'})
list_item.setArt({'icon': 'DefaultFolder.png',
'thumb': 'DefaultFolder.png'})
self.li.append(("plugin://script.tinyupnext/?info=inprogress", list_item, True))
set_plugincontent(self.id, content='videos')
xbmcplugin.addDirectoryItems(self.id, self.li)
xbmcplugin.endOfDirectory(handle=self.id)
#
# Next episode or inprogress
#
def inprogress(self):
# Get Inprogress shows
json_query = json_call('VideoLibrary.GetInprogressTVShows',
properties=JSON_MAP['tvshow_properties'],
sort=self.sort_lastplayed
)
try:
json_query = json_query['result']['tvshows']
except Exception:
pass
else:
for show in json_query:
# Get next episode
json_query = json_call('VideoLibrary.GetEpisodes',
properties=JSON_MAP['episode_properties'],
sort=self.sort_playcount,
params={'tvshowid': int(
show['tvshowid'])},
limit='1'
)
try:
episode = json_query['result']['episodes'][0]
episode['lastplayed'] = show['lastplayed']
episode['studio'] = show['studio']
episode['genre'] = show['genre']
episode['mpaa'] = show['mpaa']
episode['mediatype'] = 'episode'
self.li.append(episode)
except Exception:
pass
self.li.sort(key=lambda item: item['lastplayed'], reverse=True)
for item in self.li:
li = buildListItem(item)
self.flist.append(li)
finalizeList(id=self.id, items=self.flist,
category='inprogress', content='mixed')
if __name__ == '__main__':
Main()