Exemplo n.º 1
0
def make_channel_list():
    utils.log("url-make-channel" + sys.argv[0])

    try:
        channels = api.get_channels()

        ok = True
        for c in channels:
            listitem = xbmcgui.ListItem(label=c['name'])
            listitem.setInfo('video', {'title': c['name']})
            listitem.setIconImage('https://manstv.lattelecom.tv/' + c['logo'])
            listitem.setThumbnailImage('https://manstv.lattelecom.tv/' + c['thumb'])
            listitem.setProperty('IsPlayable', "true")

            # Build the URL for the program, including the list_info
            url = "%s?play=true&data_url=%s" % (sys.argv[0], c['id'])

            # Add the program item to the list
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False,
                                             totalItems=len(channels))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except:
        d = xbmcgui.Dialog()
        msg = utils.dialog_error("Unable to fetch listing")
        d.ok(*msg)
        utils.log_error()
Exemplo n.º 2
0
def make_channel_list():
    utils.log("url-make-channel" + sys.argv[0])

    try:
        channels = api.get_channels()

        ok = True
        for c in channels:
            listitem = xbmcgui.ListItem(label=c['name'])
            listitem.setInfo('video', {'title': c['name']})
            listitem.setIconImage(api.API_BASEURL + "/" + c['logo'])
            listitem.setThumbnailImage(api.API_BASEURL + "/" + c['thumb'])
            listitem.setProperty('IsPlayable', "true")

            # Build the URL for the program, including the list_info
            url = "%s?play=true&data_url=%s" % (sys.argv[0], c['id'])

            # Add the program item to the list
            ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),
                                             url=url,
                                             listitem=listitem,
                                             isFolder=False,
                                             totalItems=len(channels))

        xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
        xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
    except:
        d = xbmcgui.Dialog()
        msg = utils.dialog_error("Unable to fetch listing")
        d.ok(*msg)
        utils.log_error()
Exemplo n.º 3
0
def list_channels(params):
    
    listing = []
    
    channels = api.get_channels()

    if channels:
        for channel in channels:
            li = channel_to_kodi_item(channel)
            listing.append(li)  # Item label

    return common.plugin.create_listing(
        listing,
        #succeeded = True, #if False Kodi won’t open a new listing and stays on the current level.
        #update_listing = False, #if True, Kodi won’t open a sub-listing but refresh the current one. 
        #cache_to_disk = True, #cache this view to disk.
        #sort_methods = None, #he list of integer constants representing virtual folder sort methods.
        #view_mode = None, #a numeric code for a skin view mode. View mode codes are different in different skins except for 50 (basic listing).
        #content = None #string - current plugin content, e.g. ‘movies’ or ‘episodes’.
    )
Exemplo n.º 4
0
def build_epg():
    utils.log("Building EPG data")

    today = datetime.date.today().strftime("%Y-%m-%d")
    tomorrow = (datetime.date.today() +
                datetime.timedelta(days=1)).strftime("%Y-%m-%d")

    channels = api.get_channels()

    today_data = api.get_epg(today)
    tomorrow_data = api.get_epg(tomorrow)

    json_object = merge_data(today_data, tomorrow_data)

    xml_tv = ElementTree.Element("tv")
    m3u = "#EXTM3U tvg-shift=0\n"

    for channel in channels:
        m3u += "#EXTINF:-1 tvg-id=\"" + channel["id"] + "\" tvg-name=\"" + channel["name"] + "\" tvg-logo=\"" \
               + channel["logo"] + "\" group-title=\"Lattelecom\"," + channel["name"] + "\n"
        m3u += "plugin://lattelecomtv/?play=true&data_url=" + channel[
            "id"] + "\n"

    for channel in json_object["included"]:

        if channel["type"] != "channels":
            continue

        xml_chan = ElementTree.SubElement(xml_tv, "channel", id=channel["id"])
        ElementTree.SubElement(xml_chan, "display-name",
                               lang="en").text = channel["attributes"]["title"]

    offset_hours = riga_offset_hours()
    offset = "%s%02d00" % (("" if offset_hours < 0 else "+"), offset_hours)
    date_format_xml = "%Y%m%d%H%M%S " + offset

    for item in json_object["data"]:

        if item["type"] != "epgs":
            continue

        xml_prog = ElementTree.SubElement(
            xml_tv,
            "programme",
            start=riga.localize(
                utils.dateFromUnix(float(
                    item["attributes"]["unix-start"]))).strftime(
                        date_format_xml),
            stop=riga.localize(
                utils.dateFromUnix(float(
                    item["attributes"]["unix-stop"]))).strftime(
                        date_format_xml),
            channel=item["relationships"]["channel"]["data"]["id"])
        ElementTree.SubElement(xml_prog, "title",
                               lang="en").text = item["attributes"]["title"]
        ElementTree.SubElement(
            xml_prog, "desc",
            lang="en").text = item["attributes"]["description"]
        ElementTree.SubElement(xml_prog, "category",
                               lang="en").text = item["attributes"]["category"]
        ElementTree.SubElement(xml_prog,
                               "icon",
                               src=api.API_BASEURL + "/" +
                               item["attributes"]["poster-url"])

    indent(xml_tv)
    xml_str = ElementTree.tostring(xml_tv, encoding="utf-8", method="xml")

    text_file = open(config.DATADIR + EPG_FILE, "w")
    text_file.write('<?xml version="1.0" encoding="utf-8" ?>' + "\n" + xml_str)
    text_file.close()

    text_file = open(config.DATADIR + M3U_FILE, "w")
    text_file.write(m3u.encode("utf-8"))
    text_file.close()

    mark_updated()