-
Notifications
You must be signed in to change notification settings - Fork 10
/
default.py
131 lines (105 loc) · 3.27 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
# -*- coding: cp1252 -*-
""" -*- coding: utf-8 -*- """
# version 3.0.0 - By CB
# version 2.0.2 - By SlySen
# version 0.2.6 - By CB
#
# pylint...: --max-line-length 120
# vim......: set expandtab
# vim......: set tabstop=4
#
import os, urllib, sys, traceback, xbmcplugin, xbmcaddon, xbmc, simplejson, xbmcgui
from resources.lib import content, parse, navig
#from collections import OrderedDict
def peupler():
if filtres['content']['mediaBundleId']>0:
creer_liste_videos()
elif filtres['content']['genreId']!='':
creer_liste_filtree()
else:
creer_menu_categories()
def creer_menu_categories():
""" function docstring """
navig.ajouterItemAuMenu(content.dictOfGenres(filtres))
navig.ajouterItemAuMenu(content.dictOfMainDirs(filtres))
def creer_liste_filtree():
""" function docstring """
navig.ajouterItemAuMenu(parse.get_liste_emissions(filtres))
def creer_liste_videos():
""" function docstring """
navig.ajouterItemAuMenu(parse.ListeVideosGroupees(filtres))
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 set_content(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('--- init -----------------')
# ---
PARAMS = get_params()
URL = None
MODE = None
SOURCE_ID = ''
FILTERS = ''
filtres = {}
try:
URL = urllib.unquote_plus(PARAMS["url"])
log("PARAMS['url']:"+URL)
except StandardError:
pass
try:
MODE = int(PARAMS["mode"])
log("PARAMS['mode']:"+str(MODE))
except StandardError:
pass
try:
FILTERS = urllib.unquote_plus(PARAMS["filters"])
except StandardError:
FILTERS = content.FILTRES
try:
SOURCE_ID = urllib.unquote_plus(PARAMS["sourceId"])
except StandardError:
pass
filtres = simplejson.loads(FILTERS)
if SOURCE_ID !='':
navig.jouer_video(SOURCE_ID)
elif MODE == 99:
ADDON.openSettings()
else:
peupler()
set_content('episodes')
if MODE is not 99:
set_sorting_methods(MODE)
xbmcplugin.endOfDirectory(int(sys.argv[1]))
if MODE is not 4 and xbmcaddon.Addon().getSetting('DeleteTempFiFilesEnabled') == 'true':
PATH = xbmc.translatePath('special://temp')
FILENAMES = next(os.walk(PATH))[2]
for i in FILENAMES:
if ".fi" in i:
os.remove(os.path.join(PATH, i))