forked from nightflyer73/plugin.video.raitv
-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.py
574 lines (502 loc) · 21.8 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# -*- coding: utf-8 -*-
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import urllib
try:
import urllib.parse as urlparse
except ImportError:
import urlparse
try:
from urllib.parse import urlencode
except:
from urllib import urlencode
import datetime
from resources.lib import StorageServer
from resources.lib.tgr import TGR
from resources.lib.search import Search
from resources.lib.raiplay import RaiPlay
from resources.lib.raiplayradio import RaiPlayRadio
from resources.lib.relinker import Relinker
import resources.lib.utils as utils
import re
# plugin constants
__plugin__ = "plugin.video.raitv"
__author__ = "Nightflyer"
Addon = xbmcaddon.Addon(id=__plugin__)
# plugin handle
handle = int(sys.argv[1])
# Cache channels for 1 hour
cache = StorageServer.StorageServer("plugin.video.raitv", 1) # (Your plugin name, Cache time in hours)
tv_stations = cache.cacheFunction(RaiPlay().getChannels)
radio_stations = cache.cacheFunction(RaiPlayRadio().getChannels)
# utility functions
def parameters_string_to_dict(parameters):
''' Convert parameters encoded in a URL to a dict. '''
paramDict = dict(urlparse.parse_qsl(parameters[1:]))
return paramDict
def addDirectoryItem(parameters, li):
url = sys.argv[0] + '?' + urlencode(parameters)
return xbmcplugin.addDirectoryItem(handle=handle, url=url,
listitem=li, isFolder=True)
def addLinkItem(parameters, li, url=""):
if url == "":
url = sys.argv[0] + '?' + urlencode(parameters)
li.setProperty('IsPlayable', 'true')
return xbmcplugin.addDirectoryItem(handle=handle, url=url,
listitem=li, isFolder=False)
# UI builder functions
def show_root_menu():
''' Show the plugin root menu '''
liStyle = xbmcgui.ListItem("Dirette TV")
addDirectoryItem({"mode": "live_tv"}, liStyle)
liStyle = xbmcgui.ListItem("Dirette Radio")
addDirectoryItem({"mode": "live_radio"}, liStyle)
liStyle = xbmcgui.ListItem("Replay TV")
addDirectoryItem({"mode": "replay", "media": "tv"}, liStyle)
liStyle = xbmcgui.ListItem("Replay Radio")
addDirectoryItem({"mode": "replay", "media": "radio"}, liStyle)
liStyle = xbmcgui.ListItem("Programmi TV On Demand")
addDirectoryItem({"mode": "ondemand"}, liStyle)
liStyle = xbmcgui.ListItem("Archivio Telegiornali")
addDirectoryItem({"mode": "tg"}, liStyle)
liStyle = xbmcgui.ListItem("Videonotizie")
addDirectoryItem({"mode": "news"}, liStyle)
liStyle = xbmcgui.ListItem("Aree tematiche")
addDirectoryItem({"mode": "themes"}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_tg_root():
search = Search()
try:
for k, v in search.newsArchives.iteritems():
liStyle = xbmcgui.ListItem(k)
addDirectoryItem({"mode": "get_last_content_by_tag",
"tags": search.newsArchives[k]}, liStyle)
except:
for k, v in search.newsArchives.items():
liStyle = xbmcgui.ListItem(k)
addDirectoryItem({"mode": "get_last_content_by_tag",
"tags": search.newsArchives[k]}, liStyle)
liStyle = xbmcgui.ListItem("TGR",
thumbnailImage="http://www.tgr.rai.it/dl/tgr/mhp/immagini/splash.png")
addDirectoryItem({"mode": "tgr"}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_tgr_root():
#xbmcplugin.setContent(handle=handle, content='tvshows')
tgr = TGR()
programmes = tgr.getProgrammes()
for programme in programmes:
liStyle = xbmcgui.ListItem(programme["title"],
thumbnailImage=programme["image"])
addDirectoryItem({"mode": "tgr",
"behaviour": programme["behaviour"],
"url": programme["url"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_tgr_list(mode, url):
#xbmcplugin.setContent(handle=handle, content='episodes')
tgr = TGR()
itemList = tgr.getList(url)
for item in itemList:
behaviour = item["behaviour"]
if behaviour != "video":
liStyle = xbmcgui.ListItem(item["title"])
addDirectoryItem({"mode": "tgr",
"behaviour": behaviour,
"url": item["url"]}, liStyle)
else:
liStyle = xbmcgui.ListItem(item["title"])
liStyle.setInfo("video", {})
addLinkItem({"mode": "play",
"url": item["url"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def play(url, pathId="", srt=[]):
xbmc.log("Playing...")
if pathId != "":
xbmc.log("PathID: " + pathId)
# Ugly hack
if pathId[:7] == "/audio/":
raiplayradio = RaiPlayRadio()
metadata = raiplayradio.getAudioMetadata(pathId)
url = metadata["contentUrl"]
srtUrl = ""
else:
raiplay = RaiPlay()
metadata = raiplay.getVideoMetadata(pathId)
url = metadata["content_url"]
srtUrl = metadata["subtitles"]
if srtUrl != "":
xbmc.log("SRT URL: " + srtUrl)
srt.append(srtUrl)
# Handle RAI relinker
if url[:53] == "http://mediapolis.rai.it/relinker/relinkerServlet.htm" or \
url[:56] == "http://mediapolisvod.rai.it/relinker/relinkerServlet.htm" or \
url[:58] == "http://mediapolisevent.rai.it/relinker/relinkerServlet.htm":
xbmc.log("Relinker URL: " + url)
relinker = Relinker()
url = relinker.getURL(url)
# Add the server to the URL if missing
if url[0] == "/":
url = raiplay.baseUrl[:-1] + url
xbmc.log("Media URL: " + url)
# Play the item
try: item=xbmcgui.ListItem(path=url + '|User-Agent=' + urllib.quote_plus(Relinker.UserAgent))
except: item=xbmcgui.ListItem(path=url + '|User-Agent=' + urllib.parse.quote_plus(Relinker.UserAgent))
if len(srt) > 0:
item.setSubtitles(srt)
xbmcplugin.setResolvedUrl(handle=handle, succeeded=True, listitem=item)
def show_tv_channels():
raiplay = RaiPlay()
for station in tv_stations:
liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=raiplay.getThumbnailUrl(station["transparent-icon"]))
liStyle.setInfo("video", {})
addLinkItem({"mode": "play",
"url": station["video"]["contentUrl"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_radio_stations():
for station in radio_stations:
liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=station["stillFrame"])
liStyle.setInfo("audio", {})
addLinkItem({"mode": "play",
"url": station["audio"]["castUrl"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_dates(media):
days = ["Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedì", "Venerdì", "Sabato"]
months = ["gennaio", "febbraio", "marzo", "aprile", "maggio", "giugno",
"luglio", "agosto", "settembre", "ottobre", "novembre", "dicembre"]
epgEndDate = datetime.date.today()
epgStartDate = datetime.date.today() - datetime.timedelta(days=7)
for day in utils.daterange(epgStartDate, epgEndDate):
day_str = days[int(day.strftime("%w"))] + " " + day.strftime("%d") + " " + months[int(day.strftime("%m"))-1]
liStyle = xbmcgui.ListItem(day_str)
addDirectoryItem({"mode": "replay",
"media": media,
"date": day.strftime("%d-%m-%Y")}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_tv_channels(date):
raiplay = RaiPlay()
for station in tv_stations:
liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=raiplay.getThumbnailUrl(station["transparent-icon"]))
addDirectoryItem({"mode": "replay",
"media": "tv",
"channel_id": station["channel"],
"date": date}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_radio_channels(date):
for station in radio_stations:
liStyle = xbmcgui.ListItem(station["channel"], thumbnailImage=station["stillFrame"])
addDirectoryItem({"mode": "replay",
"media": "radio",
"channel_id": station["channel"].encode("utf-8"),
"date": date}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_tv_epg(date, channelId):
xbmc.log("Showing EPG for " + channelId + " on " + date)
raiplay = RaiPlay()
programmes = raiplay.getProgrammes(channelId, date)
if(programmes):
for programme in programmes:
if not programme:
continue
startTime = programme["timePublished"]
title = programme["name"]
if programme["images"]["landscape"] != "":
thumb = raiplay.getThumbnailUrl(programme["images"]["landscape"])
elif programme["isPartOf"] and programme["isPartOf"]["images"]["landscape"] != "":
thumb = raiplay.getThumbnailUrl(programme["isPartOf"]["images"]["landscape"])
else:
thumb = raiplay.noThumbUrl
if programme["hasVideo"]:
videoUrl = programme["pathID"]
else:
videoUrl = None
if videoUrl is None:
# programme is not available
liStyle = xbmcgui.ListItem(startTime + " [I]" + title + "[/I]",
thumbnailImage=thumb)
liStyle.setInfo("video", {})
addLinkItem({"mode": "nop"}, liStyle)
else:
liStyle = xbmcgui.ListItem(startTime + " " + title,
thumbnailImage=thumb)
liStyle.setInfo("video", {})
addLinkItem({"mode": "play",
"path_id": videoUrl}, liStyle)
else:
response = raiplay.getProgrammesHtml(channelId, date)
programmes = re.findall('(<li.*?</li>)', response)
for i in programmes:
icon = re.findall('''data-img=['"]([^'^"]+?)['"]''', i)
if icon:
icon = raiplay.getUrl(icon[0])
else:
icon =''
title = re.findall("<p class=\"info\">([^<]+?)</p>", i)
if title:
title = title[0]
else:
title = ''
startTime = re.findall("<p class=\"time\">([^<]+?)</p>", i)
if startTime:
title = startTime[0] + " " + title
desc = re.findall("<p class=\"descProgram\">([^<]+?)</p>", i, re.S)
if desc:
desc= desc[0]
else:
desc=""
videoUrl = re.findall('''data-href=['"]([^'^"]+?)['"]''', i)
if not videoUrl:
# programme is not available
liStyle = xbmcgui.ListItem(" [I]" + title + "[/I]", thumbnailImage = icon)
liStyle.setInfo("video", {})
addLinkItem({"mode": "nop"}, liStyle)
else:
videoUrl = videoUrl[0]
if not videoUrl.endswith('json'):
videoUrl = videoUrl + "?json"
liStyle = xbmcgui.ListItem(title, thumbnailImage = icon )
liStyle.setInfo("video", {})
addLinkItem({"mode": "play", "path_id": videoUrl}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_replay_radio_epg(date, channelId):
xbmc.log("Showing EPG for " + channelId + " on " + date)
raiplayradio = RaiPlayRadio()
programmes = raiplayradio.getProgrammes(channelId.decode("utf-8"), date)
for programme in programmes:
if not programme:
continue
startTime = programme["timePublished"]
title = programme["name"]
if programme["images"]["landscape"] != "":
thumb = raiplayradio.getThumbnailUrl(programme["images"]["square"])
elif programme["isPartOf"] and programme["isPartOf"]["images"]["square"] != "":
thumb = raiplayradio.getThumbnailUrl(programme["isPartOf"]["images"]["square"])
else:
thumb = raiplayradio.noThumbUrl
if programme["hasAudio"]:
audioUrl = programme["pathID"]
else:
audioUrl = None
if audioUrl is None:
# programme is not available
liStyle = xbmcgui.ListItem(startTime + " [I]" + title + "[/I]",
thumbnailImage=thumb)
liStyle.setInfo("audio", {})
addLinkItem({"mode": "nop"}, liStyle)
else:
liStyle = xbmcgui.ListItem(startTime + " " + title,
thumbnailImage=thumb)
liStyle.setInfo("audio", {})
addLinkItem({"mode": "play",
"path_id": audioUrl}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_root():
raiplay = RaiPlay()
items = raiplay.getMainMenu()
for item in items:
if item["sub-type"] in ("RaiPlay Tipologia Page", "RaiPlay Genere Page", "RaiPlay Tipologia Editoriale Page" ):
liStyle = xbmcgui.ListItem(item["name"])
addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
liStyle = xbmcgui.ListItem("Cerca")
addDirectoryItem({"mode": "ondemand_search_by_name"}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_programmes(pathId):
xbmc.log("PathID: " + pathId)
raiplay = RaiPlay()
blocchi = raiplay.getCategory(pathId)
if len(blocchi) > 1:
xbmc.log("Blocchi: " + str(len(blocchi)))
for item in blocchi[0]["lanci"]:
liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": item["sub-type"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_list(pathId):
xbmc.log("PathID: " + pathId)
liStyle = xbmcgui.ListItem("0-9")
addDirectoryItem({"mode": "ondemand_list", "index": "0-9", "path_id": pathId}, liStyle)
for i in range(26):
liStyle = xbmcgui.ListItem(chr(ord('A')+i))
addDirectoryItem({"mode": "ondemand_list", "index": chr(ord('A')+i), "path_id": pathId}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_index(index, pathId):
xbmc.log("PathID: " + pathId)
xbmc.log("Index: " + index)
raiplay = RaiPlay()
dir = raiplay.getProgrammeList(pathId)
for item in dir[index]:
liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": "PLR programma Page"}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_programme(pathId):
xbmc.log("PathID: " + pathId)
raiplay = RaiPlay()
programme = raiplay.getProgramme(pathId)
if (len(programme["infoProg"]["tipologia"]) > 0) and programme["infoProg"]["tipologia"][0]["nome"] == "Film":
if "pathFirstItem" in programme:
liStyle = xbmcgui.ListItem(programme["infoProg"]["name"], thumbnailImage=raiplay.getThumbnailUrl(programme["infoProg"]["images"]["landscape"]))
liStyle.setInfo("video", {
"Plot": programme["infoProg"]["description"],
"Cast": programme["infoProg"]["interpreti"].split(", "),
"Director": programme["infoProg"]["regia"],
"Country": programme["infoProg"]["country"],
"Year": programme["infoProg"]["anno"],
})
addLinkItem({"mode": "play",
"path_id": programme["pathFirstItem"]}, liStyle)
else:
blocks = programme["Blocks"]
for block in blocks:
for set in block["Sets"]:
liStyle = xbmcgui.ListItem(set["Name"])
addDirectoryItem({"mode": "ondemand_items", "url": set["url"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_ondemand_items(url):
xbmc.log("ContentSet URL: " + url)
raiplay = RaiPlay()
items = raiplay.getContentSet(url)
for item in items:
title = item["name"]
if "subtitle" in item and item["subtitle"] != "" and item["subtitle"] != item["name"]:
title = title + " (" + item["subtitle"] + ")"
liStyle = xbmcgui.ListItem(title, thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
liStyle.setInfo("video", {})
addLinkItem({"mode": "play",
"path_id": item["pathID"]}, liStyle)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def search_ondemand_programmes():
kb = xbmc.Keyboard()
kb.setHeading("Cerca un programma")
kb.doModal()
if kb.isConfirmed():
try: name = kb.getText().decode('utf8').lower()
except: name = kb.getText().lower()
xbmc.log("Searching for programme: " + name)
raiplay = RaiPlay()
dir = raiplay.getProgrammeList(raiplay.AzTvShowPath)
for letter in dir:
for item in dir[letter]:
if item["name"].lower().find(name) != -1:
liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
addDirectoryItem({"mode": "ondemand", "path_id": item["PathID"], "sub_type": "PLR programma Page"}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_news_providers():
search = Search()
try:
for k, v in search.newsProviders.iteritems():
liStyle = xbmcgui.ListItem(k)
addDirectoryItem({"mode": "get_last_content_by_tag",
"tags": search.newsProviders[k]}, liStyle)
except:
for k, v in search.newsProviders.items():
liStyle = xbmcgui.ListItem(k)
addDirectoryItem({"mode": "get_last_content_by_tag",
"tags": search.newsProviders[k]}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def show_themes():
search = Search()
for position, tematica in enumerate(search.tematiche):
liStyle = xbmcgui.ListItem(tematica)
addDirectoryItem({"mode": "get_last_content_by_tag",
"tags": "Tematica:"+search.tematiche[int(position)]}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def get_last_content_by_tag(tags):
xbmc.log("Get latest content for tags: " + tags)
search = Search()
items = search.getLastContentByTag(tags)
show_search_result(items)
def get_most_visited(tags):
xbmc.log("Get most visited for tags: " + tags)
search = Search()
items = search.getMostVisited(tags)
show_search_result(items)
def show_search_result(items):
raiplay = RaiPlay()
for item in items:
liStyle = xbmcgui.ListItem(item["name"], thumbnailImage=raiplay.getThumbnailUrl(item["images"]["landscape"]))
liStyle.setInfo("video", {})
# Using "Url" because "PathID" is broken upstream :-/
addLinkItem({"mode": "play", "url": item["Url"]}, liStyle)
xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_NONE)
xbmcplugin.endOfDirectory(handle=handle, succeeded=True)
def log_country():
raiplay = RaiPlay()
country = raiplay.getCountry()
xbmc.log("RAI geolocation: %s" % country)
# parameter values
params = parameters_string_to_dict(sys.argv[2])
# TODO: support content_type parameter, provided by XBMC Frodo.
content_type = str(params.get("content_type", ""))
mode = str(params.get("mode", ""))
media = str(params.get("media", ""))
behaviour = str(params.get("behaviour", ""))
url = str(params.get("url", ""))
date = str(params.get("date", ""))
channelId = str(params.get("channel_id", ""))
index = str(params.get("index", ""))
pathId = str(params.get("path_id", ""))
subType = str(params.get("sub_type", ""))
tags = str(params.get("tags", ""))
if mode == "live_tv":
show_tv_channels()
elif mode == "live_radio":
show_radio_stations()
elif mode == "replay":
if date == "":
show_replay_dates(media)
elif channelId == "":
if media == "tv":
show_replay_tv_channels(date)
else:
show_replay_radio_channels(date)
else:
if media == "tv":
show_replay_tv_epg(date, channelId)
else:
show_replay_radio_epg(date, channelId)
elif mode == "nop":
dialog = xbmcgui.Dialog()
dialog.ok("Replay", "Elemento non disponibile")
elif mode == "ondemand":
if subType == "":
show_ondemand_root()
elif subType in ("RaiPlay Tipologia Page", "RaiPlay Genere Page", "RaiPlay Tipologia Editoriale Page"):
show_ondemand_programmes(pathId)
elif subType == "Raiplay Tipologia Item":
show_ondemand_list(pathId)
elif subType == "PLR programma Page":
show_ondemand_programme(pathId)
else:
xbmc.log("Unhandled sub-type: " + subType)
elif mode == "ondemand_list":
show_ondemand_index(index, pathId)
elif mode == "ondemand_items":
show_ondemand_items(url)
elif mode == "ondemand_search_by_name":
search_ondemand_programmes()
elif mode == "tg":
show_tg_root()
elif mode == "tgr":
if url != "":
show_tgr_list(mode, url)
else:
show_tgr_root()
elif mode == "news":
show_news_providers()
elif mode == "themes":
show_themes()
elif mode == "get_last_content_by_tag":
get_last_content_by_tag(tags)
elif mode == "get_most_visited":
get_most_visited(tags)
elif mode == "play":
play(url, pathId)
else:
log_country()
show_root_menu()