def GetSeasonsList(url, iconimage): url = "{0}&{1}".format(url, endings) if "?" in url else "{0}?{1}".format( url, endings) prms = GetJson(url) if prms is None or "programData" not in prms or "seasons" not in prms[ "programData"]: xbmc.log("Cannot get Seasons list", 2) return if iconimage == os.path.join(imagesDir, 'search.jpg'): iconimage = GetImage(prms["programData"], "picI", iconimage) for prm in prms["programData"]["seasons"]: try: if "vods" not in prm: continue name = common.GetLabelColor(common.encode(prm.get('name', ''), "utf-8"), keyColor="timesColor", bold=True) url = "{0}{1}".format(baseUrl, prm["url"]) description = common.encode(prm.get('brief', ''), "utf-8") infos = {"Title": name, "Plot": description} common.addDir(name, url, 3, iconimage, infos, module=module, moreData=prm["id"]) except Exception as ex: xbmc.log(str(ex), 3)
def GetSeriesList(iconimage): text = common.OpenURL( 'https://www.20il.co.il/tochniot_haarutz/%d7%97%d7%93%d7%a9%d7%95%d7%aa-%d7%a2%d7%a8%d7%95%d7%a5-20/' ) match = re.compile('<div class="tochniot-in-use-images(.*?)</div>', re.S).findall(text) match = re.compile('<a href="(.*?)".*?<img src="\s*(.*?)"', re.S).findall(match[0]) grids_arr = [] for link, iconimage in match: iconimage = GetQuoteUrl(iconimage) name = common.unquote( common.encode(link[link.rfind('/') + 1:], 'utf-8')) name = common.GetLabelColor(common.UnEscapeXML(name.replace('-', ' ')), keyColor="prColor", bold=True) if iconimage.startswith('http') == False: iconimage = '{0}{1}'.format(baseUrl, iconimage) grids_arr.append((name, '{0}{1}'.format(baseUrl, link), iconimage, { "Title": name })) grids_sorted = grids_arr if sortBy == 0 else sorted( grids_arr, key=lambda grids_arr: grids_arr[0]) for name, link, image, infos in grids_sorted: common.addDir(name, link, 1, common.encode(image, 'utf-8'), infos=infos, module=module)
def GetChannels(url, iconimage): html = common.OpenURL(url, headers={"User-Agent": UA}) if html == "": return None match = re.compile("var makoliveJson ='(.*?)';").findall(html) resultJSON = json.loads(match[0]) if resultJSON is None or len(resultJSON) < 1: return None for channel in resultJSON['list']: name = common.GetLabelColor(common.encode(channel['title'], "utf-8"), keyColor="prColor") infos = { "Title": name, "Plot": common.encode(channel['subtitle'], "utf-8") } url = '{0}{1}'.format(baseUrl, channel['link']) iconimage = channel['picUrl'] common.addDir( name, url, 5, iconimage, infos, contextMenu=[(common.GetLocaleString( 30005 ), 'RunPlugin({0}?url={1}&name={2}&mode=5&iconimage={3}&moredata=choose&module=keshet)' .format(sys.argv[0], common.quote_plus(url), common.quote_plus(name), common.quote_plus(iconimage)))], moreData=bitrate, module='keshet', isFolder=False, isPlayable=True)
def Search(): series = common.GetUpdatedList(common.seriesFile, common.seriesUrl, isZip=True, sort=True) filteredSeries = [] seriesLinks = [] searchText = common.GetKeyboardText('מילים לחיפוש', '').strip().lower() if searchText == '': filteredSeries = series else: for serie in series: if serie['name'].lower().startswith(searchText): filteredSeries.append(serie) seriesLinks.append(serie['name']) for serie in series: if searchText in serie['name'].lower( ) and serie['name'] not in seriesLinks: filteredSeries.append(serie) seriesLinks.append(serie['name']) programNameFormat = int(Addon.getSetting("programNameFormat")) for serie in filteredSeries: serieMoreData = serie.get('moreData', '') serieCatName = serie.get('catName', '') serieName = serie['name'] moduleName = GetModuleName(serie['module'], serie['mode'], serieMoreData, serieCatName) name = common.getDisplayName(serieName, moduleName, programNameFormat, bold=True) infos = {"Title": name, "Plot": serie['desc']} isFolder = False if serieMoreData == 'youtube' else True xbmc.log(serie['url'], 5) xbmc.log(serie['icon'], 5) common.addDir(name, serie['url'], serie['mode'], common.encode(serie['icon'], 'utf-8'), infos, module=serie['module'], moreData=common.encode(serieMoreData, 'utf-8'), totalItems=len(filteredSeries), isFolder=isFolder, urlParamsData={ 'name': common.GetLabelColor(serieName, keyColor="prColor", bold=True) })
def GetSeriesList(iconimage): url = '{0}/vod/'.format(baseUrl) result = GetUrlJson(url) if len(result) < 1: return grids_arr = [] seriesIDs = [] series = {} grids = result.get('Content', {}).get('PageGrid', {}) for grid in grids: for seriesID in grid.get('Posts', {}): try: if seriesID in seriesIDs or seriesID == 170768: continue serie = result.get('ItemStore', {}).get(str(seriesID), {}) link = serie.get('link') postType = serie.get('postType', '') if postType == 'item': if '/movies/' in link: link = link[:link.find('/movies/') +8].replace('/item', '') else: link = link[:link.find('/season') +1].replace('/item', '') page_2_level_heb = serie['coolaData'].get('page_2_level_heb') name = '' if page_2_level_heb is None else common.encode(page_2_level_heb, 'utf-8') elif postType != 'page': continue else: if len(common.url_parse(link).path.split('/')) > 4 and 'channel2-news' not in link: continue name = common.encode(serie['title'], 'utf-8') name = common.GetLabelColor(name, keyColor="prColor", bold=True) if link == '' or link in series and postType != 'page': continue series[link] = name seriesIDs.append(seriesID) pageTitle = serie.get('pageTitle', {}) description = '' if pageTitle is None else common.encode(pageTitle.get('description', ''), 'utf-8') matches = [grids_arr.index(x) for x in grids_arr if link == x[1]] if len(matches) == 1: grids_arr[matches[0]] = (name, link, common.encode(serie['images']['app_16x9'], 'utf-8'), {"Title": name, "Plot": description}) else: grids_arr.append((name, link, common.encode(serie['images']['app_16x9'], 'utf-8'), {"Title": name, "Plot": description})) except Exception as ex: xbmc.log(str(ex), 3) grids_sorted = grids_arr if sortBy == 0 else sorted(grids_arr,key=lambda grids_arr: grids_arr[0]) for name, link, icon, infos in grids_sorted: common.addDir(name, link, 1, icon, infos=infos, module=module)
def MakeChannelsGuide(): if Addon.getSetting("useIPTV") != 'true': return channelsList = "" programmeList = "" epgList = common.ReadList(common.epgFile) if len(epgList) == 0: return for key,val in common.items(epgList): chName = common.encode(key, "utf-8") channelsList += "\t<channel id=\"{0}\">\n\t\t<display-name>{1}</display-name>\n\t</channel>\n".format(common.EscapeXML(chName), chName) for programme in val: start = GetTZtime(programme["start"]) end = GetTZtime(programme["end"]) name = common.EscapeXML(common.encode(programme["name"], "utf-8")) if programme["name"] != None else "" description = common.EscapeXML(common.encode(programme["description"], "utf-8")) if programme["description"] != None else "" programmeList += "\t<programme start=\"{0}\" stop=\"{1}\" channel=\"{2}\">\n\t\t<title>{3}</title>\n\t\t<desc>{4}</desc>\n\t</programme>\n".format(start, end, common.EscapeXML(chName), name, description) xmlList = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<tv>\n{0}{1}</tv>".format(channelsList, programmeList) with io.open(xmlFile, 'w', encoding="utf-8") as f: f.write(common.uni_code(xmlList))
def GetCategoriesList(iconimage): name = "{0}: {1}".format(common.GetLocaleString(30001), common.GetLocaleString(30002) if sortBy == 0 else common.GetLocaleString(30003)) common.addDir(name, "toggleSortingMethod", 5, iconimage, {"Title": name, "Plot": "{0}[CR]{1}[CR]{2} / {3}".format(name, common.GetLocaleString(30004), common.GetLocaleString(30002), common.GetLocaleString(30003))}, module=module, isFolder=False) result = GetUrlJson('{0}/vod/'.format(baseUrl)) if len(result) > 0: name = common.GetLabelColor("כל התכניות", bold=True, color="none") common.addDir(name, '', 0, iconimage, infos={"Title": name, "Plot": "צפיה בתכניות רשת 13"}, module=module) grids = result.get('Content', {}).get('PageGrid', {}) for grid in grids: gridType = grid.get('GridType') if gridType is not None and gridType == 'grid_content_4col' or gridType == 'carousel_grid_content': gridTitle = common.encode(grid.get('GridTitle').get('title').strip(), 'utf-8') name = common.GetLabelColor(gridTitle, bold=True, color="none") common.addDir(name, str(grid.get('grid_id')), 6, iconimage, infos={"Title": name}, module=module) name = common.GetLabelColor("החדשות 13", bold=True, color="none") common.addDir(name, '', 10, iconimage, infos={"Title": name, "Plot": "צפיה בתכניות חדשות 13"}, module=module)
def PlayLive(id): channel = None channels = baseChannels.TvChannels + baseChannels.RadioChannels for ch in channels: if ch.get('ch') == id: channel = ch break if channel is None: return nowEPG = epg.GetNowEPG() programs = [] if channel.get('tvgID', '') == '' else nowEPG.get( channel['tvgID'], []) channelNameFormat = int(Addon.getSetting("channelNameFormat")) displayName = common.GetLabelColor(common.GetLocaleString( channel['nameID']), keyColor="chColor", bold=True) iconimage = os.path.join(imagesDir, channel['image']) if len(programs) > 0: programTime = common.GetLabelColor("[{0}-{1}]".format( datetime.datetime.fromtimestamp( programs[0]["start"]).strftime('%H:%M'), datetime.datetime.fromtimestamp( programs[0]["end"]).strftime('%H:%M')), keyColor="timesColor") programName = common.GetLabelColor(common.encode( programs[0]["name"], 'utf-8'), keyColor="prColor", bold=True) displayName = GetChannelName(programName, programTime, displayName, channelNameFormat) if channel.get('resKey', '') == '': bitrate = 'best' else: bitrate = Addon.getSetting(channel['resKey']) if bitrate == '': bitrate = 'best' try: module = channel['module'] moduleScript = __import__('resources.lib.{0}'.format(module), fromlist=[module]) moduleScript.Run(displayName, channel['channelID'], channel['mode'], iconimage, bitrate) except Exception as ex: xbmc.log(str(ex), 3)
def GetNewsCategoriesList(iconimage): url = 'https://13news.co.il/programs/' result = GetUrlJson(url) if len(result) < 1: return grids_arr = [] mainMenus = result.get('Header', {}).get('mainMenu', []) for mainMenu in mainMenus: if mainMenu['url'] == url: grids = mainMenu['children'] for grid in grids: name = common.GetLabelColor(common.UnEscapeXML(common.encode(grid['title'], 'utf-8')), keyColor="prColor", bold=True) link = grid['url'] grids_arr.append((name, link, iconimage, {"Title": name})) grids_sorted = grids_arr if sortBy == 0 else sorted(grids_arr,key=lambda grids_arr: grids_arr[0]) for name, link, icon, infos in grids_sorted: common.addDir(name, link, 1, icon, infos=infos, module=module)
def ShowChannelEPG(channel, name='', iconimage='', provider='auto', days=2): common.addDir('------- {0} -------'.format(common.GetLabelColor(name, keyColor="chColor", bold=True)), name, 99, iconimage, isFolder=False) day = "" epgList = GetEPG() programs = epgList[channel] channelNameFormat = int(Addon.getSetting("channelNameFormat")) for program in programs: if now >= program['end']: continue startdate = datetime.datetime.fromtimestamp(program["start"]).strftime('%d/%m/%y') if startdate != day: day = startdate dayS = common.GetLabelColor(day, keyColor="nprColor", bold=True) common.addDir(dayS, 'epg', 99, iconimage, {"Title": dayS}, module=module, isFolder=False) start_time = datetime.datetime.fromtimestamp(program["start"]).strftime('%H:%M') end_time = datetime.datetime.fromtimestamp(program["end"]).strftime('%H:%M') programName = GetDisplayName(common.GetLabelColor('[{0}-{1}]'.format(start_time, end_time), keyColor="timesColor"), common.GetLabelColor(common.encode(program["name"].strip(),'utf-8'), keyColor="prColor", bold=True), channelNameFormat) description = common.encode(program["description"].strip(), 'utf-8') common.addDir(programName, 'epg', 99, iconimage, {"Title": programName, "Plot": description}, module=module, isFolder=False)
def Search(url, iconimage): search_entered = common.GetKeyboardText('מילים לחיפוש', '') if search_entered != '': url = url.format(search_entered.replace(' ', '%20')) params = GetJson(url) suggestions = params["suggestions"] data = params["data"] for i in range(len(suggestions)): if "mako-vod-channel2-news" in data[i]: continue url = "{0}{1}".format(baseUrl, data[i]) name = common.UnEscapeXML(common.encode(suggestions[i], "utf-8")) infos = {"Title": name, "Plot": name} if "VOD-" in data[i]: name = common.GetLabelColor(name, keyColor="chColor") common.addDir( name, url, 5, iconimage, infos, contextMenu=[(common.GetLocaleString( 30005 ), 'RunPlugin({0}?url={1}&name={2}&mode=5&iconimage={3}&moredata=choose&module=keshet)' .format(sys.argv[0], common.quote_plus(url), common.quote_plus(name), common.quote_plus(iconimage)))], moreData=bitrate, module='keshet', isFolder=False, isPlayable=True) else: name = common.GetLabelColor(name, keyColor="prColor", bold=True) common.addDir(name, url, 2, iconimage, infos, module=module) else: return
def GetGridList(iconimage, grid_id): url = '{0}/vod/'.format(baseUrl) result = GetUrlJson(url) if len(result) < 1: return episodes = [] series = [] postsIDs = [] posts = {} grids = result.get('Content', {}).get('PageGrid', {}) for grid in grids: if grid.get('grid_id') != int(grid_id): continue gridType = grid.get('GridType') if gridType is None or 'grid_content' not in gridType: continue title = grid.get('GridTitle') gridTitle = '' if title is None else common.encode(title.get('title', '').strip(), 'utf-8') titleLink = '' if title is None else title.get('link', '') gridLink = '' if titleLink is None else common.encode(str(titleLink).strip(), 'utf-8') if gridLink != '' and gridTitle != '' and gridLink != url: series.append((gridTitle, gridLink, iconimage, '', '')) for postsID in grid.get('Posts', {}): try: if postsID in postsIDs: continue post = result.get('ItemStore', {}).get(str(postsID), {}) link = post.get('link') title = common.encode(post['title'], 'utf-8') subtitle = common.encode(post['subtitle'], 'utf-8') icon = common.encode(post['images']['app_16x9'], 'utf-8') publishDate = post.get('publishDate') postType = post.get('postType', '') if postType == 'item': mode = 3 video = post.get('video') if video is None: continue link = '' if video.get('kaltura_videoID') is not None: link = '{0}--kaltura--{1}==='.format(link, video['kaltura_videoID']) if video.get('cst_videoID') is not None: if video['cst_videoID'] == '-1': link = '{0}--cst--{1}==='.format(link, video['cst_videoID']) else: link = '{0}--cst--{1}==='.format(link, video.get('videoRef', link)) if video.get('brv_videoID') is not None: link = '{0}--brv--{1}==='.format(link, video['brv_videoID']) if link == '': continue elif postType != 'page': continue else: mode = 1 if link == '' or link in posts: continue posts[link] = title postsIDs.append(postsID) if mode == 1: series.append((title, link, icon, subtitle, publishDate)) else: episodes.append((title, gridTitle, link, icon, subtitle, publishDate)) except Exception as ex: xbmc.log(str(ex), 3) break if sortBy == 1: series = sorted(series,key=lambda series: series[0]) #episodes = sorted(episodes,key=lambda episodes: episodes[0]) for title, link, icon, subtitle, publishDate in series: name = common.GetLabelColor(title, keyColor="prColor", bold=True) link = str(link) infos= {"Title": name, "Plot": subtitle, "Aired": publishDate} common.addDir(name, link, 1, icon, infos=infos, module=module) programNameFormat = int(Addon.getSetting("programNameFormat")) for title, gridTitle, link, icon, subtitle, publishDate in episodes: name = common.GetLabelColor(title, keyColor="chColor") if gridTitle is None or gridTitle == '' else common.getDisplayName(gridTitle, title, programNameFormat) link = str(link) infos= {"Title": name, "Plot": subtitle, "Aired": publishDate} common.addDir(name, link, 3, icon, infos=infos, contextMenu=[(common.GetLocaleString(30005), 'RunPlugin({0}?url={1}&name={2}&mode=3&iconimage={3}&moredata=choose&module=reshet)'.format(sys.argv[0], common.quote_plus(link), common.quote_plus(name), common.quote_plus(icon))), (common.GetLocaleString(30023), 'RunPlugin({0}?url={1}&name={2}&mode=3&iconimage={3}&moredata=set_reshet_res&module=reshet)'.format(sys.argv[0], common.quote_plus(link), common.quote_plus(name), common.quote_plus(icon)))], moreData=bitrate, module=module, isFolder=False, isPlayable=True)
def ShowFavorties(): if Addon.getSetting("showFavSort") == 'true': sortString = common.GetLocaleString( 30036) if sortBy == 0 else common.GetLocaleString(30003) name = "{0}: {1}".format(common.GetLocaleString(30001), sortString) common.addDir(name, "toggleSortingMethod", 15, iconimage, { "Title": name, "Plot": "{0}[CR]{1}[CR]{2} / {3}".format( name, common.GetLocaleString(30004), common.GetLocaleString(30036), common.GetLocaleString(30003)) }, isFolder=False) favoritesList = common.ReadList(favoritesFile) nowEPG = [] items = [] i = -1 for favorite in favoritesList: i += 1 u = common.encode(favorite, "utf-8") prms = dict(common.parse_qsl(u[u.find('?') + 1:])) url = common.unquote_plus(prms.get('url', '')) mode = int(prms.get('mode', '-1')) name = common.unquote_plus(prms.get('name', '')).replace('|||', '?') unColorName = common.GetUnColor(name) catName = common.unquote_plus(prms.get('catName', '')).replace('|||', '?') image = common.unquote_plus(prms.get('iconimage', '')) module = prms.get('module') moreData = common.unquote_plus(prms.get('moredata', '')) isFolder = prms.get('isFolder', 'False') == 'True' isPlayable = prms.get('isPlayable', 'False') == 'True' tvgID = prms.get('tvgID', '') contextMenu = [(common.GetLocaleString(30027), 'RunPlugin({0}?url={1}&mode=9)'.format(sys.argv[0], i))] if sortBy == 0: contextMenu.append( (common.GetLocaleString(30031), 'RunPlugin({0}?mode=11&url={1}&moredata=-1)'.format( sys.argv[0], i))) contextMenu.append( (common.GetLocaleString(30032), 'RunPlugin({0}?mode=11&url={1}&moredata=1)'.format( sys.argv[0], i))) contextMenu.append( (common.GetLocaleString(30033), 'RunPlugin({0}?mode=11&url={1}&moredata=0)'.format( sys.argv[0], i))) if tvgID != '': if nowEPG == []: nowEPG = epg.GetNowEPG() programs = nowEPG.get(tvgID, []) items.append((unColorName, common.GetUnColor(name), url, mode, image, module, contextMenu, moreData, programs, isFolder, isPlayable, True)) else: moduleName = GetModuleName(module, mode, moreData, catName) if moduleName != '': name = '{0} - {1}'.format( common.GetLabelColor(moduleName, keyColor='timesColor', bold=True), name) items.append( (unColorName, name, url, mode, image, module, contextMenu, moreData, [], isFolder, isPlayable, False)) if sortBy == 1: items = sorted(items, key=lambda items: items[0]) for unColorName, name, url, mode, image, module, contextMenu, moreData, programs, isFolder, isPlayable, isLive in items: if isLive: LiveChannel(name, url, mode, image, module, contextMenu=contextMenu, bitrate=moreData, programs=programs, addFav=False) else: common.addDir(name, url, mode, image, infos={"Title": name}, contextMenu=contextMenu, moreData=moreData, module=module, isFolder=isFolder, isPlayable=isPlayable, addFav=False)
def GetLinks(url, result, iconimage): seasons = collections.OrderedDict() if common.NewerThanPyVer('2.6.99') else {} episodes = [] subMenus = result.get('Header', {}).get('subMenu', {}) if subMenus: for subMenu in subMenus: try: title = subMenu.get('title') link = subMenu.get('url') ending = link[link.rfind('/', 0, len(link)-1):] if 'episodes' in ending or 'season' in ending and (link not in seasons or seasons[link] == ''): seasons[link] = common.encode(title.strip(), 'utf-8') except Exception as ex: xbmc.log(str(ex), 3) grids = result.get('Content', {}).get('PageGrid', {}) for grid in grids: title = grid.get('GridTitle') gridTitle = '' if title is None else common.encode(title.get('title', '').strip(), 'utf-8') titleLink = '' if title is None else title.get('link', '') gridLink = '' if titleLink is None else common.encode(str(titleLink).strip(), 'utf-8') if 'episodes' in gridLink and (gridLink not in seasons or seasons[gridLink] == ''): seasons[gridLink] = gridTitle if gridTitle != '' else common.encode(result.get('PageMeta', {}).get('title', '').strip(), 'utf-8') elif gridLink != '' and gridTitle != '' and gridLink != url: seasons[gridLink] = gridTitle for pid in grid.get('Posts', {}): try: post = result.get('ItemStore', {}).get(str(pid), {}) link = post['link'].replace('vod-2', 'vod').replace('/channel2/', '/channel2-news/') if 'episodes' not in link and '/movies/' not in link: ending = link[link.rfind('/', 0, len(link)-1):] if 'season' in ending and (link not in seasons or seasons[link] == ''): seasons[link] = common.encode(post.get('title', '').strip(), 'utf-8') if post['postType'] != 'item': continue if 'links' in post['postType'] and link not in seasons: seasons[link] = common.encode(post.get('title', '').strip(), 'utf-8') else: if '/episodes/' in link: seasonsLink = link[:link.find('/episodes/') + 10].replace('/item', '') match = re.compile('/season-(\d+)(.*?)/').findall(seasonsLink) if len(match) > 0 and match[0][1] != '': seasonsLink = seasonsLink.replace(match[0][1], '') if seasonsLink not in seasons and '/movies/' not in link: page_2_level_heb = post['coolaData'].get('page_2_level_heb') page_2_level_heb = '' if page_2_level_heb is None else common.encode(page_2_level_heb, 'utf-8') page_3_level_heb = post['coolaData'].get('page_3_level_heb') page_3_level_heb = '' if page_3_level_heb is None else common.encode(page_3_level_heb, 'utf-8') page_4_level_heb = post['coolaData'].get('page_4_level_heb') page_4_level_heb = '' if page_4_level_heb is None else common.encode(page_4_level_heb, 'utf-8') seasons[seasonsLink] = '{0} {1} {2}'.format(page_2_level_heb, page_3_level_heb, page_4_level_heb) video = post.get('video') if video is None: continue videoID = '' if video.get('kaltura_videoID') is not None: videoID = '{0}--kaltura--{1}==='.format(videoID, video['kaltura_videoID']) if video.get('cst_videoID') is not None: if video['cst_videoID'] == '-1': videoID = '{0}--cst--{1}==='.format(videoID, video['cst_videoID']) else: videoID = '{0}--cst--{1}==='.format(videoID, video.get('videoRef', videoID)) if video.get('brv_videoID') is not None: videoID = '{0}--brv--{1}==='.format(videoID, video['brv_videoID']) if videoID == '': continue icon = common.encode(post['images'].get('app_16x9', iconimage), 'utf-8') episodes.append((gridTitle, videoID, icon, common.encode(post.get('title', '').strip(), 'utf-8'), common.encode(post.get('subtitle', '').strip(), 'utf-8'), post.get('publishDate'))) except Exception as ex: xbmc.log(str(ex), 3) return seasons, episodes
def GetSeriesList(catName, url, iconimage): url = "{0}&{1}".format(url, endings) if "?" in url else "{0}?{1}".format( url, endings) prms = GetJson(url) if prms is None: "Cannot get {0} list".format(catName) return key2 = None picKey = "picI" if catName == "תכניות MakoTV": key1 = "allPrograms" picKey = "picVOD" elif catName == "אוכל" or catName == common.GetLocaleString(30608): key1 = "specialArea" key2 = "items" elif catName == "הופעות" or catName == "הרצאות" or catName == "דוקומנטרי - סרטים": key1 = "moreVOD" key2 = "items" else: key1 = "moreVOD" key2 = "programItems" if key2 is None: series = prms.get(key1, {}) else: series = prms.get(key1, {}).get(key2, {}) seriesCount = len(series) programNameFormat = int(Addon.getSetting("programNameFormat")) for serie in series: try: mode = 2 title = common.encode(serie.get("title", "").strip(), "utf-8") subtitle = common.encode( serie.get("subtitle", "").strip(), "utf-8") url = serie.get("url", "") if url == "": url = serie.get("link", "") url = "{0}{1}".format(baseUrl, url) if "VOD-" in url: mode = 5 title = common.getDisplayName( title, subtitle, programNameFormat, bold=False ) if makoShowShortSubtitle and subtitle != "" else common.GetLabelColor( title, keyColor="prColor", bold=False) else: title = common.GetLabelColor(title, keyColor="prColor", bold=True) icon = GetImage(serie, picKey, iconimage) description = common.encode( serie.get("brief", "").strip(), "utf-8") if "plot" in serie: description = "{0} - {1}".format( description, common.encode(serie["plot"].strip(), "utf-8")) infos = {"Title": title, "Plot": description} if mode == 2: common.addDir(title, url, 2, icon, infos, module=module, totalItems=seriesCount) else: common.addDir( title, url, 5, icon, infos, contextMenu=[(common.GetLocaleString( 30005 ), 'RunPlugin({0}?url={1}&name={2}&mode=5&iconimage={3}&moredata=choose&module=keshet)' .format(sys.argv[0], common.quote_plus(url), common.quote_plus(title), common.quote_plus(icon)))], moreData=bitrate, module='keshet', isFolder=False, isPlayable=True) except Exception as ex: xbmc.log(str(ex), 3) if sortBy == 1: xbmcplugin.addSortMethod(handle, xbmcplugin.SORT_METHOD_LABEL)
def GetEpisodesList(url, icon, moreData=""): url = "{0}&{1}".format(url, endings) if "?" in url else "{0}?{1}".format( url, endings) prms = GetJson(url) if prms is None or "channelId" not in prms or "programData" not in prms or "seasons" not in prms[ "programData"]: xbmc.log("Cannot get Seasons list", 2) return programNameFormat = int(Addon.getSetting("programNameFormat")) videoChannelId = prms["channelId"] grids_arr = [] for prm in prms["programData"]["seasons"]: if prm is None or "vods" not in prm or "id" not in prm or prm[ "id"].lower() != moreData.lower(): continue episodesCount = len(prm["vods"]) for episode in prm["vods"]: try: vcmid = episode["guid"] name = common.getDisplayName( common.encode(episode["title"], "utf-8"), common.encode(episode["shortSubtitle"], "utf-8"), programNameFormat ) if makoShowShortSubtitle else common.GetLabelColor( common.encode(episode["title"], "utf-8"), keyColor="prColor", bold=False) url = "{0}/VodPlaylist?vcmid={1}&videoChannelId={2}".format( baseUrl, vcmid, videoChannelId) iconimage = GetImage(episode, 'picI', icon) description = common.encode(episode.get('subtitle', ''), "utf-8") i = episode["date"].find('|') if i < 0: aired = episode["date"][episode["date"].find(' ') + 1:] else: a = episode["date"][:i].strip().split('/') aired = '20{0}-{1}-{2}'.format(a[2], a[1], a[0]) infos = {"Title": name, "Plot": description, "Aired": aired} grids_arr.append((aired, name, url, iconimage, infos, [ (common.GetLocaleString(30005), 'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=choose&module=keshet)' .format(sys.argv[0], common.quote_plus(url), common.quote_plus(name), common.quote_plus(iconimage))), (common.GetLocaleString(30023), 'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=set_mako_res&module=keshet)' .format(sys.argv[0], common.quote_plus(url), common.quote_plus(name), common.quote_plus(iconimage))) ])) except Exception as ex: xbmc.log(str(ex), 3) grids_sorted = sorted(grids_arr, key=lambda grids_arr: grids_arr[0]) grids_sorted.reverse() for aired, name, url, iconimage, infos, contextMenu in grids_sorted: common.addDir(name, url, 4, iconimage, infos, contextMenu=contextMenu, moreData=bitrate, module='keshet', isFolder=False, isPlayable=True)
def GetQuoteUrl(url): b = url.rfind('/') e = url.rfind(".") n = url[b + 1:e] url = url[:b + 1] + common.quote(common.encode(n, 'utf-8')) + url[e:] return url
def LiveChannel(name, url, mode, iconimage, module, contextMenu=[], choose=True, resKey='', bitrate='', programs=[], tvgID='', addFav=True): channelNameFormat = int(Addon.getSetting("channelNameFormat")) displayName = common.GetLabelColor(name, keyColor="chColor", bold=True) description = '' iconimage = os.path.join(imagesDir, iconimage) if len(programs) > 0: contextMenu.insert(0, (common.GetLocaleString( 30030 ), 'Container.Update({0}?url={1}&name={2}&mode=2&iconimage={3}&module=epg)' .format(sys.argv[0], tvgID, common.quote_plus(name), common.quote_plus(iconimage)))) programTime = common.GetLabelColor("[{0}-{1}]".format( datetime.datetime.fromtimestamp( programs[0]["start"]).strftime('%H:%M'), datetime.datetime.fromtimestamp( programs[0]["end"]).strftime('%H:%M')), keyColor="timesColor") programName = common.GetLabelColor(common.encode( programs[0]["name"], 'utf-8'), keyColor="prColor", bold=True) displayName = GetChannelName(programName, programTime, displayName, channelNameFormat) description = '{0}[CR]{1}'.format( programName, common.encode(programs[0]["description"], 'utf-8')) if len(programs) > 1: nextProgramName = common.GetLabelColor(common.encode( programs[1]["name"], 'utf-8'), keyColor="prColor", bold=True) nextProgramTime = common.GetLabelColor("[{0}-{1}]".format( datetime.datetime.fromtimestamp( programs[1]["start"]).strftime('%H:%M'), datetime.datetime.fromtimestamp( programs[1]["end"]).strftime('%H:%M')), keyColor="timesColor") description = GetDescription(description, nextProgramTime, nextProgramName, channelNameFormat) if resKey == '' and bitrate == '': bitrate = 'best' else: if bitrate == '': bitrate = Addon.getSetting(resKey) if bitrate == '': bitrate = 'best' if addFav: contextMenu.insert(0, (common.GetLocaleString( 30023 ), 'RunPlugin({0}?url={1}&name={2}&mode={3}&iconimage={4}&moredata=set_{5}&module={6})' .format(sys.argv[0], url, common.quote_plus(displayName), mode, common.quote_plus(iconimage), resKey, module))) if choose: contextMenu.insert(0, (common.GetLocaleString( 30005 ), 'RunPlugin({0}?url={1}&name={2}&mode={3}&iconimage={4}&moredata=choose&module={5})' .format(sys.argv[0], url, common.quote_plus(displayName), mode, common.quote_plus(iconimage), module))) if contextMenu == []: contextMenu = None urlParamsData = { 'name': common.GetLabelColor(name, keyColor="chColor", bold=True), 'tvgID': tvgID } if addFav else {} common.addDir(displayName, url, mode, iconimage, infos={ "Title": displayName, "Plot": description }, contextMenu=contextMenu, moreData=bitrate, module=module, isFolder=False, isPlayable=True, addFav=addFav, urlParamsData=urlParamsData)