tubelib: set eServiceReference isLive for channel list services
[enigma2-plugins.git] / tubelib / src / youtube / YTChannelListServiceProvider.py
1 from enigma import eServiceReference
2 from Screens.InputBox import InputBox
3 from Tools.Log import Log
4
5 from Plugins.SystemPlugins.TubeLib.ChannelListTubeServiceHelper import ChannelListServiceProviderBase, ChannelListTubeServiceHelper
6
7 class YTChannelListServiceProvider(ChannelListServiceProviderBase):
8         TYPE = "youtube"
9         DESCRIPTION = _("Youtube Live Channel")
10
11         def _createServiceForChannelList(self):
12                 self._addYoutubeService()
13
14         def _addYoutubeService(self):
15                 self._session.openWithCallback(self._onYoutubeChannel, InputBox, title=_("Please provide a YouTube Channel-/Username"), windowTitle=_("Youtube Channel/User"))
16
17         def _onYoutubeChannel(self, data):
18                 if data:
19                         self._tubeUri = "yt://live/%s" % (data,)
20                         self._session.openWithCallback(self._onLocalChannelName, InputBox, title=_("Please provide a channel name for your local channel list"), windowTitle=_("Local channel name"))
21                 else:
22                         self._finish(None)
23
24         def _onLocalChannelName(self, name):
25                 Log.w("uri=%s, name=%s" % (self._tubeUri, name))
26                 if name and self._tubeUri:
27                         ref = eServiceReference(eServiceReference.idURI, eServiceReference.isLive, self._tubeUri)
28                         ref.setName(name)
29                         self._finish(ref)
30                 else:
31                         self._finish(None)
32
33 ChannelListTubeServiceHelper.addProvider(YTChannelListServiceProvider.TYPE, YTChannelListServiceProvider)