def PlayVideo(channel, filename=None, folder=None, recorded=None, audioid=None, onnow=False): Log('Entering PlayVideo channel={} filename={} folder={} recorded={} audioid={}' .format(channel, filename, folder, recorded, audioid)) import time from enigma2 import format_string, zap if (Prefs['singletuner']): zapped = zap(Prefs['host'], Prefs['port_web'], sRef=channel) if channel: channel = channel.strip('.m3u8') if Prefs['zap'] and not recorded: Log('Changing Audio to {}'.format(audioid)) zapaudio(channel, audioid) if recorded == 'False': stream = 'http://{}:{}/{}'.format(Prefs['host'], Prefs['port_video'], channel) Log('Stream to play {}'.format(stream)) else: folder = folder.replace( '\\', '/') # required to make correct path for subfolders Log('channel={} filename={}'.format( format_string(folder, clean_file=True), filename)) filename = format_string(filename, clean_file=True) if filename[:3] != 'hdd': filename = 'hdd/movie/{}/'.format(folder) + filename stream = 'http://{}:{}/file?file=/{}'.format(Prefs['host'], Prefs['port_web'], filename) Log('Recorded file to play {}'.format(stream)) return Redirect(stream)
def Display_Channel_Events(sender, sRef, title=None): Log('Entered DisplayChannelEvents function sender={} sRef={} title={}'.format(sender, sRef, title)) import time from enigma2 import zap, get_number_of_audio_tracks items = [] for id, start, duration, current_time, title, description, sRef, name in get_events(title, sRef): remaining = calculate_remaining(start, int(duration), current_time) if int(start) < time.time(): result=None if Prefs['zap'] :#and Prefs['audio'] : zapped = zap(Prefs['host'],Prefs['port_web'], sRef=sRef) Log('Zapped is {}'.format(zapped[0])) if zapped[0]: result = check_and_display_audio(name=name, title=title, sRef=sRef, description=description, remaining=remaining) else: Log('Not zapped for some reason') else: items.append(add_current_event(sRef, name, title, description, remaining=remaining, piconfile=picon(sRef))) if title == 'N/A': title = 'Unknown' if result: items.append(result) items = check_empty_items(items) oc = ObjectContainer(objects=items, title2=sender, view_group='List', no_cache=True) return oc
def ResetReceiver(): Log('Entered ResetReceiver function') from enigma2 import zap zap, error = zap(Prefs['host'], Prefs['port_web'], Data.Load('sRef')) Log(error) if zap: message = 'Zapped to channel to reset receiver' Log(message) else: message = "Couldn't zap to channel resetting receiver" Log(message) return ObjectContainer(title2='Reset Receiver', no_cache=False, header='Reset receiver', message=message)
def zapaudio(channel=None, audioid=None): from enigma2 import zap, set_audio_track if not audioid: #if we have no audio id then we just zap zap = zap(Prefs['host'], Prefs['port_web'], channel) if zap: Log('Zapped to channel when playing video') else: Log("Couldn't zap to channel when playing video") else: #switch audio. Already zapped to get audioid, or on current channel zap = zap(Prefs['host'], Prefs['port_web'], channel) import time time.sleep(2) audio = set_audio_track(Prefs['host'], Prefs['port_web'], audioid) Log('Audio returned from enigma2 module {}'.format(audio)) time.sleep(2) if audio: Log('Changed Audio to channel {}'.format(audioid)) else: Log("Unable to change audio")
def zapaudio( channel=None, audioid=None): from enigma2 import zap, set_audio_track if not audioid: #if we have no audio id then we just zap zap = zap(Prefs['host'], Prefs['port_web'], channel) if zap: Log('Zapped to channel when playing video') else: Log("Couldn't zap to channel when playing video") else: #switch audio. Already zapped to get audioid, or on current channel zap = zap(Prefs['host'], Prefs['port_web'], channel) import time time.sleep(2) audio = set_audio_track(Prefs['host'], Prefs['port_web'], audioid) Log('Audio returned from enigma2 module {}'.format(audio)) time.sleep(2) if audio: Log('Changed Audio to channel {}'.format(audioid)) else: Log("Unable to change audio")
def Display_Audio_Events(sender, sRef, title=None, description=None, onnow=False): import time from enigma2 import get_audio_tracks, zap Log('Entered display Audio events: sender {} sref {} title {}'.format(sender, sRef, title)) items = [] zapped = True if not onnow: zapped = zap(Prefs['host'], Prefs['port_web'], sRef=sRef) if zapped: time.sleep(2) for audio_id, audio_description, active in get_audio_tracks(Prefs['host'],Prefs['port_web']): remaining = 0 items.append(add_current_event(sRef=sRef, name=sender, description=description, title=title, remaining=0, audioid=audio_id, audio_description=audio_description)) items = check_empty_items(items) oc = ObjectContainer(objects=items, title2='Select Audio Channel', view_group='List', no_cache=True) return oc
def Display_Channel_Events(sender, sRef, title=None): Log('Entered DisplayChannelEvents function sender={} sRef={} title={}'.format(sender, sRef, title)) import time from enigma2 import zap, get_number_of_audio_tracks items = [] for id, start, duration, current_time, title, description, sRef, name in get_events(title, sRef): remaining = calculate_remaining(start, int(duration), current_time) if int(start) < time.time(): result=None if Prefs['zap'] :#and Prefs['audio'] : zapped = zap(Prefs['host'],Prefs['port_web'], sRef=sRef) Log('Zapped is {}'.format(zapped[0])) if zapped[0]: result = check_and_display_audio(name=name, title=title, sRef=sRef, description=description, remaining=remaining) else: Log('Not zapped for some reason') else: items.append(add_current_event(sRef, name, title, description, remaining=remaining, piconfile=picon(sRef))) if title == 'N/A': title = 'Unknown' if result: items.append(result) #Add a future \ next event elif start > 0: pass items.append(DirectoryObject(key=Callback(AddTimer, title=title, name=name, sRef=sRef, eventid=id), title=title, duration = remaining, thumb=Callback(GetThumb, series=title))) items = check_empty_items(items) oc = ObjectContainer(objects=items, title2=sender, view_group='List', no_cache=True) return oc
def PlayVideo(channel, filename=None, folder=None, recorded=None, audioid=None, onnow=False): Log('Entering PlayVideo channel={} filename={} folder={} recorded={} audioid={}'.format(channel, filename, folder, recorded, audioid)) import time from enigma2 import format_string, zap if(Prefs['singletuner']): zapped = zap(Prefs['host'], Prefs['port_web'], sRef=channel) if channel: channel = channel.strip('.m3u8') if Prefs['zap'] and not recorded: Log('Changing Audio to {}'.format(audioid)) zapaudio(channel, audioid) if recorded == 'False': stream = 'http://{}:{}/{}'.format(Prefs['host'], Prefs['port_video'], channel) Log('Stream to play {}'.format(stream)) else: folder = folder.replace('\\', '/') # required to make correct path for subfolders Log('channel={} filename={}'.format(format_string(folder,clean_file=True), filename)) filename = format_string(filename, clean_file=True) if filename[:3] != 'hdd': filename= 'hdd/movie/{}/'.format(folder) + filename stream = 'http://{}:{}/file?file=/{}'.format(Prefs['host'], Prefs['port_web'], filename) Log('Recorded file to play {}'.format(stream)) return Redirect(stream)