forked from openmips/stbgui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceReference.py
59 lines (47 loc) · 1.72 KB
/
ServiceReference.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
from enigma import eServiceReference, eServiceCenter, getBestPlayableServiceReference
import NavigationInstance
class ServiceReference(eServiceReference):
def __init__(self, ref, reftype = eServiceReference.idInvalid, flags = 0, path = ''):
if reftype != eServiceReference.idInvalid:
self.ref = eServiceReference(reftype, flags, path)
elif not isinstance(ref, eServiceReference):
self.ref = eServiceReference(ref or "")
else:
self.ref = ref
self.serviceHandler = eServiceCenter.getInstance()
def __str__(self):
return self.ref.toString()
def getServiceName(self):
info = self.info()
return info and info.getName(self.ref) or ""
def info(self):
return self.serviceHandler.info(self.ref)
def list(self):
return self.serviceHandler.list(self.ref)
def getType(self):
return self.ref.type
def getPath(self):
return self.ref.getPath()
def getFlags(self):
return self.ref.flags
def isRecordable(self):
ref = self.ref
return ref.flags & eServiceReference.isGroup or (ref.type == eServiceReference.idDVB or ref.type == eServiceReference.idDVB + 0x100 or ref.type == 0x2000 or ref.type == 0x1001)
def getPlayingref(ref):
playingref = None
if NavigationInstance.instance:
playingref = NavigationInstance.instance.getCurrentlyPlayingServiceReference()
if not playingref:
playingref = eServiceReference()
return playingref
def isPlayableForCur(ref):
info = eServiceCenter.getInstance().info(ref)
return info and info.isPlayable(ref, getPlayingref(ref))
def resolveAlternate(ref):
nref = None
if ref.flags & eServiceReference.isGroup:
nref = getBestPlayableServiceReference(ref, getPlayingref(ref))
if not nref:
nref = getBestPlayableServiceReference(ref,
eServiceReference(), True)
return nref