def get_recordingcopies_list_item(archive, recording): if not 'copies' in recording: return for copy in recording['copies'].keys(): li = xbmcgui.ListItem( "%s %s" % (_('local copy:'), recording['copies'][copy]['name']), '', archive.getImageUrl(recording['epgid'], recording['icon_image']), archive.getImageUrl(recording['epgid'], recording['thumbnail_image']) ) contextmenueitems = [tuple(( _('play'), "PlayWith()" )), tuple(( _('delete'), "XBMC.RunPlugin(\"%s\")" % call.format('/deletelocalcopies', params={'file': recording['copies'][copy]['file']}) )), tuple(( _('userinfo'), "XBMC.RunPlugin(\"%s\")" % call.format('/userinfo') ))] li.addContextMenuItems(contextmenueitems, replaceItems=True ) yield [ recording['copies'][copy]['file'], li, False, ]
def _createDir(self, subs): """ dir listing fuer uebersichten erzeugen @param subs: listenelemente @type subs: list """ listing = [] for element in subs: li = xbmcgui.ListItem( label=_(element) ) if element == 'recordings': li.addContextMenuItems( [ ( _('refresh listing'), "XBMC.RunPlugin(\"%s\")" % call.format('/refreshlisting') ), ( _('userinfo'), "XBMC.RunPlugin(%s)" % call.format('userinfo') ), ], replaceItems=True ) else: li.addContextMenuItems( [ ( _('refresh listing'), "Container.Refresh" ), ( _('userinfo'), "XBMC.RunPlugin(%s)" % call.format('userinfo') ), ], replaceItems=True ) listing.append( [ call.format(element), li, True] ) return listing
def get_recording_list_item(archive, recording): li = xbmcgui.ListItem( recording['label'], recording['filename'], archive.getImageUrl(recording['epgid'], recording['icon_image']), archive.getImageUrl(recording['epgid'], recording['thumbnail_image']) ) contextmenueitems = [tuple(( _('delete local copies'), "XBMC.RunPlugin(\"%s\")" % call.format('/deletelocalcopies', params={'epgid': recording['epgid']}) )), tuple(( _('delete'), "XBMC.RunPlugin(\"%s\")" % call.format('/deletejob', params={'epgid': recording['epgid']}) )), tuple(( _('refresh listing'), "XBMC.RunPlugin(\"%s\")" % call.format('/refreshlisting', params={'epgid': recording['epgid']}) )), tuple(( _('userinfo'), "XBMC.RunPlugin(\"%s\")" % call.format('/userinfo') ))] li.addContextMenuItems(contextmenueitems, replaceItems=True ) infos = dict( filter( lambda r: r[0] in ['duration', 'title', 'studio', 'date', 'plot'], recording.items() ) ) li.setInfo('video', infos) return [ call.format(params={ 'epgid': recording['epgid'] }), li, True ]
def get_recordingstreams_list_item(archive, recording): if not 'streams' in recording: return list = recording['streams'].keys() list.sort() for stream in list: li = xbmcgui.ListItem( "%s %s" % (_('stream:'), recording['streams'][stream]['name']), recording['streams'][stream]['type'], archive.getImageUrl(recording['epgid'], recording['icon_image']), archive.getImageUrl(recording['epgid'], recording['thumbnail_image'])) contextmenueitems = [] contextmenueitems.append(tuple((_('play'), "PlayWith()"))) if 'copies' in recording: if not str(recording['streams'][stream]['file'].split( '/').pop()) in recording['copies']: contextmenueitems.append( tuple( (_('download'), "XBMC.RunPlugin(\"%s\")" % call.format( '/download', params={ 'url': recording['streams'][stream]['file'], 'epgid': recording['epgid'], 'name': recording['streams'][stream]['name'] })))) contextmenueitems.append( tuple( (_('userinfo'), "XBMC.RunPlugin(\"%s\")" % call.format('/userinfo')))) li.addContextMenuItems(contextmenueitems, replaceItems=True) yield [ call.format('/play', params={ 'url': recording['streams'][stream]['file'], 'epgid': recording['epgid'] }), li, False, ]
def _createPastHightlightsList(self, otr): """ get past hightlights @param otr: OtrHandler @type otr: OtrHandler Instanz """ items = getKey(otr.getPastHighlightsDict(), 'channel', 'item') or [] listing = [] for item in items: thumbnail = getKey(item, '{http://search.yahoo.com/mrss/}thumbnail', 'url') title = item['title'] li = xbmcgui.ListItem( label=title, iconImage=thumbnail or None, thumbnailImage=thumbnail or None ) description = getKey(item, 'description') if description: description = __common__.stripTags(description) description = description.replace('Informationen und Screnshots', '') description = description.replace('Zum Download', '') li.setInfo('video', {'plot' : description, 'title': title }) li.addContextMenuItems([], replaceItems=True ) listing.append( [call.format('/schedulejob', {'epgid':item['epg_id']}), li, False] ) return listing
def _createSearchList(self, otr, future=False): """ search for recordings @param otr: OtrHandler @type otr: OtrHandler Instanz """ listing = [] searchstring = __common__.getUserInput(_('search'), False) if searchstring: for show in getKey(otr.getSearchListDict(searchstring, future=future), 'SHOW') or []: #noinspection PyBroadException try: duration = (int(show['END']) - int(show['BEGIN'])) / 60 except Exception: duration = False elementname = "" elementname += "%s: " % show['STATION'] elementname += "%s" % show['TITLE'] elementname += " (" elementname += "%s" % (show['NICEBEGIN']) if duration: elementname += ", %s min" % duration elementname += ")" li = xbmcgui.ListItem( label=elementname ) li.addContextMenuItems([], replaceItems=True ) listing.append( [call.format('/schedulejob', {'epgid':show['EPGID']}), li, False] ) return listing
def get_recordingstreams_list_item(archive, recording): if not 'streams' in recording: return list = recording['streams'].keys() list.sort() for stream in list: li = xbmcgui.ListItem( "%s %s" % (_('stream:'), recording['streams'][stream]['name']), recording['streams'][stream]['type'], archive.getImageUrl(recording['epgid'], recording['icon_image']), archive.getImageUrl(recording['epgid'], recording['thumbnail_image']) ) contextmenueitems = [] contextmenueitems.append( tuple(( _('play'), "PlayWith()" ))) if 'copies' in recording: if not str(recording['streams'][stream]['file'].split('/').pop()) in recording['copies']: contextmenueitems.append( tuple(( _('download'), "XBMC.RunPlugin(\"%s\")" % call.format('/download', params={ 'url': recording['streams'][stream]['file'], 'epgid': recording['epgid'], 'name': recording['streams'][stream]['name'] }) )) ) contextmenueitems.append( tuple(( _('userinfo'), "XBMC.RunPlugin(\"%s\")" % call.format('/userinfo') )) ) li.addContextMenuItems(contextmenueitems, replaceItems=True ) yield [ call.format('/play', params={ 'url': recording['streams'][stream]['file'], 'epgid': recording['epgid']}), li, False, ]
def _createProgrammList(self, otr): def getStationThumburl(station): url = "http://static.onlinetvrecorder.com/images/easy/stationlogos/%s.gif" return url % urllib.quote(station.lower()) listing = [] thisweek = datetime.datetime.now() thisweek = thisweek - datetime.timedelta(days=thisweek.weekday()) if not 'week' in call.params and not 'day' in call.params: # wochenliste thisweek = datetime.datetime.now() thisweek = thisweek - datetime.timedelta(days=thisweek.weekday()) for weekdelta in range(-4, 0): weekstart = thisweek+datetime.timedelta(weeks=weekdelta) weekstring = " -" + _(weekdelta<-1 and "%s weeks" or "%s week") % str(weekdelta*-1) month_start_name = _(weekstart.date().strftime("%B")) month_end_name = _((weekstart.date()+datetime.timedelta(days=6)).strftime("%B")) weekstring += u" (%s - %s)" % ( weekstart.date().strftime("%d. ") + month_start_name + weekstart.date().strftime(" %Y"), (weekstart.date()+datetime.timedelta(days=6)).strftime("%d. ") + month_end_name + (weekstart.date()+datetime.timedelta(days=6)).strftime(" %Y") ) listitem = xbmcgui.ListItem(label=weekstring) listitem.addContextMenuItems([], replaceItems=True ) listing.append( [ call.format(params={'week':weekdelta}, update=True), listitem, True] ) if not 'day' in call.params: # tagesliste weekstart = thisweek+datetime.timedelta(weeks=int( 'week' in call.params and call.params['week'] or 0)) for day in range(7): singleday = weekstart + datetime.timedelta(days=day) weekday_name = _(singleday.date().strftime("%A")) month_name = _(singleday.date().strftime("%B")) stringdate=weekday_name + " (%d. " + month_name + " %Y)" stringdate=unicode(stringdate).encode("utf-8") listitem = xbmcgui.ListItem(label=singleday.date().strftime(stringdate)) contextmenueitems = [tuple(( _('show all channels'), "Container.Update(%s,True)" % call.format(params={'showall': True}, update=True) ))] listitem.addContextMenuItems(contextmenueitems, replaceItems=True ) if singleday.date() == datetime.date.today(): listitem.select(True) listing.append( [ call.format(params={'day': int(time.mktime(singleday.timetuple()))}, update=True), listitem, True] ) if not 'week' in call.params and not 'day' in call.params: # wochenliste for weekdelta in range(1, 5): weekstart = thisweek+datetime.timedelta(weeks=weekdelta) weekstring = " +" + _(weekdelta>1 and "%s weeks" or "%s week") % str(weekdelta) month_start_name = _(weekstart.date().strftime("%B")) month_end_name = _((weekstart.date()+datetime.timedelta(days=6)).strftime("%B")) weekstring += u" (%s - %s)" % ( weekstart.date().strftime("%d. ") + month_start_name + weekstart.date().strftime(" %Y"), (weekstart.date()+datetime.timedelta(days=6)).strftime("%d. ") + month_end_name + (weekstart.date()+datetime.timedelta(days=6)).strftime(" %Y") ) listitem = xbmcgui.ListItem(label=weekstring) listitem.addContextMenuItems([], replaceItems=True ) listing.append( [ call.format(params={'week':weekdelta}, update=True), listitem, True] ) if not 'day' in call.params: return listing if not 'channel' in call.params: # kanalliste hidden_chan = __addon__.getSetting('otrChannelsHidden').split(',') hidden_lang = __addon__.getSetting('otrLanguagesHidden').split(',') if getKey(call.params, 'hidechannel'): hidden_chan.append(getKey(call.params, 'hidechannel')) __addon__.setSetting('otrChannelsHidden', ','.join(hidden_chan).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'unhidechannel'): name = getKey(call.params, 'unhidechannel') if name in hidden_chan: hidden_chan.remove(name) __addon__.setSetting('otrChannelsHidden', ','.join(hidden_chan).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'hidelanguage'): hidden_lang.append(getKey(call.params, 'hidelanguage')) __addon__.setSetting('otrLanguagesHidden', ','.join(hidden_lang).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'unhidelanguage'): name = getKey(call.params, 'unhidelanguage') if name in hidden_lang: hidden_lang.remove(name) __addon__.setSetting('otrLanguagesHidden', ','.join(hidden_lang).strip(',')) xbmc.executebuiltin("Container.Refresh") channels = otr.getChannelsDict() keys = channels.keys() keys.sort() for key in keys: language = channels[key]['LANGUAGE'] contextmenueitems = [] if not ('showall' in call.params and call.params['showall'] == 'True'): if language in hidden_lang: continue if key in hidden_chan: continue showall = False hiddenitem = False else: hiddenitem = False if language in hidden_lang: hiddenitem = True if key in hidden_chan: hiddenitem = True showall = True if not hiddenitem: contextmenueitems.append ( tuple(( _('hide channel (%s)') % key, "XBMC.RunPlugin(%s)" % call.format(params={'hidechannel': key}, update=True), )) ) if hiddenitem and key in hidden_chan: contextmenueitems.append ( tuple(( _('unhide channel (%s)') % key, "XBMC.RunPlugin(%s)" % call.format(params={'unhidechannel': key}, update=True), )) ) if not hiddenitem: contextmenueitems.append ( tuple(( _('hide language (%s)') % language, "XBMC.RunPlugin(%s)" % call.format(params={'hidelanguage': language}, update=True), )) ) if hiddenitem and language in hidden_lang: contextmenueitems.append ( tuple(( _('unhide language (%s)') % language, "XBMC.RunPlugin(%s)" % call.format(params={'unhidelanguage': language}, update=True), )) ) if not showall: contextmenueitems.append ( tuple(( _('show all channels'), "Container.Update(%s,True)" % call.format(params={'showall': True}, update=True) )) ) li = xbmcgui.ListItem(label=key, iconImage=getStationThumburl(key)) li.addContextMenuItems(contextmenueitems, replaceItems=True ) if hiddenitem: li.select(True) listing.append( [ call.format(params={'channel': key}, update=True), li, True] ) return listing if 'day' in call.params and 'channel' in call.params: selected_daystamp = int(call.params['day']) selected_day = datetime.datetime.fromtimestamp(selected_daystamp).date() selected_channel = call.params['channel'] entries = otr.getChannelListingDict([selected_channel], selected_day, selected_day) or [] entries = getKey(entries, 'ITEM') or [] listing.append( [ call.format(params={'day': str(selected_daystamp-86400)}, update=True), xbmcgui.ListItem(label=_('day before')), True] ) for entry in entries: title = urllib.unquote_plus(entry['TITEL']) attribs = [] if 'NICEDATE' in entry: attribs.append(entry['NICEDATE']) title += " (%s)" % ', '.join(attribs) info = {} if 'NICEDATE' in entry and entry['NICEDATE']: info['date'] = entry['NICEDATE'] if 'TYP' in entry and entry['TYP']: info['genre'] = urllib.unquote_plus(entry['TYP']) if 'TEXT' in entry and entry['TEXT']: info['plot'] = urllib.unquote_plus(entry['TEXT']) if 'RATING' in entry and entry['RATING']: info['rating'] = int(entry['RATING']) if 'PROGRAMMINGS' in entry and entry['PROGRAMMINGS']: info['playcount'] = int(entry['PROGRAMMINGS']) if 'DAUER' in entry and entry['DAUER']: info['duration'] = entry['DAUER'] if 'FSK' in entry and entry['FSK']: info['mpaa'] = urllib.unquote_plus(entry['FSK']) li = xbmcgui.ListItem(label=title) li.setInfo('video', info) if 'HIGHLIGHT' in entry and entry['HIGHLIGHT'] and int(entry['HIGHLIGHT'])>0: li.select(True) listing.append( [call.format('/schedulejob', {'epgid':entry['ID']}), li, False] ) listing.append( [ call.format(params={'day': str(selected_daystamp+86400)}, update=True), xbmcgui.ListItem(label=_('day after')), True] ) return listing return None
def _createProgrammList(self, otr): def getStationThumburl(station): url = "http://static.onlinetvrecorder.com/images/easy/stationlogos/%s.gif" return url % urllib.quote(station.lower()) listing = [] thisweek = datetime.datetime.now() thisweek = thisweek - datetime.timedelta(days=thisweek.weekday()) if not 'week' in call.params and not 'day' in call.params: # wochenliste thisweek = datetime.datetime.now() thisweek = thisweek - datetime.timedelta(days=thisweek.weekday()) for weekdelta in range(-4, 0): weekstart = thisweek+datetime.timedelta(weeks=weekdelta) weekstring = " -" + _(weekdelta<-1 and "%s weeks" or "%s week") % str(weekdelta*-1) month_start_name = _(weekstart.date().strftime("%B")) month_end_name = _((weekstart.date()+datetime.timedelta(days=6)).strftime("%B")) weekstring += u" (%s - %s)" % ( weekstart.date().strftime("%d. ") + month_start_name + weekstart.date().strftime(" %Y"), (weekstart.date()+datetime.timedelta(days=6)).strftime("%d. ") + month_end_name + (weekstart.date()+datetime.timedelta(days=6)).strftime(" %Y") ) listitem = xbmcgui.ListItem(label=weekstring) listitem.addContextMenuItems([], replaceItems=True ) listing.append( [ call.format(params={'week':weekdelta}, update=True), listitem, True] ) if not 'day' in call.params: # tagesliste weekstart = thisweek+datetime.timedelta(weeks=int( 'week' in call.params and call.params['week'] or 0)) for day in range(7): singleday = weekstart + datetime.timedelta(days=day) weekday_name = _(singleday.date().strftime("%A")) month_name = _(singleday.date().strftime("%B")) listitem = xbmcgui.ListItem(label=singleday.date().strftime(weekday_name + " (%d. " + month_name + " %Y)")) contextmenueitems = [tuple(( _('show all channels'), "Container.Update(%s,True)" % call.format(params={'showall': True}, update=True) ))] listitem.addContextMenuItems(contextmenueitems, replaceItems=True ) if singleday.date() == datetime.date.today(): listitem.select(True) listing.append( [ call.format(params={'day': int(time.mktime(singleday.timetuple()))}, update=True), listitem, True] ) if not 'week' in call.params and not 'day' in call.params: # wochenliste for weekdelta in range(1, 5): weekstart = thisweek+datetime.timedelta(weeks=weekdelta) weekstring = " +" + _(weekdelta>1 and "%s weeks" or "%s week") % str(weekdelta) month_start_name = _(weekstart.date().strftime("%B")) month_end_name = _((weekstart.date()+datetime.timedelta(days=6)).strftime("%B")) weekstring += u" (%s - %s)" % ( weekstart.date().strftime("%d. ") + month_start_name + weekstart.date().strftime(" %Y"), (weekstart.date()+datetime.timedelta(days=6)).strftime("%d. ") + month_end_name + (weekstart.date()+datetime.timedelta(days=6)).strftime(" %Y") ) listitem = xbmcgui.ListItem(label=weekstring) listitem.addContextMenuItems([], replaceItems=True ) listing.append( [ call.format(params={'week':weekdelta}, update=True), listitem, True] ) if not 'day' in call.params: return listing if not 'channel' in call.params: # kanalliste hidden_chan = __addon__.getSetting('otrChannelsHidden').split(',') hidden_lang = __addon__.getSetting('otrLanguagesHidden').split(',') if getKey(call.params, 'hidechannel'): hidden_chan.append(getKey(call.params, 'hidechannel')) __addon__.setSetting('otrChannelsHidden', ','.join(hidden_chan).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'unhidechannel'): name = getKey(call.params, 'unhidechannel') if name in hidden_chan: hidden_chan.remove(name) __addon__.setSetting('otrChannelsHidden', ','.join(hidden_chan).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'hidelanguage'): hidden_lang.append(getKey(call.params, 'hidelanguage')) __addon__.setSetting('otrLanguagesHidden', ','.join(hidden_lang).strip(',')) xbmc.executebuiltin("Container.Refresh") elif getKey(call.params, 'unhidelanguage'): name = getKey(call.params, 'unhidelanguage') if name in hidden_lang: hidden_lang.remove(name) __addon__.setSetting('otrLanguagesHidden', ','.join(hidden_lang).strip(',')) xbmc.executebuiltin("Container.Refresh") channels = otr.getChannelsDict() keys = channels.keys() keys.sort() for key in keys: language = channels[key]['LANGUAGE'] contextmenueitems = [] if not ('showall' in call.params and call.params['showall'] == 'True'): if language in hidden_lang: continue if key in hidden_chan: continue showall = False hiddenitem = False else: hiddenitem = False if language in hidden_lang: hiddenitem = True if key in hidden_chan: hiddenitem = True showall = True if not hiddenitem: contextmenueitems.append ( tuple(( _('hide channel (%s)') % key, "XBMC.RunPlugin(%s)" % call.format(params={'hidechannel': key}, update=True), )) ) if hiddenitem and key in hidden_chan: contextmenueitems.append ( tuple(( _('unhide channel (%s)') % key, "XBMC.RunPlugin(%s)" % call.format(params={'unhidechannel': key}, update=True), )) ) if not hiddenitem: contextmenueitems.append ( tuple(( _('hide language (%s)') % language, "XBMC.RunPlugin(%s)" % call.format(params={'hidelanguage': language}, update=True), )) ) if hiddenitem and language in hidden_lang: contextmenueitems.append ( tuple(( _('unhide language (%s)') % language, "XBMC.RunPlugin(%s)" % call.format(params={'unhidelanguage': language}, update=True), )) ) if not showall: contextmenueitems.append ( tuple(( _('show all channels'), "Container.Update(%s,True)" % call.format(params={'showall': True}, update=True) )) ) li = xbmcgui.ListItem(label=key, iconImage=getStationThumburl(key)) li.addContextMenuItems(contextmenueitems, replaceItems=True ) if hiddenitem: li.select(True) listing.append( [ call.format(params={'channel': key}, update=True), li, True] ) return listing if 'day' in call.params and 'channel' in call.params: selected_daystamp = int(call.params['day']) selected_day = datetime.datetime.fromtimestamp(selected_daystamp).date() selected_channel = call.params['channel'] entries = otr.getChannelListingDict([selected_channel], selected_day, selected_day) or [] entries = getKey(entries, 'ITEM') or [] listing.append( [ call.format(params={'day': str(selected_daystamp-86400)}, update=True), xbmcgui.ListItem(label=_('day before')), True] ) for entry in entries: title = urllib.unquote_plus(entry['TITEL']) attribs = [] if 'NICEDATE' in entry: attribs.append(entry['NICEDATE']) title += " (%s)" % ', '.join(attribs) info = {} if 'NICEDATE' in entry and entry['NICEDATE']: info['date'] = entry['NICEDATE'] if 'TYP' in entry and entry['TYP']: info['genre'] = urllib.unquote_plus(entry['TYP']) if 'TEXT' in entry and entry['TEXT']: info['plot'] = urllib.unquote_plus(entry['TEXT']) if 'RATING' in entry and entry['RATING']: info['rating'] = int(entry['RATING']) if 'PROGRAMMINGS' in entry and entry['PROGRAMMINGS']: info['playcount'] = int(entry['PROGRAMMINGS']) if 'DAUER' in entry and entry['DAUER']: info['duration'] = entry['DAUER'] if 'FSK' in entry and entry['FSK']: info['mpaa'] = urllib.unquote_plus(entry['FSK']) li = xbmcgui.ListItem(label=title) li.setInfo('video', info) if 'HIGHLIGHT' in entry and entry['HIGHLIGHT'] and int(entry['HIGHLIGHT'])>0: li.select(True) listing.append( [call.format('/schedulejob', {'epgid':entry['ID']}), li, False] ) listing.append( [ call.format(params={'day': str(selected_daystamp+86400)}, update=True), xbmcgui.ListItem(label=_('day after')), True] ) return listing return None