tubelib: set eServiceReference isLive for channel list services
[enigma2-plugins.git] / tubelib / src / twitch / TwitchChannelListServiceProvider.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 TwitchChannelListServiceProvider(ChannelListServiceProviderBase):
8         TYPE = "twitch"
9         DESCRIPTION = _("twitch.tv Live Channel")
10
11         def _createServiceForChannelList(self):
12                 self._addTwitchService()
13
14         def _addTwitchService(self):
15                 self._session.openWithCallback(self._onTwitchChannel, InputBox, title=_("Please provide a Twitch Channel-/Username"), windowTitle=_("Twitch Channel/User"))
16
17         def _onTwitchChannel(self, data):
18                 if data:
19                         self._tubeUri = "tw://%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(TwitchChannelListServiceProvider.TYPE, TwitchChannelListServiceProvider)