def play_archive_utc(station_id, utc, askpin): logger.log.info('play archive: ' + station_id + 'utc: ' + utc) sl = skylink.Skylink(_user_name, _password, _profile, _provider) if askpin != 'False': pin_ok = utils.ask_for_pin(sl) if not pin_ok: xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem()) return try: info = utils.call( sl, lambda: sl.replay_info(locId_from_time(sl, station_id, utc))) except skylink.StreamNotResolvedException as e: xbmcgui.Dialog().ok(_addon.getAddonInfo('name'), _addon.getLocalizedString(e.id)) xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem()) return if info: is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm']) if is_helper.check_inputstream(): playitem = xbmcgui.ListItem(path=info['path']) playitem.setProperty('inputstreamaddon', is_helper.inputstream_addon) playitem.setProperty('inputstream.adaptive.manifest_type', info['protocol']) playitem.setProperty('inputstream.adaptive.license_type', info['drm']) playitem.setProperty('inputstream.adaptive.license_key', info['key']) playitem.setProperty('inputstream.adaptive.stream_headers', info['headers']) xbmcplugin.setResolvedUrl(_id, True, playitem)
def play(channel_id, askpin): logger.log.info('play: ' + channel_id) sl = skylink.Skylink(_user_name, _password, _profile, _provider) if askpin != 'False': pin_ok = utils.ask_for_pin(sl) if not pin_ok: xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem()) return try: info = utils.call(sl, lambda: sl.channel_info(channel_id)) except skylink.StreamNotResolvedException as e: xbmcgui.Dialog().ok(heading=_addon.getAddonInfo('name'), line1=_addon.getLocalizedString(e.id)) xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem()) return if info: is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm']) if is_helper.check_inputstream(): playitem = xbmcgui.ListItem(path=info['path']) if (_python3): # Python 3.x playitem.setProperty('inputstream', is_helper.inputstream_addon) else: # Python 2.5+ playitem.setProperty('inputstreamaddon', is_helper.inputstream_addon) playitem.setProperty('inputstream.adaptive.manifest_type', info['protocol']) playitem.setProperty('inputstream.adaptive.license_type', info['drm']) playitem.setProperty('inputstream.adaptive.license_key', info['key']) xbmcplugin.setResolvedUrl(_id, True, playitem)
def get_provider(accountid): account = get_account(accountid) if not account or not account.is_valid(): return None return skylink.Skylink(account)
def get_available_providers(): accounts = get_accounts() providers = [] for account in accounts: if not account.is_valid(): continue providers.append(skylink.Skylink(account)) return providers
if __name__ == '__main__': args = utils.parse_qs(sys.argv[2][1:]) if 'id' in args: play(str(args['id'][0]), str(args['askpin'][0]) if 'askpin' in args else 'False') elif ('stationid' in args) and ('catchup_id' in args): play_archive( str(args['stationid'][0]), str(args['catchup_id'][0]) if 'catchup_id' in args else None, str(args['askpin'][0]) if 'askpin' in args else 'False') elif 'replay' in args: replay.router( args, skylink.Skylink(_user_name, _password, _profile, _provider, _pin_protected_content)) elif 'live' in args: live.router( args, skylink.Skylink(_user_name, _password, _profile, _provider, _pin_protected_content)) elif 'library' in args: library.router( args, skylink.Skylink(_user_name, _password, _profile, _provider, _pin_protected_content)) else: xbmcplugin.setPluginCategory(_id, '') xbmcplugin.setContent(_id, 'videos') if _a_show_live: xbmcplugin.addDirectoryItem(
def update(self, try_reconnect=False): result = -1 _playlist_generate = 'true' == self._addon.getSetting( 'playlist_generate') _epg_generate = 'true' == self._addon.getSetting('epg_generate') if not _playlist_generate and not _epg_generate: return result _username = self._addon.getSetting('username') _password = self._addon.getSetting('password') _profile = xbmc.translatePath(self._addon.getAddonInfo('profile')) _provider = 'directone.hu' _pin_protected_content = 'false' != self._addon.getSetting( 'pin_protected_content') sl = skylink.Skylink(_username, _password, _profile, _provider, _pin_protected_content) logger.log.info('SL created') try: channels = sl.channels() except skylink.TooManyDevicesException as e: if self._addon.getSetting('reuse_last_device') == 'true': device = utils.get_last_used_device(e.devices) else: device = utils.select_device( e.devices) if try_reconnect else '' if device != '': logger.log.info('reconnecting as: ' + device) sl.reconnect(device) channels = sl.channels() else: raise if _playlist_generate: try: path = os.path.join(self._addon.getSetting('playlist_folder'), self._addon.getSetting('playlist_file')) _skylink_logos = 'true' == self._addon.getSetting('sl_logos') logger.log.info('Updating playlist [%d channels]' % len(channels)) exports.create_m3u(channels, path, sl._api_url if _skylink_logos else None) result = 1 except IOError as e: logger.log.error(str(e)) raise skylink.SkylinkException(30503) if _epg_generate: try: days = int(self._addon.getSetting('epg_days')) catchup_days = int(self._addon.getSetting('epg_days_catchup')) today = datetime.datetime.now() epgFrom = today - datetime.timedelta( days=catchup_days) if catchup_days > 0 else today epgTo = today + datetime.timedelta(days=days) path = os.path.join(self._addon.getSetting('epp_folder'), self._addon.getSetting('epg_file')) logger.log.info('Updating EPG [from %s to %s]' % (epgFrom, epgTo)) exports.create_epg(channels, sl.epg(channels, epgFrom, epgTo), path) result = 2 except IOError as e: logger.log.error(str(e)) raise skylink.SkylinkException(30504) return result