def get_fanart(item_id, path, server_id=None, api_client=None): ''' Get extra fanart for listitems. This is called by skinhelper. Images are stored locally, due to the Kodi caching system. ''' if not item_id and 'plugin.video.jellyfin' in path: item_id = path.split('/')[-2] if not item_id: return LOG.info("[ extra fanart ] %s", item_id) objects = Objects() list_li = [] directory = translate_path("special://thumbnails/jellyfin/%s/" % item_id) if not xbmcvfs.exists(directory): xbmcvfs.mkdirs(directory) item = api_client.get_item(item_id) obj = objects.map(item, 'Artwork') backdrops = api.API(item).get_all_artwork(obj) tags = obj['BackdropTags'] for index, backdrop in enumerate(backdrops): tag = tags[index] fanart = os.path.join(directory, "fanart%s.jpg" % tag) li = xbmcgui.ListItem(tag, path=fanart) xbmcvfs.copy(backdrop, fanart) list_li.append((fanart, li, False)) else: LOG.debug("cached backdrop found") dirs, files = xbmcvfs.listdir(directory) for file in files: fanart = os.path.join(directory, file) li = xbmcgui.ListItem(file, path=fanart) list_li.append((fanart, li, False)) xbmcplugin.addDirectoryItems(PROCESS_HANDLE, list_li, len(list_li)) xbmcplugin.endOfDirectory(PROCESS_HANDLE)
def root(): gslug_url = plugin.args.get("url", [""])[-1] if gslug_url: gslug_referer = plugin.args.get("referer", [gslug_url])[-1] quality = plugin.args.get("quality", ["best"])[-1] _port = find_free_port() LIVE = False xbmc.executebuiltin( "RunScript({0},{1},{2},{3},{4},{5})".format( XBMC_GSLUG_SCRIPT, gslug_url, gslug_referer, user_agent, quality, _port ) ) playlist_path = "http://127.0.0.1:{0}/{1}/chunks.m3u8".format( _port, sha256(gslug_url.encode("utf-8")).hexdigest() ) timeout = 0 monitor = xbmc.Monitor() while not monitor.abortRequested() and (timeout < 10): try: _r = requests.head(playlist_path, timeout=1) _r.raise_for_status() LIVE = True break except Exception: if monitor.waitForAbort(1): break else: timeout +=1 if LIVE: headers = urlencode([("User-Agent", user_agent,)]) li = xbmcgui.ListItem(path="{0}|{1}".format(playlist_path, headers)) li.setMimeType("application/vnd.apple.mpegurl") li.setContentLookup(False) xbmcplugin.setResolvedUrl(plugin.handle, True, li) else: xbmcgui.Dialog().notification(plugin.name, "Stream offline", xbmcgui.NOTIFICATION_ERROR) xbmcplugin.setResolvedUrl(plugin.handle, False, xbmcgui.ListItem())
def build_show_menu(self, variable, playlist=False, select_group=None): """ Builds a list of videos for a show given by its show URL. Keyword arguments: variable -- Either a relative URL of a show or a article id playlist -- If true, interpret variable as a playlist, i.e. variable is a article id. """ if not playlist: shows = self.extract_show_info(variable, select_group=select_group) else: shows = self.extract_playlist(variable) for show in shows: list_item = xbmcgui.ListItem(label=show['title']) list_item.setProperty('IsPlayable', 'true') list_item.setArt({ 'thumb': show['image'], 'poster': show['image'], 'fanart': show['fanart'], 'banner': show['fanart'] }) # We currently do not add dates to the show, because they # are wrong on the server. # date_string = show['date'] # try: # date_obj = dateutil.parser.parse(date_string) # aired = "%s-%s-%s" % (str(date_obj.year), # str(date_obj.month).zfill(2), # str(date_obj.day).zfill(2)) # except (TypeError, ValueError): # aired = None list_item.setInfo( 'video', { # We do not set the date currently, because the given date # by the server is not correct. # 'aired': aired, 'plot': show['lead'], 'duration': show['duration'], }) if show['is_folder']: url = self.build_url(mode=21, name=show['id']) else: url = self.build_url(mode=50, name=show['title'].encode('utf-8'), kaltura_id=show['kaltura_id']) xbmcplugin.addDirectoryItem(int(sys.argv[1]), url, list_item, isFolder=show['is_folder'])
def add_dir(name, id, mode, icon, fanart=None, info=None, genre_id=None, content_type='videos'): ok = True u = addon_url+"?id="+urllib.quote_plus(id)+"&mode="+str(mode) if genre_id is not None: u += "&genre_id=%s" % genre_id listitem=xbmcgui.ListItem(name) if fanart is None: fanart = FANART listitem.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'fanart': fanart}) if info is not None: listitem.setInfo( type="video", infoLabels=info) ok = xbmcplugin.addDirectoryItem(handle=addon_handle,url=u,listitem=listitem,isFolder=True) xbmcplugin.setContent(addon_handle, content_type) return ok
def SingleRubrik(path, title, DictID): PLog('SingleRubrik: %s' % path); PLog(DictID) path_org = path jsonObject = Dict("load", DictID) jsonObject = GetJsonByPath(path, jsonObject) if jsonObject == '': # index error xbmcplugin.endOfDirectory(HANDLE) PLog('jsonObjects: ' + str(len(jsonObject))) # Debug: # RSave("/tmp/x_SingleRubrik.json", json.dumps(jsonObject, sort_keys=True, indent=2, separators=(',', ': '))) li = xbmcgui.ListItem() li = home(li, ID=ZDFNAME) # Home-Button i=0 for entry in jsonObject: path = path_org + '|%d' % i date=''; title=''; descr=''; img='' # PLog(entry) # bei Bedarf PLog("entry_type: " + entry["type"]) mediatype='' if entry["type"] == 'video': # Kennz. Video nur bei Sofortstart in ShowVideo if SETTINGS.getSetting('pref_video_direct') == 'true': mediatype='video' # Alle genannten types laufen über ShowVideo - nur video wird dort endverarbeitet. # Die types video, brand, category, topic kehren mit dem neuen jsonObject wieder # zum PageMenu zurück und werden neu verteilt (SingleRubrik od. ShowVideo). # Alle anderen möglichen entry-types (?) werden übersprungen. if entry["type"] == "video" or entry["type"] == "brand" or entry["type"] == "category" or entry["type"] == "topic": typ,title,subTitle,descr,img,date,dauer = Get_content(entry,imgWidth) if subTitle: # title = '%s | %s' % (title,subTitle) title = '%s | %s' % (subTitle, title ) # subTitle = Sendungstitel tagline='' if date: tagline = '%s' % (date) if tagline and dauer: tagline = '%s | %s' % (tagline, dauer) title = repl_json_chars(title) # PLog('video-content: %s | %s | %s | %s | ' % (title,subTitle,descr,img)) fparams="&fparams={'path': '%s', 'DictID': '%s'}" % (path, DictID) PLog("fparams: " + fparams) addDir(li=li, label=title, action="dirList", dirID="resources.lib.zdfmobile.ShowVideo", fanart=img, thumb=img, fparams=fparams, summary=descr, tagline=tagline, mediatype=mediatype) i=i+1 # break # Test Einzelsatz xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def create_item(queries, label, thumb='', fanart='', is_folder=None, is_playable=None, total_items=0, menu_items=None, replace_menu=False): list_item = xbmcgui.ListItem(label, iconImage=thumb, thumbnailImage=thumb) add_item(queries, list_item, fanart, is_folder, is_playable, total_items, menu_items, replace_menu)
def addDir(name, url, mode, iconimage): u = sys.argv[0] + "?url=" + urllib_parse.quote_plus(url) + "&mode=" + str(mode) \ + "&name=" + urllib_parse.quote_plus(name) ok = True liz = xbmcgui.ListItem(name) liz.setArt({'thumb': iconimage, 'icon': 'DefaultVideo.png', 'poster': iconimage}) liz.setInfo(type='Video', infoLabels={'Title': name}) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) return ok
def DownloadMultiple(key_downl_list, key_URL_rec): # Sammeldownloads PLog('DownloadMultiple:'); import shlex # Parameter-Expansion downl_list = Dict("load", "downl_list") # PLog('downl_list: %s' % downl_list) li = xbmcgui.ListItem() li = home(li, ID='ARDaudio') # Home-Button rec_len = len(downl_list) dest_path = SETTINGS.getSetting('pref_download_path') path_url_list = [] # für int. Download if os.path.isdir(dest_path) == False: # Downloadverzeichnis prüfen msg1='Downloadverzeichnis nicht gefunden:' msg2=path xbmcgui.Dialog().ok(ADDON_NAME, msg1, msg2, '') return li i = 0 for rec in downl_list: # Parameter-Liste erzeugen i = i + 1 #if i > 2: # reduz. Testlauf # break title, url = rec.split('#') title = unescape(title) # schon in PodFavoriten, hier erneut nötig if SETTINGS.getSetting('pref_generate_filenames'): # Dateiname aus Titel generieren dfname = make_filenames(py2_encode(title)) + '.mp3' PLog(dfname) else: # Bsp.: Download_2016-12-18_09-15-00.mp4 oder ...mp3 now = datetime.datetime.now() mydate = now.strftime("%Y-%m-%d_%H-%M-%S") dfname = 'Download_' + mydate + '.mp3' # Parameter-Format: -o Zieldatei_kompletter_Pfad Podcast-Url -o Zieldatei_kompletter_Pfad Podcast-Url .. # path_url_list (int. Download): Zieldatei_kompletter_Pfad|Podcast, Zieldatei_kompletter_Pfad|Podcast .. fullpath = os.path.join(dest_path, dfname) fullpath = os.path.abspath(fullpath) # os-spezischer Pfad path_url_list.append('%s|%s' % (fullpath, url)) PLog(sys.platform) from threading import Thread # thread_getfile textfile='';pathtextfile='';storetxt='';url='';fulldestpath='' now = datetime.datetime.now() timemark = now.strftime("%Y-%m-%d_%H-%M-%S") background_thread = Thread(target=ardundzdf.thread_getfile, args=(textfile,pathtextfile,storetxt,url,fulldestpath,path_url_list,timemark)) background_thread.start() # return li # Kodi-Problem: wartet bis Ende Thread xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True) return # hier trotz endOfDirectory erforderlich
def dir_listitem(label, path, artwork=None, fanart=None): ''' Gets the icon paths for default node listings ''' li = xbmcgui.ListItem(label, path=path) li.setArt({ "thumb": artwork or "special://home/addons/plugin.video.jellyfin/resources/icon.png", "fanart": fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png", "landscape": artwork or fanart or "special://home/addons/plugin.video.jellyfin/resources/fanart.png", }) return li
def add_stream(name, id, stream_type, icon, fanart, info=None): ok = True u=addon_url+"?id="+urllib.quote_plus(id)+"&mode="+str(103)+"&type="+urllib.quote_plus(stream_type) listitem=xbmcgui.ListItem(name) if fanart is None: fanart = FANART listitem.setArt({'icon': icon, 'thumb': icon, 'poster': icon, 'fanart': fanart}) listitem.setProperty("IsPlayable", "true") if info is not None: listitem.setInfo( type="video", infoLabels=info) ok = xbmcplugin.addDirectoryItem(handle=addon_handle,url=u,listitem=listitem,isFolder=False) xbmcplugin.setContent(addon_handle, stream_type) return ok
def playLive(self, id, epid=None, opt='live'): log('playLive, id = %s, epid = %s, opt = %s' % (id, epid, opt)) #if opt == 'pvr', find epid. if id == 'NEXT_SHOW': found = False liz = xbmcgui.ListItem() notificationDialog(LANGUAGE(30029), time=4000) else: found = True liz = self.resolveURL(id, epid, opt) log('playLive, url = %s' % (liz.getPath())) xbmcplugin.setResolvedUrl(ROUTER.handle, found, liz)
def addDir(self, name, uri=(''), infoList={}, infoArt={}, infoType='video', listitem=None): log('addDir, name = %s'%name) if listitem is None: liz = xbmcgui.ListItem(name) if infoList: liz.setInfo(type=infoType, infoLabels=infoList) else: liz.setInfo(type=infoType, infoLabels={"mediatype":infoType,"label":name,"title":name}) if infoArt: liz.setArt(infoArt) else: liz.setArt({'thumb':ICON,'fanart':FANART}) if infoList.get('favorite',None) is not None: liz = self.addContextMenu(liz, infoList) else: liz = listitem liz.setProperty('IsPlayable','false') xbmcplugin.addDirectoryItem(ROUTER.handle, ROUTER.url_for(*uri), liz, isFolder=True)
def addDir(name, url, mode, icon, fanart=None, event_id=None, owner_id=None, info=None, cat_info=None): ok = True u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str( mode) + "&name=" + urllib.quote_plus(name) if event_id is not None: u = u + "&event_id=" + urllib.quote_plus(event_id) if owner_id is not None: u = u + "&owner_id=" + urllib.quote_plus(owner_id) if icon is not None: u = u + "&icon=" + urllib.quote_plus(icon) if cat_info is not None: u = u + "&cat_info=" + urllib.quote_plus(cat_info) if icon is None: icon = ICON if fanart is None: fanart = FANART liz = xbmcgui.ListItem(name) liz = xbmcgui.ListItem(name) liz.setArt({'icon': icon, 'thumb': icon, 'fanart': fanart}) liz.setInfo(type="Video", infoLabels={"Title": name}) if info is not None: liz.setInfo(type="Video", infoLabels=info) ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True) xbmcplugin.setContent(int(sys.argv[1]), 'episodes') return ok
def Main_TIVI(title): PLog('Main_TIVI:') li = xbmcgui.ListItem() li = home(li, ID='Kinderprogramme') # Home-Button title = "Suche in ZDFtivi" summ = "Suche Videos in KIKA" fparams = "&fparams={'query': '', 'title': '%s'}" % title addDir(li=li, label=title, action="dirList", dirID="resources.lib.childs.Tivi_Search", fanart=GIT_ZDFTIVI, thumb=R(ICON_ZDF_SEARCH), fparams=fparams) title = 'Startseite' fparams = "&fparams={'path': '%s', 'title': '%s'}" % (quote(BASE_TIVI), title) addDir(li=li, label=title, action="dirList", dirID="ardundzdf.ZDFStart", fanart=GIT_ZDFTIVI, thumb=GIT_TIVIHOME, tagline=title, fparams=fparams) title = 'Sendungen der letzten 7 Tage' fparams = "&fparams={}" addDir(li=li, label=title, action="dirList", dirID="resources.lib.childs.Tivi_Woche", fanart=GIT_ZDFTIVI, thumb=GIT_CAL, tagline=title, fparams=fparams) title = 'Sendungen A-Z | 0-9' fparams = "&fparams={}" addDir(li=li, label=title, action="dirList", dirID="resources.lib.childs.Tivi_AZ", fanart=GIT_ZDFTIVI, thumb=GIT_AZ, tagline=title, fparams=fparams) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def Tivi_Search(query=None, title='Search', pagenr=''): PLog("Tivi_Search:") if query == '': query = ardundzdf.get_query(channel='ZDF') PLog(query) if query == None or query.strip() == '': return "" query_org = query query=py2_decode(query) # decode, falls erf. (1. Aufruf) PLog('Tivi_Search:'); PLog(query); PLog(pagenr); ID='Search' Tivi_Search_PATH = 'https://www.zdf.de/suche?q=%s&from=&to=&sender=ZDFtivi&attrs=&contentTypes=episode&sortBy=date&page=%s' if pagenr == '': # erster Aufruf muss '' sein pagenr = 1 path = Tivi_Search_PATH % (query, pagenr) PLog(path) page, msg = get_page(path=path) searchResult = stringextract('data-loadmore-result-count="', '"', page) # Anzahl Ergebnisse PLog("searchResult: " + searchResult) li = xbmcgui.ListItem() li = home(li, ID='Kinderprogramme') # Home-Button # Der Loader in ZDF-Suche liefert weitere hrefs, auch wenn weitere Ergebnisse fehlen - # dto ZDFtivi if searchResult == '0' or 'class="artdirect"' not in page: query = (query.replace('%252B', ' ').replace('+', ' ')) # quotiertes ersetzen msg1 = 'Keine Ergebnisse (mehr) zu: %s' % query MyDialog(msg1, '', '') return li # anders als bei den übrigen ZDF-'Mehr'-Optionen gibt der Sender Suchergebnisse bereits # seitenweise aus, hier umgesetzt mit pagenr - offset entfällt li, page_cnt = ardundzdf.ZDF_get_content(li=li, page=page, ref_path=path, ID=ID) PLog('li, page_cnt: %s, %s' % (li, page_cnt)) if page_cnt == 'next': # mehr Seiten (Loader erreicht) pagenr = int(pagenr) + 1 query = query_org.replace('+', ' ') path = Tivi_Search_PATH % (query, pagenr) # Debug PLog(pagenr); PLog(path) title = "Mehr Ergebnisse in ZDFtivi suchen zu: >%s<" % query query_org=py2_encode(query_org); fparams="&fparams={'query': '%s', 'pagenr': '%s'}" %\ (quote(query_org), pagenr) addDir(li=li, label=title, action="dirList", dirID="resources.lib.childs.Tivi_Search", fanart=R(ICON_MEHR), thumb=R(ICON_MEHR), fparams=fparams) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def ThemenListe(title, ID, path, next_url=''): # Liste zu einzelnem Untermenü PLog('ThemenListe: ' + title) PLog('ID: ' + ID) PLog('next_url: ' + next_url) title_org = title if next_url == '': # 1. Aufruf sid = re.search(u'\-(\d+)\.html', path).group(1) # Bsp. ../russland-r-252413.html url = 'https://www.phoenix.de/response/id/' + sid else: url = next_url PLog('url: ' + url) page, msg = get_page(path=url) if page == '': msg1 = 'Fehler in ThemenListe: %s' % title msg2 = msg MyDialog(msg1, msg2, '') return PLog(len(page)) page = page.replace('\\/', '/') # json-raw Links page = page.replace('\\"', '*') # "-Zeichen ersetzen base_img = ICON_PHOENIX # Fallback if 'bild_l' in page: base_img = BASE_PHOENIX + stringextract('"bild_l":"', '"', page) li = xbmcgui.ListItem() li = home(li, ID='phoenix') # Home-Button li = GetContent(li, page, base_img=base_img, turn_title=True) if '"next_url":' in page: # Mehr-Seiten next_url = stringextract('next_url":"', '"', page) if next_url: next_url = BASE_PHOENIX + next_url PLog("next_url: " + next_url) img = R(ICON_MEHR) title = u"Weitere Beiträge" tag = "%s zu: [B]%s[/B]" % (title, title_org) # tag = u"Beiträge gezeigt: %s, gesamt: %s" % (len(items), search_cnt) # nicht verfügbar title_org=py2_encode(title_org); ID=py2_encode(ID); path=py2_encode(path); next_url=py2_encode(next_url); fparams="&fparams={'title': '%s', 'ID': '%s', 'path': '%s', 'next_url': '%s'}" %\ (quote(title_org), quote(ID), quote(path), quote(next_url)) addDir(li=li, label=title, action="dirList", dirID="resources.lib.phoenix.ThemenListe", fanart=img, thumb=img, fparams=fparams, tagline=tag) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def Hub(ID): PLog('Hub, ID: %s' % ID) li = xbmcgui.ListItem() li = home(li, ID=ZDFNAME) # Home-Button if ID == 'Startpage': # lokale Testdatei: # path = '/daten/entwicklung/Plex/Codestuecke/ZDF_JSON/ZDF_start-page.json' # page = Resource.Load(path) path = 'https://zdf-cdn.live.cellular.de/mediathekV2/start-page' if ID == 'Kategorien': path = 'https://zdf-cdn.live.cellular.de/mediathekV2/categories-overview' if ID == 'Sendungen_A-Z': path = 'https://zdf-cdn.live.cellular.de/mediathekV2/brands-alphabetical' if ID == 'Sendung_verpasst': li = Verpasst(DictID='mobile_Verpasst') return li # raus - jsonObject wird in Verpasst_load geladen if ID == 'Live_TV': now = datetime.datetime.now() datum = now.strftime("%Y-%m-%d") path = 'https://zdf-cdn.live.cellular.de/mediathekV2/live-tv/%s' % datum # Im Cache wird das jsonObject abgelegt, Name: "mobile_%s" % ID page = Dict("load", "mobile_%s" % ID, CacheTime=ZDFStartCacheTime) # 5 min if page == False: # nicht vorhanden oder zu alt page = loadPage(path) # vom Sender holen if len(page) == 0 or str(page).startswith('Fehler'): msg1 = 'Fehler beim Abruf von:' msg2 = path MyDialog(msg1, msg2, '') xbmcplugin.endOfDirectory(HANDLE) else: jsonObject = json.loads(page) Dict('store', "mobile_%s" % ID, jsonObject) # jsonObject speichern else: jsonObject = page PLog("jsonObject1: " + str(jsonObject)[:100]) if ID == 'Startpage': # speichern li = PageMenu(li, jsonObject, DictID='mobile_Startpage') if ID == 'Kategorien': li = PageMenu(li, jsonObject, DictID='mobile_Kategorien') if ID == 'Sendungen_A-Z': li = PageMenu(li, jsonObject, DictID='mobile_Sendungen_A-Z') if ID == 'Live_TV': li = PageMenu(li, jsonObject, DictID='mobile_Live_TV') return li
def Themen(ID): # Untermenüs zu ID PLog('Themen, ID: ' + ID) if ID == 'Rubriken': url = 'https://www.phoenix.de/response/template/rubrik_overview_json' if ID == 'Dossiers': url = 'https://www.phoenix.de/response/template/dossier_overview_json' if ID == 'Sendungen': url = 'https://www.phoenix.de/response/template/sendungseite_overview_json' page, msg = get_page(path=url) if page == '': msg1 = 'Fehler in Themen: %s' % ID msg2 = msg xbmcgui.Dialog().ok(ADDON_NAME, msg1, msg2, '') return PLog(len(page)) jsonObject = json.loads(page) search_cnt = jsonObject["content"]['hits'] li = xbmcgui.ListItem() li = home(li, ID='phoenix') # Home-Button items = jsonObject["content"]['items'] PLog(len(items)) for item in items: # img = BASE_PHOENIX + item["icon"] # diese svg-Grafik in Plex nicht darstellbar img = BASE_PHOENIX + item["bild_m"] url = BASE_PHOENIX + item["link"] # Bsp. ../russland-r-252413.html title = item["titel"] typ = item["typ"] title = cleanhtml(title) PLog('Satz:') PLog(url) PLog(img) PLog(title) url = py2_encode(url) title = py2_encode(title) fparams="&fparams={'path': '%s', 'title': '%s', 'ID': '%s'}" %\ (quote(url), quote(title), ID) addDir(li=li, label=title, action="dirList", dirID="resources.lib.phoenix.ThemenListe", fanart=img, thumb=img, fparams=fparams) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def Hub(ID): PLog('Hub, ID: %s' % ID) li = xbmcgui.ListItem() li = home(li, ID=ZDFNAME) # Home-Button if ID=='Startseite': # lokale Testdatei: # path = '/daten/entwicklung/Plex/Codestuecke/ZDF_JSON/ZDF_start-page.json' # page = Resource.Load(path) path = 'https://zdf-cdn.live.cellular.de/mediathekV2/start-page' if ID=='Kategorien': path = 'https://zdf-cdn.live.cellular.de/mediathekV2/categories' if ID=='Sendungen A-Z': path = 'https://zdf-cdn.live.cellular.de/mediathekV2/brands-alphabetical' if ID=='Sendung verpasst': li = Verpasst(DictID='Verpasst') return li # raus - jsonObject wird in Verpasst_load geladen if ID=='Live TV': now = datetime.datetime.now() datum = now.strftime("%Y-%m-%d") path = 'https://zdf-cdn.live.cellular.de/mediathekV2/live-tv/%s' % datum page = loadPage(path) if len(page) == 0 or str(page).startswith('Fehler'): xbmcgui.Dialog().ok(ADDON_NAME, 'Fehler beim Abruf von:', path, '') xbmcplugin.endOfDirectory(HANDLE) jsonObject = json.loads(page) if ID=='Startseite': v = 'Startpage' # speichern Dict('store', v, jsonObject) li = PageMenu(li,jsonObject,DictID='Startpage') if ID=='Kategorien': v = 'Kategorien' Dict("store", v, jsonObject) li = PageMenu(li,jsonObject,DictID='Kategorien') if ID=='Sendungen A-Z': v = 'A_Z' Dict("store", v, jsonObject) li = PageMenu(li,jsonObject,DictID='A_Z') if ID=='Live TV': v = 'Live' Dict("store", v, jsonObject) li = PageMenu(li,jsonObject,DictID='Live') return li
def Kiraka_Live(): PLog('Kiraka_Live') li = xbmcgui.ListItem() li = home(li, ID='Kinderprogramme') # Home-Button url = 'http://wdr-kiraka-live.icecast.wdr.de/wdr/kiraka/live/mp3/128/stream.mp3' thumb = "https://www1.wdr.de/mediathek/audio/logo-kiraka100~_v-gseagaleriexl.jpg" Plot = '' title = 'KiRaKa Live hören' PLog(url) PlayAudio(url, title, thumb, Plot) # direkt xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def makeListItem(self, **ka): replaceItems = ka['replaceItems'] if 'replaceItems' in ka else False item = xbmcgui.ListItem( self.get_label(), self.get_label(), self.get_image(), self.get_image(), self.make_url(), ) ctxMenu = contextMenu() self.attach_context_menu(item, ctxMenu) item.addContextMenuItems(ctxMenu.getTuples(), replaceItems) return item
def buildMenuListItem(label1="", label2="", iconImage=None, url="", infoItem=None, artItem=None, propItem=None, oscreen=True, mType='video'): listitem = xbmcgui.ListItem(label1, label2, path=url, offscreen=oscreen) iconImage = (iconImage or COLOR_LOGO) if propItem: listitem.setProperties(propItem) if infoItem: listitem.setInfo(mType, infoItem) else: listitem.setInfo(mType, {'mediatype': 'video', 'Label' : label1, 'Label2': label2, 'Title' : label1}) if artItem: listitem.setArt(artItem) else: listitem.setArt({'thumb': iconImage, 'icon' : iconImage}) return listitem
def addCat(self, name, url, icon, mode): if self.lograwdata: self.log("Adding Cat: " + str(name) + "," + str(url) + "," + str(icon) + " MODE: " + str(mode)) category_url = '%s?%s' % (self.base_url, urlencode({ 'url': url, 'mode': mode, 'name': name, })) liz = xbmcgui.ListItem(name) liz.setArt({'fanart': self.get_resource("fanart.jpg"), 'thumb': icon, 'icon': icon}) liz.setInfo(type="Video", infoLabels={"Title": name}) liz.setProperty('isPlayable', "false") xbmcplugin.addDirectoryItem(handle=self.handle, url=category_url, listitem=liz, isFolder=True)
def play(name, url, iconimage, description, playable): if url and 'plugin' in url: xbmc.executebuiltin('RunPlugin(%s)' % url) elif url and not 'plugin' in url: if six.PY3: li = xbmcgui.ListItem(name, path=url) if iconimage: li.setArt({"icon": "DefaultVideo.png", "thumb": iconimage}) else: li = xbmcgui.ListItem(name, path=url, iconImage=iconimage, thumbnailImage=iconimage) li.setInfo(type="Video", infoLabels={ "Title": name, "Plot": description }) if not playable == 'false': xbmcplugin.setResolvedUrl(handle, True, li) else: xbmc.Player().play(item=url, listitem=li)
def listitem(self): """Create a Kodi listitem from the metadata""" try: # offscreen is a Kodi v18 feature # We wont't be able to change the listitem after running .addDirectoryItem() # But load time for this function is cut down by 93% (!) li = xbmcgui.ListItem(self.title, offscreen=True) except TypeError: li = xbmcgui.ListItem(self.title) art_dict = {'icon': self.icon, 'poster': self.icon, 'fanart': self.fanart} # Check if there's any art, setArt can be kinda slow if any(art_dict.values()): li.setArt(art_dict) li.setInfo('video', {'plot': self.description}) if self.streamable: query = {Q.MODE: M.STREAM, Q.STREAMKEY: self.key} action = 'RunPlugin(' + request_to_self(query) + ')' li.addContextMenuItems([(S.SHUFFLE_CAT, action)]) return li
def addPlaylist(self, name, path='', infoList={}, infoArt={}, infoVideo={}, infoAudio={}, infoType='video', listitem=None): log('addPlaylist, name = %s'%name) if listitem is None: liz = xbmcgui.ListItem(name) if infoList: liz.setInfo(type=infoType, infoLabels=infoList) else: liz.setInfo(type=infoType, infoLabels={"mediatype":infoType,"label":name,"title":name}) if infoArt: liz.setArt(infoArt) else: liz.setArt({'thumb':ICON,'fanart':FANART}) if infoVideo: liz.addStreamInfo('video', infoVideo) if infoAudio: liz.addStreamInfo('audio', infoAudio) else: liz = listitem liz.setProperty('IsPlayable','true') self.listitems.append(liz)
def create_item(queries, label, thumb='', fanart='', is_folder=None, is_playable=None, total_items=0, menu_items=None, replace_menu=False): if not thumb: thumb = os.path.join(get_path(), 'icon.png') list_item = xbmcgui.ListItem(label, iconImage=thumb, thumbnailImage=thumb) add_item(queries, list_item, fanart, is_folder, is_playable, total_items, menu_items, replace_menu)
def Kika_Videos(path, title, thumb): PLog('Kika_Videos:') li = xbmcgui.ListItem() li = home(li, ID='Kinderprogramme') # Home-Button page, msg = get_page(path) if page == '': msg1 = "Fehler in Kika_VideosAZ:" msg2 = msg MyDialog(msg1, msg2, '') return li if page.find('dataURL:') < 0: # ohne 'dataURL:' - ohne kein Link zu xml-Seite, also keine Videos. msg1 = "Leider kein Video gefunden zu:" msg2 = title MyDialog(msg1, msg2, '') return li videos = blockextract('class="av-playerContainer"', page) PLog(len(videos)) mediatype='' if SETTINGS.getSetting('pref_video_direct') == 'true': # Kennz. Video für Sofortstart mediatype='video' for s in videos: href = ref = stringextract('dataURL:\'', '\'}', s) # Link Videodetails (..avCustom.xml) # PLog(href); # PLog(s); # Bei Bedarf img = stringextract('<noscript>', '</noscript>', s).strip() # Bildinfo separieren img_alt = stringextract('alt=\"', '\"', img) img_alt = unescape(img_alt) img_src = stringextract('src="', '"', img) if img_src.startswith('http') == False: img_src = BASE_KIKA + img_src stitle = stringextract('title="', '"', s) duration = stringextract('icon-duration">', '</span>', s) tagline = duration + ' Minuten' stitle = unescape(stitle); stitle = repl_json_chars(stitle) img_alt = unescape(img_alt); img_alt = repl_json_chars(img_alt); PLog('Satz:') PLog(href);PLog(stitle);PLog(img_alt);PLog(img_src); PLog(tagline); href=py2_encode(href); stitle=py2_encode(stitle); img_src=py2_encode(img_src); img_alt=py2_encode(img_alt); fparams="&fparams={'path': '%s', 'title': '%s', 'thumb': '%s', 'summ': '%s', 'duration': '%s'}" %\ (quote(href), quote(stitle), quote(img_src), quote(img_alt), quote(duration)) addDir(li=li, label=stitle, action="dirList", dirID="resources.lib.childs.Kika_SingleBeitrag", fanart=img_src, thumb=img_src, fparams=fparams, tagline=img_alt, mediatype=mediatype) xbmcplugin.endOfDirectory(HANDLE, cacheToDisc=True)
def get_movie(s, mainurl, mainurlajax, headers=None): check_sorry_message = "Our servers are almost maxed" check_go_premium = "Go Premium" htm=s.get(mainurl, headers=headers, cookies=s.cookies).text if re.search(check_sorry_message, htm): xbmcgui.Dialog().ok( "Server Error", "Sorry. Einthusan servers are almost maxed. Please try again in 5 - 10 mins or upgrade to a Lifetime Premium account.", ) return False if re.search(check_go_premium, htm): xbmcgui.Dialog().ok( "UltraHD Error", "Premium Membership Required for UltraHD Movies. Please add Premium Membership Login details in Addon Settings.", ) return False lnk=re.findall('data-ejpingables=["\'](.*?)["\']',htm)[0] r=decodeEInth(lnk) jdata='{"EJOutcomes":"%s","NativeHLS":false}'%lnk gid=re.findall('data-pageid=["\'](.*?)["\']',htm)[0] gid=html.unescape(gid) postdata={'xEvent':'UIVideoPlayer.PingOutcome','xJson':jdata,'arcVersion':'3','appVersion':'59','gorilla.csrf.Token':gid} rdata=s.post(mainurlajax,headers=headers,data=postdata,cookies=s.cookies).text r=json.loads(rdata)["Data"]["EJLinks"] xbmc.log(base64.b64decode(str(decodeEInth(r))).decode('ascii'), level=xbmc.LOGINFO) lnk=json.loads(base64.b64decode(decodeEInth(r)).decode('ascii'))["HLSLink"] lnk = preferred_server(lnk, mainurl) xbmc.log(lnk, level=xbmc.LOGINFO) urlnew=lnk+('|'+einthusanRedirectUrl+'&Referer=%s&User-Agent=%s'%(mainurl,'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36')) # listitem = xbmcgui.ListItem( label = str(name), icon = "DefaultVideo.png", thumb = xbmc.getInfoImage( "ListItem.Thumb" ) ) listitem = xbmcgui.ListItem(label = str(name)) #listitem.setProperty('IsPlayable', 'true') listitem.setPath(urlnew) xbmcplugin.setResolvedUrl(_plugin_handle, True, listitem) s.close()
def playvid(videourl, name, download=None): if download == 1: downloadVideo(videourl, name) else: iconimage = xbmc.getInfoImage("ListItem.Thumb") subject = xbmc.getInfoLabel("ListItem.Plot") listitem = xbmcgui.ListItem(name) listitem.setArt({ 'thumb': iconimage, 'icon': "DefaultVideo.png", 'poster': iconimage }) listitem.setInfo( 'video', { 'Title': name, 'Genre': 'P**n', 'plot': subject, 'plotoutline': subject }) if videourl.startswith('is://') or '.mpd' in videourl: videourl = videourl[5:] if videourl.startswith( 'is://') else videourl if PY2: listitem.setProperty('inputstreamaddon', 'inputstream.adaptive') else: listitem.setProperty('inputstream', 'inputstream.adaptive') if '|' in videourl: videourl, strhdr = videourl.split('|') listitem.setProperty('inputstream.adaptive.stream_headers', strhdr) if '.m3u8' in videourl: listitem.setProperty('inputstream.adaptive.manifest_type', 'hls') listitem.setMimeType('application/vnd.apple.mpegstream_url') elif '.mpd' in videourl: listitem.setProperty('inputstream.adaptive.manifest_type', 'mpd') listitem.setMimeType('application/dash+xml') elif '.ism' in videourl: listitem.setProperty('inputstream.adaptive.manifest_type', 'ism') listitem.setMimeType('application/vnd.ms-sstr+xml') listitem.setContentLookup(False) if int(sys.argv[1]) == -1: xbmc.Player().play(videourl, listitem) else: listitem.setPath(str(videourl)) xbmcplugin.setResolvedUrl(addon_handle, True, listitem)