Example #1
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)
Example #2
0
def ShowPaging(grids, page_url, iconimage, mode):
	WpQuery = grids[0].get('WpQuery', None)
	if WpQuery is None:
		paged = 0  
	else: 
		paged = WpQuery.get('paged', 0)
	if paged > 0 and  len(grids) > 0:
		max_page = grids[0].get('max_page', 0)
		if paged > 1:
			prev_page = page_url + 'page/' + str(paged-1) + '/' if paged - 1 > 1 else page_url
			common.addDir(common.GetLabelColor(common.GetLocaleString(30011), color="green"), prev_page, mode, iconimage, module=module)
		if max_page > paged:
			common.addDir(common.GetLabelColor(common.GetLocaleString(30012), color="green"), page_url + 'page/' + str(paged+1) + '/', mode, iconimage, module=module)
Example #3
0
def MakeIPTVlist(channels):
	if Addon.getSetting("useIPTV") != 'true':
		return
	iptvList = '#EXTM3U\n'
	for channel in channels:
		try:
			type = channel.get('type', '')
			if type != 'radio' and type != 'tv':
				continue
			tvg_id = channel["tvgID"]
			view_name = common.GetLocaleString(channel['nameID'])
			tvg_logo = 'special://home/addons/{0}/resources/images/{1}'.format(common.AddonID, channel['image'])
			if type == 'radio':
				radio = ' radio="true"'
				group = ' group-title="Radio"'
			elif type == 'tv': 
				radio = ''
				group = ' group-title="TV"'
			url = '{0}?mode=5&url={1}'.format(sys.argv[0], channel['ch'])
			iptvList += '\n#EXTINF:-1 tvg-id="{0}"{1} tvg-logo="{2}"{3},{4}\n{5}\n'.format(tvg_id, group, tvg_logo, radio, view_name, url)
		except Exception as ex:
			xbmc.log("{0}".format(ex), 3)
	iptvListOld = ''
	if os.path.isfile(m3uFile):
		with io.open(m3uFile, 'r', encoding="utf-8") as f:
			iptvListOld = f.read()
	if iptvListOld != iptvList:
		with io.open(m3uFile, 'w', encoding="utf-8") as f:
			f.write(common.uni_code(iptvList))
Example #4
0
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)
Example #5
0
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)
Example #6
0
def AddFavorite(url):
    favoritesList = common.ReadList(favoritesFile)
    if any(u == url for u in favoritesList):
        return
    favoritesList.append(common.decode(url, "utf-8"))
    common.WriteList(favoritesFile, favoritesList)
    xbmc.executebuiltin("Notification({0}, {1}, 5000, {2})".format(
        AddonName, common.GetLocaleString(30028), icon))
Example #7
0
def RemoveFavortie(index):
    favoritesList = common.ReadList(favoritesFile)
    if index < 0 or index >= len(favoritesList):
        return
    favoritesList.remove(favoritesList[index])
    common.WriteList(favoritesFile, favoritesList)
    xbmc.executebuiltin("Notification({0}, {1}, 5000, {2})".format(
        AddonName, common.GetLocaleString(30029), icon))
    xbmc.executebuiltin("Container.Refresh()")
Example #8
0
def GetCategoriesList(iconimage):
    sortString = common.GetLocaleString(
        30002) if sortBy == 0 else common.GetLocaleString(30003)
    name = "{0}: {1}".format(common.GetLocaleString(30001), sortString)
    common.addDir(
        name,
        "toggleSortingMethod",
        4,
        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)
    name = common.GetLabelColor("כל התכניות", bold=True, color="none")
    common.addDir(name,
                  '',
                  0,
                  iconimage,
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכניות ערוץ מורשת 20"
                  },
                  module=module)
