*add getcurrent - return information for running service
[enigma2-plugins.git] / webinterface / src / WebComponents / Sources / AudioTracks.py
1 from Components.Sources.Source import Source
2 from Tools.ISO639 import LanguageCodes
3
4 class AudioTracks( Source ):
5     
6     def __init__(self, session):
7         self.session = session
8         Source.__init__(self)
9         
10     def getList(self):
11         service = self.session.nav.getCurrentService()
12         audio = service and service.audioTracks()
13         n = audio and audio.getNumberOfTracks() or 0
14         tlist = []
15         for name in dir(audio):
16             print getattr(audio, name)
17         if n > 0:
18             print "[AudioTracks.py] got %s Audiotracks!" %(n)
19             
20             for x in range(n):
21                 i = audio.getTrackInfo(x)
22                 for name in dir(i):
23                     print getattr(i, name)
24                 language = i.getLanguage()
25                 description = i.getDescription()
26                 
27                 from pprint import pprint
28                 pprint(x)
29                 
30                 if LanguageCodes.has_key(language):
31                     language = LanguageCodes[language][0]
32                 
33                 if len(description):
34                     description += " (" + language + ")"
35                 else:
36                     description = language
37                 
38                 tlist.append((description, x))
39         
40         return tlist
41     
42     list = property(getList)
43     lut = {"Description": 0, "Id": 1 }