def watch_channel(channel_id, start, end): #print('WATCH: '+channel_id+' st:'+str(start)+' en:'+str(end)) #new ZattooDB instance because this is called from thread-timer on channel-nr input (sql connection doesn't work) _zattooDB_=ZattooDB() #selected currently playing live TV playing=_zattooDB_.get_playing() if (xbmc.Player().isPlaying() and channel_id == playing['channel'] and start=='0' and str(playing['start'])=='1970-01-01 01:00:00'): xbmc.executebuiltin("Action(FullScreen)") makeZattooGUI() return #save current channel for toggle xbmcgui.Window(10000).setProperty('ZBElastChannel', playing['channel']) # (64 150 300) 600 900 1500 3000 5000 max_bandwidth = __addon__.getSetting('max_bandwidth') if start == '0': params = {'cid': channel_id, 'stream_type': 'hls', 'maxrate':max_bandwidth} else: zStart = datetime.datetime.fromtimestamp(int(start) - _timezone_ ).strftime("%Y-%m-%dT%H:%M:%SZ") #5min zattoo skips back zEnd = datetime.datetime.fromtimestamp(int(end) - _timezone_ ).strftime("%Y-%m-%dT%H:%M:%SZ") params = {'cid': channel_id, 'stream_type': 'hls', 'start':zStart, 'end':zEnd, 'maxrate':max_bandwidth } channelInfo = _zattooDB_.get_channelInfo(channel_id) resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/watch',params) if resultData is None: xbmcgui.Dialog().notification("ERROR", "NO ZAPI RESULT", channelInfo['logo'], 5000, False) return streams = resultData['stream']['watch_urls'] if len(streams)==0: xbmcgui.Dialog().notification("ERROR", "NO STREAM FOUND, CHECK SETTINGS!", channelInfo['logo'], 5000, False) return # change stream if settings are set streamNr = 0 if len(streams) > 1 and __addon__.getSetting('audio_stream') == 'B' and streams[1]['audio_channel'] == 'B': streamNr = 1 #play liveTV: info is created in OSD if (start=='0'): xbmc.Player().play(streams[streamNr]['url'], xbmcgui.ListItem(channel_id)) xbmcgui.Window(10000).setProperty('playstream', streams[streamNr]['url']) #12005:fullscreenvideo #if (xbmcgui.getCurrentWindowId()!=12005):xbmc.executebuiltin("Action(FullScreen)") # save currently playing streamsList = [] for stream in resultData['stream']['watch_urls']: streamsList.append(stream['url']) streamsList = '|'.join(streamsList) _zattooDB_.set_playing(channel_id, start, streamsList, streamNr) #make Info if start == '0':startTime = datetime.datetime.now() else: startTime = datetime.datetime.fromtimestamp(int(start)) if end == '0': endTime = datetime.datetime.now() else: endTime = datetime.datetime.fromtimestamp(int(end)) program = _zattooDB_.getPrograms({channel_id:''}, True, startTime, endTime) listitem = xbmcgui.ListItem(channel_id) if program: program = program[0] heading = ('[B]' + channelInfo['title'] + '[/B] ').translate(_umlaut_) + ' ' + program['start_date'].strftime('%H:%M') + '-' + program['end_date'].strftime('%H:%M') xbmcgui.Dialog().notification(heading, program['title'].translate(_umlaut_), channelInfo['logo'], 5000, False) #set info for recall listitem.setThumbnailImage(program['image_small']) meta = {'title': program['title'], 'season' : 'S', 'episode': streamNr, 'tvshowtitle': channelInfo['title']+ ', ' + program['start_date'].strftime('%A %H:%M') + '-' + program['end_date'].strftime('%H:%M'), 'premiered' :'premiered', 'duration' : '20', 'rating': 'rating', 'director': 'director', 'writer': 'writer', 'plot': program['description_long']} listitem.setInfo(type="Video", infoLabels = meta) listitem.setArt({ 'poster': program['image_small'], 'logo' : channelInfo['logo'] }) #play recall if (start!='0'): player= myPlayer(True) player.play(streams[streamNr]['url'], listitem) while (player.starting):xbmc.sleep(10) #wait for player to skip 5min on recall else: makeZattooGUI() #liveTV: intercept keys and show OSD
def watch_channel(channel_id, start, end, showID="", restart=False, showOSD=False): #print('WATCH: '+channel_id+' st:'+str(start)+' en:'+str(end)) #new ZattooDB instance because this is called from thread-timer on channel-nr input (sql connection doesn't work) _zattooDB_ = ZattooDB() #selected currently playing live TV playing = _zattooDB_.get_playing() if (xbmc.Player().isPlaying() and channel_id == playing['channel'] and start == '0'): xbmc.executebuiltin("Action(FullScreen)") return # (64 150 300) 600 900 1500 3000 5000 max_bandwidth = __addon__.getSetting('max_bandwidth') if DASH: stream_type = 'dash' else: stream_type = 'hls' if restart: startTime = datetime.datetime.fromtimestamp(int(start)) endTime = datetime.datetime.fromtimestamp(int(end)) params = {'stream_type': stream_type, 'maxrate': max_bandwidth} elif start == '0': startTime = datetime.datetime.now() endTime = datetime.datetime.now() params = { 'cid': channel_id, 'stream_type': stream_type, 'maxrate': max_bandwidth } else: startTime = datetime.datetime.fromtimestamp(int(start)) endTime = datetime.datetime.fromtimestamp(int(end)) zStart = datetime.datetime.fromtimestamp( int(start) - _timezone_).strftime( "%Y-%m-%dT%H:%M:%SZ") #5min zattoo skips back zEnd = datetime.datetime.fromtimestamp(int(end) - _timezone_).strftime( "%Y-%m-%dT%H:%M:%SZ") params = { 'cid': channel_id, 'stream_type': stream_type, 'start': zStart, 'end': zEnd, 'maxrate': max_bandwidth } #print "RECALL: " +str(zStart) + " " + str(startTime) + " " +str(_timezone_) channelInfo = _zattooDB_.get_channelInfo(channel_id) if restart: resultData = _zattooDB_.zapi.exec_zapiCall( '/zapi/watch/selective_recall/' + channel_id + '/' + showID, params) else: resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/watch', params) #resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/watch',params) #print 'ResultData ' +str(resultData) if resultData is None: xbmcgui.Dialog().notification("ERROR", "NO ZAPI RESULT", channelInfo['logo'], 5000, False) return streams = resultData['stream']['watch_urls'] if len(streams) == 0: xbmcgui.Dialog().notification("ERROR", "NO STREAM FOUND, CHECK SETTINGS!", channelInfo['logo'], 5000, False) return # change stream if settings are set streamNr = 0 if len(streams) > 1 and __addon__.getSetting( 'audio_stream') == 'B' and streams[1]['audio_channel'] == 'B': streamNr = 1 xbmcgui.Window(10000).setProperty('playstream', streams[streamNr]['url']) # save currently playing streamsList = [] for stream in resultData['stream']['watch_urls']: streamsList.append(stream['url']) streamsList = '|'.join(streamsList) _zattooDB_.set_playing(channel_id, streamsList, streamNr) #make Info program = _zattooDB_.getPrograms({'index': [channel_id]}, True, startTime, endTime) listitem = xbmcgui.ListItem(channel_id) if program: program = program[0] heading = ('[B]' + channelInfo['title'] + '[/B] ').translate( _umlaut_) + ' ' + program['start_date'].strftime( '%H:%M') + '-' + program['end_date'].strftime('%H:%M') xbmcgui.Dialog().notification(heading, program['title'].translate(_umlaut_), channelInfo['logo'], 5000, False) #set info for recall listitem.setThumbnailImage(program['image_small']) meta = { 'title': program['title'], 'season': 'S', 'episode': streamNr, 'tvshowtitle': channelInfo['title'] + ', ' + program['start_date'].strftime('%A %H:%M') + '-' + program['end_date'].strftime('%H:%M'), 'premiered': 'premiered', 'duration': '20', 'rating': 'rating', 'director': 'director', 'writer': 'writer', 'plot': program['description_long'] } listitem.setInfo(type="Video", infoLabels=meta) listitem.setArt({ 'poster': program['image_small'], 'logo': channelInfo['logo'] }) if DASH: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') #play liveTV: info is created in OSD if (start == '0'): _zattooDB_ = ZattooDB() channelList = _zattooDB_.getChannelList(_listMode_ == 'favourites') #print "ChannelList: " + str(channelList) currentChannel = _zattooDB_.get_playing()['channel'] nr = channelList[currentChannel]['nr'] player = xbmc.Player() #player.startTime=startTime player.play(streams[streamNr]['url'], listitem) #while (player.playing):xbmc.sleep(100) show_channelNr(nr + 1) else: #player= myPlayer(290) player = xbmc.Player() player.startTime = startTime player.play(streams[streamNr]['url'], listitem) while (player.playing): xbmc.sleep(100)
def watch_channel(channel_id, start, end, showID="", restart=False): #print('WATCH: '+channel_id+' st:'+str(start)+' en:'+str(end)) #new ZattooDB instance because this is called from thread-timer on channel-nr input (sql connection doesn't work) _zattooDB_=ZattooDB() #selected currently playing live TV playing=_zattooDB_.get_playing() if (xbmc.Player().isPlaying() and channel_id == playing['channel'] and start=='0' ): xbmc.executebuiltin("Action(FullScreen)") makeZattooGUI() return #save current channel for toggle xbmcgui.Window(10000).setProperty('ZBElastChannel', playing['channel']) # (64 150 300) 600 900 1500 3000 5000 max_bandwidth = __addon__.getSetting('max_bandwidth') if restart: params = {'stream_type': 'hls'} elif start == '0': params = {'cid': channel_id, 'stream_type': 'hls', 'maxrate':max_bandwidth} else: zStart = datetime.datetime.fromtimestamp(int(start) - _timezone_ ).strftime("%Y-%m-%dT%H:%M:%SZ") #5min zattoo skips back zEnd = datetime.datetime.fromtimestamp(int(end) - _timezone_ ).strftime("%Y-%m-%dT%H:%M:%SZ") params = {'cid': channel_id, 'stream_type': 'hls', 'start':zStart, 'end':zEnd, 'maxrate':max_bandwidth } channelInfo = _zattooDB_.get_channelInfo(channel_id) if restart: resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/watch/selective_recall/'+channel_id+'/'+showID, params) else: resultData = _zattooDB_.zapi.exec_zapiCall('/zapi/watch',params) print 'ResultData ' +str(params) if resultData is None: xbmcgui.Dialog().notification("ERROR", "NO ZAPI RESULT", channelInfo['logo'], 5000, False) return streams = resultData['stream']['watch_urls'] if len(streams)==0: xbmcgui.Dialog().notification("ERROR", "NO STREAM FOUND, CHECK SETTINGS!", channelInfo['logo'], 5000, False) return # change stream if settings are set streamNr = 0 if len(streams) > 1 and __addon__.getSetting('audio_stream') == 'B' and streams[1]['audio_channel'] == 'B': streamNr = 1 #play liveTV: info is created in OSD if (start=='0'): xbmc.Player().play(streams[streamNr]['url'], xbmcgui.ListItem(channel_id)) xbmcgui.Window(10000).setProperty('playstream', streams[streamNr]['url']) #12005:fullscreenvideo #if (xbmcgui.getCurrentWindowId()!=12005):xbmc.executebuiltin("Action(FullScreen)") # save currently playing streamsList = [] for stream in resultData['stream']['watch_urls']: streamsList.append(stream['url']) streamsList = '|'.join(streamsList) _zattooDB_.set_playing(channel_id, streamsList, streamNr) #make Info if start == '0':startTime = datetime.datetime.now() else: startTime = datetime.datetime.fromtimestamp(int(start)) if end == '0': endTime = datetime.datetime.now() else: endTime = datetime.datetime.fromtimestamp(int(end)) program = _zattooDB_.getPrograms({'index':[channel_id]}, True, startTime, endTime) listitem = xbmcgui.ListItem(channel_id) if program: program = program[0] heading = ('[B]' + channelInfo['title'] + '[/B] ').translate(_umlaut_) + ' ' + program['start_date'].strftime('%H:%M') + '-' + program['end_date'].strftime('%H:%M') xbmcgui.Dialog().notification(heading, program['title'].translate(_umlaut_), channelInfo['logo'], 5000, False) #set info for recall listitem.setThumbnailImage(program['image_small']) meta = {'title': program['title'], 'season' : 'S', 'episode': streamNr, 'tvshowtitle': channelInfo['title']+ ', ' + program['start_date'].strftime('%A %H:%M') + '-' + program['end_date'].strftime('%H:%M'), 'premiered' :'premiered', 'duration' : '20', 'rating': 'rating', 'director': 'director', 'writer': 'writer', 'plot': program['description_long']} listitem.setInfo(type="Video", infoLabels = meta) listitem.setArt({ 'poster': program['image_small'], 'logo' : channelInfo['logo'] }) #play recall if (start!='0') or restart: player= myPlayer(True) player.play(streams[streamNr]['url'], listitem) while (player.starting):xbmc.sleep(10) #wait for player to skip 5min on recall else: makeZattooGUI() #liveTV: intercept keys and show OSD