Example #9
0
def LiveChannels():
    if Addon.getSetting("tvShortcut") == 'true':
        name = common.GetLabelColor(common.GetLocaleString(30652),
                                    bold=True,
                                    color="none")
        common.addDir(name,
                      'ActivateWindow',
                      6,
                      icon,
                      infos={"Title": name},
                      moreData='tvchannels',
                      isFolder=False)
    nowEPG = epg.GetNowEPG()
    channels = GetUserChannels(type='tv')
    for channel in channels:
        if channel.get('type') == 'refresh':
            name = common.GetLabelColor(common.GetLocaleString(
                channel['nameID']),
                                        bold=True,
                                        color="none")
            common.addDir(name,
                          'Container.Refresh',
                          channel['mode'],
                          channel['image'],
                          infos={"Title": name},
                          moreData=';noexit',
                          isFolder=False)
        else:
            programs = [] if channel['tvgID'] == '' else nowEPG.get(
                channel['tvgID'], [])
            LiveChannel(common.GetLocaleString(channel['nameID']),
                        channel['channelID'],
                        channel['mode'],
                        channel['image'],
                        channel['module'],
                        contextMenu=[],
                        resKey=channel['resKey'],
                        programs=programs,
                        tvgID=channel['tvgID'])
Example #10
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)
Example #11
0
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)
Example #12
0
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
Example #13
0
def VODs():
    name = common.GetLabelColor(common.GetLocaleString(30602),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  0,
                  os.path.join(imagesDir, "kan.jpg"),
                  infos={"Title": name},
                  module='kan')
    name = common.GetLabelColor(common.GetLocaleString(30603),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  0,
                  os.path.join(imagesDir, "mako.png"),
                  infos={"Title": name},
                  module='keshet')
    name = common.GetLabelColor(common.GetLocaleString(30604),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  -1,
                  os.path.join(imagesDir, "13.png"),
                  infos={"Title": name},
                  module='reshet')
    name = common.GetLabelColor(common.GetLocaleString(30606),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  -1,
                  os.path.join(imagesDir, "20.png"),
                  infos={"Title": name},
                  module='twenty')
    name = common.GetLabelColor(common.GetLocaleString(30607),
                                bold=True,
                                color="none")
    common.addDir(name,
                  'https://www.kankids.org.il',
                  5,
                  os.path.join(imagesDir, "23tv.jpg"),
                  infos={"Title": name},
                  module='kan')
    name = common.GetLabelColor(common.GetLocaleString(30608),
                                bold=True,
                                color="none")
    common.addDir(name,
                  'http://www.mako.co.il/mako-vod-music24',
                  1,
                  os.path.join(imagesDir, "24telad.png"),
                  infos={"Title": name},
                  module='keshet')
    name = common.GetLabelColor(common.GetLocaleString(30630),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  0,
                  os.path.join(imagesDir, "9tv.png"),
                  infos={"Title": name},
                  module='9tv')
    name = common.GetLabelColor(common.GetLocaleString(30900),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  -1,
                  os.path.join(imagesDir, "Sport5.png"),
                  infos={"Title": name},
                  module='sport5')
    name = common.GetLabelColor(common.GetLocaleString(31000),
                                bold=True,
                                color="none")
    common.addDir(name,
                  '',
                  -1,
                  os.path.join(imagesDir, "sport1.jpg"),
                  infos={"Title": name},
                  module='sport1')
Example #14
0
def GetEpisodesList(data, iconimage, moreData=''):
    d = data.split(';')
    catId = d[0]
    page = 0 if len(d) < 2 else int(d[1])
    stopPage = page + pagesPerList
    prevPage = page - pagesPerList if page > pagesPerList else 0
    md = moreData.split('|||')
    site = md[0]
    catName = '' if len(md) < 2 else md[1]
    if site == 'youtube':
        xbmc.executebuiltin('container.Update({0}/playlist/{1}/)'.format(
            youtubePlugin, catId))
        return
    bitrate = Addon.getSetting('kan_res')
    if bitrate == '':
        bitrate = 'best'
    while True:
        page += 1
        url = '{0}/Program/getMoreProgram.aspx?count={1}&catId={2}'.format(
            baseUrl, page, catId)
        text = common.OpenURL(url)
        if 'ol' not in text:
            if page > pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(catId, prevPage),
                              2,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': catName})
            break
        matches = re.compile(
            'w-clearfix">.*?url\(\'(.+?)\'.+?onclick="playVideo\(\'.*?\',\'.*?\',\'(\d*)\'.+?<iframe.+?src="(.+?)".+?"content_title">(.+?)</.+?<p>(.+?)</p>',
            re.S).findall(text)
        for image, id, url, name, description in matches:
            name = common.GetLabelColor(name.strip(), keyColor="chColor")
            common.addDir(name,
                          '{0}|||{1}'.format(url, id),
                          3,
                          image,
                          infos={
                              "Title": name,
                              "Plot": description.replace('&nbsp;',
                                                          '').strip()
                          },
                          module=module,
                          moreData=bitrate,
                          isFolder=False,
                          isPlayable=True,
                          urlParamsData={'catName': catName})
        if page == stopPage:
            if page > pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(catId, prevPage),
                              2,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': catName})
            name = common.GetLabelColor(common.GetLocaleString(30012),
                                        color="green")
            common.addDir(name,
                          '{0};{1}'.format(catId, page),
                          2,
                          iconimage,
                          infos={
                              "Title": name,
                              "Plot": name
                          },
                          module=module,
                          urlParamsData={'catName': catName})
            break
