summaryrefslogtreecommitdiff
path: root/plugin.video.unithek/default.py
blob: fbacdb8beb443f193e31482bb72340df1d442cff (plain)
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
# -*- coding: utf-8 -*-


import sys
import xbmc
import xbmcgui
import xbmcplugin
import xbmcaddon
import urllib

import threading

import libmediathek3 as libMediathek

import lib3sat
import libard
import libbr
import libdaserste
import libhr
import libkika
import libmdr
import libndr
import libsr
import libswr
import libwdr
import libzdf

translation = libMediathek.getTranslation

log = libMediathek.log
import time
t = time.time() * 1000

	
def logtime():
	xbmc.log(str(time.time() * 1000 - t))

def listMain():
	l = []
	l.append({'_name':translation(31031), 'mode':'listMV', '_type':'dir'})
	l.append({'_name':translation(31032), 'mode':'listAZ', '_type':'dir'})
	l.append({'_name':translation(31033), 'mode':'listDateChannels', '_type':'dir'})
	return l
	
def listMV():
	l = []
	l += libard.getMostViewed()
	l += libzdf.getMostViewed()[:50]
	libMediathek.sortAZ()
	return l

def listAZ():
	l = []
	t1 = threading.Thread(target=getA)
	t2 = threading.Thread(target=getZ)
	t1.start()
	t2.start()
	t1.join()
	t2.join()
	l += la
	l += lz
	libMediathek.sortAZ()
	return l
	
def getA():
	global la
	la = libard.libArdListShows()
	
def getZ():
	global lz
	lz = libzdf.libZdfListAZ()
	
def listDateChannels():
	l = []
	l.append({'name':'3sat', 'mode':'lib3satListDate', '_type':'dir'})
	l.append({'name':'ARD-Alpha', 'mode':'libBrListChannelDate', 'channel':'ARD-Alpha', '_type':'dir'})
	l.append({'name':'BR', 'mode':'libBrListChannelDate', 'channel':'BR', '_type':'dir'})
	l.append({'name':'Das Erste', 'mode':'libDasErsteListDate', '_type':'dir'})
	l.append({'name':'HR', 'mode':'libHrListDate', '_type':'dir'})
	l.append({'name':'KiKa', 'mode':'libKikaListDate', '_type':'dir'})
	l.append({'name':'MDR', 'mode':'libMdrListDate', '_type':'dir'})
	#l.append({'name':'MDR', 'mode':'libArdListChannelDate', 'channel':'MDR', '_type':'dir'})
	l.append({'name':'NDR', 'mode':'libNdrListDate', '_type':'dir'})
	l.append({'name':'One', 'mode':'libArdListChannelDate','channel':'One', '_type':'dir'})
	#l.append({'name':'Phoenix', 'mode':'libZdfListChannelDate', 'channel':'phoenix', '_type':'dir'})
	l.append({'name':'RB', 'mode':'libArdListChannelDate','channel':'RB', '_type':'dir'})
	l.append({'name':'RBB', 'mode':'libArdListChannelDate','channel':'RBB', '_type':'dir'})
	l.append({'name':'SR', 'mode':'libSrListDate', '_type':'dir'})
	l.append({'name':'SWR', 'mode':'libSwrListDate', '_type':'dir'})
	l.append({'name':'Tagesschau24', 'mode':'libArdListChannelDate','channel':'tagesschau24', '_type':'dir'})
	l.append({'name':'WDR', 'mode':'libWdrListDate', '_type':'dir'})
	l.append({'name':'ZDF', 'mode':'libZdfListChannelDate', 'channel':'zdf', '_type':'dir'})
	l.append({'name':'ZDF Info', 'mode':'libZdfListChannelDate', 'channel':'zdfinfo', '_type':'dir'})
	l.append({'name':'ZDF Neo', 'mode':'libZdfListChannelDate', 'channel':'zdfneo', '_type':'dir'})
	return l
	
def list():	
	global params
	params = libMediathek.get_params()
	global pluginhandle
	pluginhandle = int(sys.argv[1])
	
	mode = params.get('mode','listMain')
	xbmc.log(mode)
	if mode.startswith('lib3sat') or mode.startswith('xml'):
		lib3sat.list()
	elif mode.startswith('libArd'):
		libard.list()
	elif mode.startswith('libBr'):
		libbr.list()
	elif mode.startswith('libDasErste'):
		libdaserste.list()
	elif mode.startswith('libHr'):
		libhr.list()
	elif mode.startswith('libKika'):
		libkika.list()
	elif mode.startswith('libMdr'):
		libmdr.list()
	elif mode.startswith('libNdr'):
		libndr.list()
	elif mode.startswith('libSr'):
		libsr.list()
	elif mode.startswith('libSwr'):
		libswr.list()
	elif mode.startswith('libWdr'):
		libwdr.list()
	elif mode.startswith('libZdf'):
		libzdf.list()
	else:
		l = modes.get(mode,listMain)()
		libMediathek.addEntries(l)
		xbmcplugin.endOfDirectory(int(sys.argv[1]),cacheToDisc=True)	
		
modes = {
	'listDateChannels': listDateChannels,
	'listAZ': listAZ,
	'listMV': listMV,
	}
list()