예제 #1
0
파일: keshet.py 프로젝트: sndmaster/oper
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)
예제 #2
0
def GetRadioEpisodesList(url):
    data = GetRadioData()
    for id in data[url]['children']:
        episode = data[id]
        name = common.GetLabelColor(episode['name'], keyColor="chColor")
        desc = episode.get('description', '')
        link = episode['url'].replace(u'\u200f', '')
        iconimage = '{0}/{1}'.format(radioUrl, episode['imageUrl'])
        common.addDir(
            name,
            link,
            23,
            iconimage,
            infos={
                "Title": name,
                "Plot": desc,
                "Aired": episode['time']
            },
            contextMenu=
            [(common.GetLocaleString(30005),
              'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=choose&module={4})'
              .format(sys.argv[0], common.quote_plus(link), name,
                      common.quote_plus(iconimage), module)),
             (common.GetLocaleString(30023),
              'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=set_{4}_res&module={4})'
              .format(sys.argv[0], common.quote_plus(link), name,
                      common.quote_plus(iconimage), module))],
            module=module,
            moreData=bitrate,
            isFolder=False,
            isPlayable=True)
예제 #3
0
파일: keshet.py 프로젝트: sndmaster/oper
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
예제 #4
0
def GetEpisodesList(url, image):
    bitrate = Addon.getSetting('twenty_res')
    if bitrate == '':
        bitrate = 'best'
    text = common.OpenURL(url)
    episodes = re.compile(
        '<div class="katan-unit(.*?)</div>\s*</div>\s*</div>',
        re.S).findall(text)
    for episode in episodes:
        match = re.compile(
            'data-videoid="(.*?)".*?src="(.*?)".*?<div class="the-title">(.*?)</div>',
            re.S).findall(episode)
        for videoid, iconimage, name in match:
            name = common.GetLabelColor(common.UnEscapeXML(name.strip()),
                                        keyColor="chColor")
            iconimage = GetQuoteUrl(iconimage)
            link = 'https://cdn.ch20-cdnwiz.com/ch20/player.php?clipid={0}&autoplay=true&automute=false'.format(
                videoid.strip())
            common.addDir(
                name,
                link,
                2,
                iconimage,
                infos={"Title": name},
                contextMenu=
                [(common.GetLocaleString(30005),
                  'RunPlugin({0}?url={1}&name={2}&mode=2&iconimage={3}&moredata=choose&module={4})'
                  .format(sys.argv[0], common.quote_plus(link), name,
                          common.quote_plus(iconimage), module)),
                 (common.GetLocaleString(30023),
                  'RunPlugin({0}?url={1}&name={2}&mode=2&iconimage={3}&moredata=set_twenty_res&module={4})'
                  .format(sys.argv[0], common.quote_plus(link), name,
                          common.quote_plus(iconimage), module))],
                module=module,
                moreData=bitrate,
                isFolder=False,
                isPlayable=True)
예제 #5
0
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)
예제 #6
0
def ShowEpisodes(episodes, iconimage):
	if len(episodes) < 1:
		name = 'אין פרקים מלאים'
		common.addDir(name, '', 99, iconimage, infos={"Title": name}, module=module, isFolder=False)
		return
	programNameFormat = int(Addon.getSetting("programNameFormat"))
	#for gridTitle, link, icon, title, subtitle, publishDate in sorted(episodes,key=lambda episodes: episodes[5]):#reversed(episodes):
	for gridTitle, link, icon, title, 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)
		common.addDir(name, link, 3, icon, infos={"Title": name, "Plot": subtitle, "Aired": publishDate}, 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)