Example #15
0
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)
Example #16
0
def GetCategoriesList(iconimage):
    sortString = common.GetLocaleString(
        30002) if sortBy == 0 else common.GetLocaleString(30003)
    name = "{0}: {1}".format(common.GetLocaleString(30001), sortString)
    common.addDir(name,
                  "toggleSortingMethod",
                  7,
                  iconimage,
                  infos={
                      "Title":
                      name,
                      "Plot":
                      "{0}[CR]{1}[CR]{2} / {3}".format(
                          name, common.GetLocaleString(30004),
                          common.GetLocaleString(30002),
                          common.GetLocaleString(30003))
                  },
                  module=module,
                  isFolder=False)
    name = "חיפוש"
    common.addDir(
        name,
        "{0}/autocomplete/vodAutocompletion.ashx?query={{0}}&max=60&id=query".
        format(baseUrl),
        6,
        os.path.join(imagesDir, 'search.jpg'),
        infos={
            "Title": name,
            "Plot": "חיפוש"
        },
        module=module)
    name = common.GetLabelColor("תכניות MakoTV", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-index".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'vod.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכני MakoTV"
                  },
                  module=module)
    name = common.GetLabelColor("לייף סטייל", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-more/lifestyle".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'lifestyle.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכניות לייף סטייל"
                  },
                  module=module)
    name = common.GetLabelColor("אוכל", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-special/cook-with-keshet".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'lifestyle.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכניות בנושא אוכל"
                  },
                  module=module)
    name = common.GetLabelColor("דוקומנטרי - תכניות", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-more/docu_tv".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'docu.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכנים דוקומנטריים"
                  },
                  module=module)
    name = common.GetLabelColor("דוקומנטרי - סרטים", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-more/docu_tv".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'docu.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכנים דוקומנטריים"
                  },
                  module=module)
    name = common.GetLabelColor("הופעות", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-more/concerts".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'live-music.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בהופעות חיות"
                  },
                  module=module)
    name = common.GetLabelColor("הרצאות", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-more/lectures".format(baseUrl),
                  1,
                  os.path.join(imagesDir, 'lectures.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בהרצאות"
                  },
                  module=module)
    name = common.GetLabelColor(common.GetLocaleString(30608),
                                bold=True,
                                color="none")
    common.addDir(name,
                  "{0}/mako-vod-music24".format(baseUrl),
                  1,
                  os.path.join(imagesDir, '24telad.png'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכניות מערוץ 24 החדש"
                  },
                  module=module)
    name = common.GetLabelColor("החדשות", bold=True, color="none")
    common.addDir(name,
                  "{0}/mako-vod-channel2-news".format(baseUrl),
                  2,
                  os.path.join(imagesDir, 'news.jpg'),
                  infos={
                      "Title": name,
                      "Plot": "צפיה בתכניות מערוץ החדשות"
                  },
                  module=module)
