forked from anisite/plugin.infologique.TVAgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.py
135 lines (110 loc) · 3.53 KB
/
default.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# -*- coding: utf-8 -*-
import os, sys, traceback, xbmcplugin, xbmcaddon, xbmc, simplejson, xbmcgui
from resources.lib import content, navig
if sys.version_info.major >= 3:
# Python 3 stuff
from urllib.parse import quote_plus, unquote_plus, unquote
else:
# Python 2 stuff
from urllib import quote_plus, unquote_plus, unquote
ADDON = xbmcaddon.Addon()
def Load():
log("default.Load")
if filtres['content']['genreId'] != '':
CreateFilteredList()
else:
CreateMainMenu()
log("default.LoadExit")
def CreateMainMenu():
""" function docstring """
log("default.CreateMainMenu")
navig.AddItemInMenu(content.LoadMainMenu(filtres))
xbmc.executebuiltin('Container.SetViewMode(500)') # "List" view.
log("default.CreateMainMenuExit")
def CreateFilteredList():
""" function docstring """
log("default.CreateFilteredList")
log(filtres['content']['url'])
if 'containerId' in filtres['content']:
log(filtres['content']['containerId'])
navig.AddItemInMenu(content.LoadContainerItems(filtres))
xbmc.executebuiltin('Container.SetViewMode(55)') # "List" view.
else:
navig.AddItemInMenu(content.LoadContainers(filtres))
xbmc.executebuiltin('Container.SetViewMode(500)') # "List" view.
log("default.CreateFilteredListExit")
def get_params():
""" function docstring """
param = []
paramstring = sys.argv[2]
if len(paramstring) >= 2:
params = sys.argv[2]
cleanedparams = params.replace('?', '')
if params[len(params)-1] == '/':
params = params[0:len(params)-2]
pairsofparams = cleanedparams.split('&')
param = {}
for k in range(len(pairsofparams)):
splitparams = {}
splitparams = pairsofparams[k].split('=')
if (len(splitparams)) == 2:
param[splitparams[0]] = splitparams[1]
return param
def SetContent(content):
""" function docstring """
xbmcplugin.setContent(int(sys.argv[1]), content)
return
def set_sorting_methods(mode):
pass
#if xbmcaddon.Addon().getSetting('SortMethodTvShow') == '1':
# xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE)
# xbmcplugin.addSortMethod(int(sys.argv[1]), xbmcplugin.SORT_METHOD_TITLE_IGNORE_THE)
#return
def log(msg):
""" function docstring """
if xbmcaddon.Addon().getSetting('DebugMode') == 'true':
xbmc.log('[%s - DEBUG]: %s' % (xbmcaddon.Addon().getAddonInfo('name'), msg))
# ---
log('--- Addon Entry ---')
# ---
PARAMS = get_params()
URL = None
MODE = None
SOURCE_URL = ''
FILTERS = ''
filtres = {}
try:
URL = unquote_plus(PARAMS["url"])
log("PARAMS['url']:" + URL)
except Exception:
pass
try:
MODE = int(PARAMS["mode"])
log("PARAMS['mode']:" + str(MODE))
except Exception:
pass
try:
FILTERS = unquote_plus(PARAMS["filters"])
except Exception:
FILTERS = content.FILTRES
try:
SOURCE_URL = unquote_plus(PARAMS["sourceUrl"])
except Exception:
pass
filtres = simplejson.loads(FILTERS)
if SOURCE_URL !='':
navig.PlayVideo(SOURCE_URL)
elif MODE == 99:
ADDON.openSettings()
else:
Load()
SetContent('episodes')
if MODE != 99:
#set_sorting_methods(MODE)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
if MODE != 4 and xbmcaddon.Addon().getSetting('DeleteTempFiFilesEnabled') == 'true':
PATH = xbmc.translatePath('special://temp').decode('utf-8')
FILENAMES = next(os.walk(PATH))[2]
for i in FILENAMES:
if ".fi" in i:
os.remove(os.path.join(PATH, i))