예제 #7
0
def GetSeasonList(id, iconimage):
    category = GetCategories()
    ids = id.split(';')
    for i in range(len(ids)):
        category = GetCategory(ids[i], category)
    if 'Category' in category:
        catName = common.GetLabelColor(category['Name'],
                                       keyColor="prColor",
                                       bold=True)
        if not isinstance(category['Category'], list):
            name = '{0} - {1}'.format(
                catName,
                common.GetLabelColor(category['Category']['Name'],
                                     keyColor="timesColor",
                                     bold=True))
            common.addDir(name,
                          '{0};{1}'.format(id, category['Category']['ID']),
                          1,
                          iconimage,
                          infos={"Title": name},
                          module=module)
        else:
            for season in category['Category']:
                name = '{0} - {1}'.format(
                    catName,
                    common.GetLabelColor(season['Name'],
                                         keyColor="timesColor",
                                         bold=True))
                common.addDir(name,
                              '{0};{1}'.format(id, season['ID']),
                              1,
                              iconimage,
                              infos={"Title": name},
                              module=module)
    if len(ids) > 1:
        category = GetSubCategory(category['ID'])
    if 'Items' in category:
        for item in category['Items']['Item']:
            name = common.GetLabelColor(item['title'],
                                        keyColor="chColor",
                                        bold=True)
            link = item['stream_url'] if 'http' in item[
                'stream_url'] else item['stream_url_bak']
            common.addDir(
                name,
                link,
                4,
                item['img_upload'],
                infos={
                    "Title": name,
                    'Plot': item['abstract']
                },
                contextMenu=
                [(common.GetLocaleString(30005),
                  'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=choose&module={4})'
                  .format(sys.argv[0], common.quote_plus(link), name,
                          common.quote_plus(item['img_upload']), module)),
                 (common.GetLocaleString(30023),
                  'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=set_{4}_res&module={4})'
                  .format(sys.argv[0], common.quote_plus(link), name,
                          common.quote_plus(item['img_upload']), module))],
                module=module,
                moreData=bitrate,
                isFolder=False,
                isPlayable=True)
예제 #8
0
파일: keshet.py 프로젝트: sndmaster/oper
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)
예제 #9
0
파일: keshet.py 프로젝트: sndmaster/oper
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)
예제 #10
0
파일: sport1.py 프로젝트: sndmaster/oper
def GetEpisodes(text):
	#raw_unicode_escape = False
	#match = []#re.compile(u'<main id="main"(.*?)</main>', re.S).findall(text)
	#if len(match) < 1:
	match = re.compile(u'pageGlobals.*?"id":(.*?),').findall(text)
	link = 'https://sport1.maariv.co.il/wp-json/sport1/v1/league/{0}/video/content?is_mobile=false&rows=800'.format(match[0])
	text = common.OpenURL(link)
	match[0] = text.replace('\\"', '"').replace('\/', '/')
	#raw_unicode_escape = True
	match = re.compile(u'<div class="video-card(.*?)</a>', re.S).findall(match[0])
	for item in match:
		m = re.compile("<a href=['\"](.*?)['\"].*?<img(.*?)>.*?<h3.*?>(.*?)</h3>", re.S).findall(item)
		if len(m) < 1:
			continue
		url, icon, name = m[0]
		m = re.compile(u'data-lazy="(.*?)"', re.S).findall(icon)
		if len(m) < 1:
			m = re.compile(u'src=["\'](.*?)["\']', re.S).findall(icon)
		icon = m[0]
		#if raw_unicode_escape:
		name = common.decode(name, 'raw_unicode_escape', force=True)
		url = common.decode(url, 'raw_unicode_escape', force=True)
		icon = common.decode(icon, 'raw_unicode_escape', force=True)
		name = common.GetLabelColor(common.UnEscapeXML(name.strip()), keyColor="chColor", bold=True)
		try:
			common.addDir(name, url.replace(baseUrl, ''), 4, icon, infos={"Title": name}, contextMenu=[(common.GetLocaleString(30005), 'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=choose&module={4})'.format(sys.argv[0], common.quote_plus(url), name, common.quote_plus(icon), module)), (common.GetLocaleString(30023), 'RunPlugin({0}?url={1}&name={2}&mode=4&iconimage={3}&moredata=set_{4}_res&module={4})'.format(sys.argv[0], common.quote_plus(url), name, common.quote_plus(icon), module))], module=module, moreData=bitrate, isFolder=False, isPlayable=True)
		except Exception as ex:
			xbmc.log(str(ex), 3)
예제 #11
0
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)