Example #17
0
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)
Example #18
0
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)
Example #19
0
def GetCategoriesList(iconimage):
    sortString = common.GetLocaleString(
        30002) if sortBy == 0 else common.GetLocaleString(30003)
    name = "{0}: {1}".format(common.GetLocaleString(30001), sortString)
    common.addDir(
        name,
        "toggleSortingMethod",
        4,
        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)
    name = common.GetLabelColor("כל התוכניות", bold=True, color="none")
    common.addDir(name,
                  '{0}/page.aspx?landingpageId=1039'.format(baseUrl),
                  1,
                  iconimage,
                  infos={"Title": name},
                  module=module,
                  moreData=common.GetLocaleString(30602))
    name = common.GetLabelColor("תוכניות אקטואליה", bold=True, color="none")
    common.addDir(name,
                  '{0}/page.aspx?landingPageId=1037'.format(baseUrl),
                  1,
                  iconimage,
                  infos={"Title": name},
                  module=module,
                  moreData=common.GetLocaleString(30602))
    name = common.GetLabelColor("דיגיטל", bold=True, color="none")
    common.addDir(name,
                  '{0}/page.aspx?landingPageId=1041'.format(baseUrl),
                  1,
                  iconimage,
                  infos={"Title": name},
                  module=module,
                  moreData=common.GetLocaleString(30602))
    name = common.GetLabelColor("כאן חינוכית 23", bold=True, color="none")
    common.addDir(name,
                  'https://www.kankids.org.il',
                  5,
                  iconimage,
                  infos={"Title": name},
                  module=module,
                  moreData=common.GetLocaleString(30607))
    name = common.GetLabelColor("תכניות רדיו", bold=True, color="none")
    common.addDir(name,
                  '',
                  21,
                  iconimage,
                  infos={"Title": name},
                  module=module)
    name = common.GetLabelColor("פודקאסטים", bold=True, color="none")
    common.addDir(name,
                  '',
                  31,
                  iconimage,
                  infos={"Title": name},
                  module=module)
    name = common.GetLabelColor("פודקאסטים לילדים", bold=True, color="none")
    common.addDir(name,
                  '',
                  33,
                  iconimage,
                  infos={"Title": name},
                  module=module)
Example #20
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)
Example #21
0
def GetModuleName(module, mode, moreData, catName=''):
    mode = str(mode)
    moduleName = ''
    if module == 'kan':
        moduleName = common.GetLocaleString(
            30400) if catName == '' else catName
    elif module == 'keshet':
        moduleName = common.GetLocaleString(30603)
    elif module == 'reshet':
        moduleName = common.GetLocaleString(30604)
    elif module == 'twenty':
        moduleName = common.GetLocaleString(30606)
    elif module == '9tv':
        moduleName = common.GetLocaleString(30630)
    elif module == '891fm':
        moduleName = common.GetLocaleString(30734)
    elif module == 'sport5':
        moduleName = common.GetLocaleString(30632)
    elif module == 'sport1':
        moduleName = common.GetLocaleString(31000)
    elif module == '99fm':
        moduleName = common.GetLocaleString(30704)
    elif module == 'glz':
        moduleName = common.GetLocaleString(30702)
    elif module == '100fm':
        moduleName = common.GetLocaleString(30726)
    return moduleName
Example #22
0
def GetPodcastEpisodesList(data, iconimage):
    d = data.split(';')
    progId = d[0]
    page = -1 if len(d) < 2 else int(d[1])
    stopPage = page + 1 + pagesPerList
    prevPage = page - pagesPerList if page >= pagesPerList else -1
    while True:
        page += 1
        url = '{0}/Podcast/getMorePodcasts.aspx?index={1}&leftToRight=0&progId={2}'.format(
            baseUrl, page, progId)
        text = common.OpenURL(url)
        matches = re.compile(
            '<iframe src="(.+?)embed.+?<h2.+?>(.+?)</h2>.+?<p.+?>(.*?)</p>',
            re.S).findall(text)
        for link, name, description in matches:
            name = common.GetLabelColor(name.strip(), keyColor="chColor")
            common.addDir(name,
                          link,
                          3,
                          iconimage,
                          infos={
                              "Title": name,
                              "Plot": description.replace('&nbsp;',
                                                          '').strip()
                          },
                          module=module,
                          isFolder=False,
                          isPlayable=True,
                          urlParamsData={'catName': 'כאן פודקאסטים'})
        if len(matches) < 10:
            if page >= pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(progId, prevPage),
                              32,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': 'כאן פודקאסטים'})
            break
        if page + 1 == stopPage:
            if page >= pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(progId, prevPage),
                              32,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': 'כאן פודקאסטים'})
            name = common.GetLabelColor(common.GetLocaleString(30012),
                                        color="green")
            common.addDir(name,
                          '{0};{1}'.format(progId, page),
                          32,
                          iconimage,
                          infos={
                              "Title": name,
                              "Plot": name
                          },
                          module=module,
                          urlParamsData={'catName': 'כאן פודקאסטים'})
            break
Example #23
0
def GetPodcastsList(page, iconimage):
    page = -1 if page == '' else int(page)
    stopPage = page + 1 + pagesPerList
    prevPage = page - pagesPerList if page >= pagesPerList else -1
    while True:
        page += 1
        url = '{0}/podcast/morePrograms.aspx?index={1}'.format(baseUrl, page)
        text = common.OpenURL(url)
        matches = re.compile(
            'title="(.+?)".+?url\(\'(.+?)\'.+?href=".+?\?progId=(.+?)".+?<p.+?>(.*?)</p>',
            re.S).findall(text)
        for name, image, id, description in matches:
            name = common.GetLabelColor(name.strip(),
                                        keyColor="prColor",
                                        bold=True)
            common.addDir(name,
                          id,
                          32,
                          image,
                          infos={
                              "Title": name,
                              "Plot": description.replace('&nbsp;',
                                                          '').strip()
                          },
                          module=module,
                          urlParamsData={'catName': 'כאן פודקאסטים'})
        if len(matches) < 10:
            if page >= pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              str(prevPage),
                              31,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': 'כאן פודקאסטים'})
            break
        if page + 1 == stopPage:
            if page >= pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              str(prevPage),
                              31,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': 'כאן פודקאסטים'})
            name = common.GetLabelColor(common.GetLocaleString(30012),
                                        color="green")
            common.addDir(name,
                          str(page),
                          31,
                          iconimage,
                          infos={
                              "Title": name,
                              "Plot": name
                          },
                          module=module,
                          urlParamsData={'catName': 'כאן פודקאסטים'})
            break
Example #24
0
def GetRadioEpisodesList(data, iconimage, catName):
    d = data.split(';')
    progId = d[0]
    page = 0 if len(d) < 2 else int(d[1])
    stopPage = page + pagesPerList - 1
    prevPage = page - pagesPerList if page > pagesPerList else 0
    while True:
        url = '{0}/Radio/getMoreItems.aspx?index={1}&progId={2}&subcatid=0&isEng=False'.format(
            baseUrl, page, progId)
        text = common.OpenURL(url)
        matches = re.compile(
            'class="radio_program_partgroup">.*?class="radio_program_toggle top_plus.*?<div>(.*?)</div>.*?onclick="playItem\(\'(.*?)\'\)"',
            re.S).findall(text)
        for name, itemId in matches:
            name = common.GetLabelColor(name.strip(), keyColor="chColor")
            common.addDir(name,
                          '{0}/radio/player.aspx?ItemId={1}'.format(
                              baseUrl, itemId),
                          12,
                          iconimage,
                          infos={"Title": name},
                          module=module,
                          moreData='best',
                          isFolder=False,
                          isPlayable=True,
                          urlParamsData={'catName': catName})
        if len(matches) < 10:
            if page > pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(progId, prevPage),
                              23,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': catName})
            break
        if page == stopPage:
            if page > pagesPerList:
                name = common.GetLabelColor(common.GetLocaleString(30011),
                                            color="green")
                common.addDir(name,
                              '{0};{1}'.format(progId, prevPage),
                              23,
                              iconimage,
                              infos={
                                  "Title": name,
                                  "Plot": name
                              },
                              module=module,
                              urlParamsData={'catName': catName})
            name = common.GetLabelColor(common.GetLocaleString(30012),
                                        color="green")
            common.addDir(name,
                          '{0};{1}'.format(progId, page + 1),
                          23,
                          iconimage,
                          infos={
                              "Title": name,
                              "Plot": name
                          },
                          module=module,
                          urlParamsData={'catName': catName})
            break
        page += 1
Example #25
0
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)
Example #26
0
def GetPodcatsList(iconimage, page='1'):
    page = int(page)
    url = '{0}/podcasts?category=&person=&show=&order=updated--dn&page={{0}}'.format(
        baseUrl)
    xbmc.log(url.format(page), 5)
    text = common.OpenURL(url.format(page), headers=headers)
    podcasts, pagination = re.compile(
        'container container--big(.*?)class="pagination">(.*?)</section>',
        re.S).findall(text)[0]
    podcasts = re.compile(
        '<a href="(.*?)".*?data-src="(.*?)".*?podcastCard__title">(.*?)</div>.*?podcastCard__description">(.*?)</div>',
        re.S).findall(podcasts)
    for link, icon, name, desc in podcasts:
        name = common.GetLabelColor(common.UnEscapeXML(name),
                                    keyColor="prColor",
                                    bold=True)
        desc = common.GetLabelColor(desc, keyColor="chColor")
        common.addDir(name,
                      '{0}{1}'.format(baseUrl, link),
                      2,
                      icon,
                      infos={
                          "Plot": desc,
                          "Title": name
                      },
                      module=module,
                      isFolder=False,
                      isPlayable=True)
    pagination = re.compile('href=.*?page=(.*?)"', re.S).findall(pagination)
    pages = page
    for p in pagination:
        if int(p) > pages:
            pages = int(p)
    if page > 1:
        name = common.GetLabelColor(common.GetLocaleString(30011),
                                    color="green")
        common.addDir(name,
                      str(page - 1),
                      0,
                      iconimage,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
    if pages > page:
        name = common.GetLabelColor(common.GetLocaleString(30012),
                                    color="green")
        common.addDir(name,
                      str(page + 1),
                      0,
                      iconimage,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
    if pages > 1:
        name = common.GetLabelColor(common.GetLocaleString(30013),
                                    color="green")
        common.addDir(name,
                      'p={0}&pages={1}'.format(page, pages),
                      1,
                      iconimage,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
Example #27
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)
Example #28
0
def GetEpisodesList(url, progName=''):
    text = common.OpenURL(url)

    pagination = re.compile('pagination\(\d*?, (\d*?)\);', re.S).findall(text)
    pages = 1 if len(pagination) < 1 else int(pagination[0])

    i = url.find('program/')
    if i < 1:
        i = url.find('programs/')
        j = url.find('/', i + 9)
    else:
        j = url.find('/', i + 8)
    if j > 0:
        page = int(url[j + 1:])
        _url = url[:j + 1]
    else:
        page = 1
        _url = '{0}/'.format(url)

    firtepisode = re.compile(
        'poster: \'(.*?)\',.*?<div>(.*?)</div>.*?<div class="share_group".*?href="(.*?)"',
        re.S).findall(text)
    for image, name, link in firtepisode:
        name = common.GetLabelColor(common.UnEscapeXML(name),
                                    keyColor="chColor")
        common.addDir(name,
                      'http://{0}'.format(link),
                      2,
                      '{0}{1}'.format(baseUrl, image),
                      infos={
                          "Title": name,
                          "Plot": progName
                      },
                      module=module,
                      isFolder=False,
                      isPlayable=True)

    episodes = re.compile('<li class=".*?program">(.*?)</li>',
                          re.S).findall(text)
    for episode in episodes:
        matches = re.compile(
            'href="(.*?)".*?src="(.*?)".*?program_item_date">(.*?)</',
            re.S).findall(episode)
        for link, image, name in matches:
            name = common.GetLabelColor(common.UnEscapeXML(name),
                                        keyColor="chColor")
            common.addDir(name,
                          '{0}{1}'.format(baseUrl, link),
                          2,
                          '{0}{1}'.format(baseUrl, image),
                          infos={
                              "Title": name,
                              "Plot": progName
                          },
                          module=module,
                          isFolder=False,
                          isPlayable=True)

    if page > 1:
        name = common.GetLabelColor(common.GetLocaleString(30011),
                                    color="green")
        common.addDir(name,
                      '{0}{1}'.format(_url, page - 1),
                      1,
                      image,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
    if pages > page:
        name = common.GetLabelColor(common.GetLocaleString(30012),
                                    color="green")
        common.addDir(name,
                      '{0}{1}'.format(_url, page + 1),
                      1,
                      image,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
    if pages > 1:
        name = common.GetLabelColor(common.GetLocaleString(30013),
                                    color="green")
        common.addDir(name,
                      '{0}?p={1}&pages={2}'.format(_url, page, pages),
                      3,
                      image,
                      infos={
                          "Title": name,
                          "Plot": name
                      },
                      module=module)
Example #29
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)
Example #30
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)