Exemplo n.º 1
0
def play(item_to_play):
    channel_data = fetch_channel_data(fetch_local_channel_data,
                                      fetch_remote_channel_data)
    xml_data = ET.fromstring(channel_data)
    try:
        channel_data = xml_data.find(".//channel[@id='" + item_to_play + "']")
        channel = Channel(handle, tempdir, channel_data, quality_priority(),
                          format_priority())
    except:
        for element in xml_data.findall(".//channel"):
            channel = Channel(handle, tempdir, element, quality_priority(),
                              format_priority())
            if channel.getid() == item_to_play:
                break

    list_item = ListItem(channel.get_simple_element('title'),
                         channel.get_simple_element('description'),
                         channel.get_content_url())
    list_item.setArt({
        "icon":
        channel.geticon(),
        "thumb":
        channel.getthumbnail(),
        "fanart":
        xbmcvfs.translatePath("special://home/addons/%s/fanart.jpg" %
                              __addonid__)
    })
    xbmcplugin.setResolvedUrl(handle, True, list_item)
def build_directory():
    channel_data = fetch_channel_data(fetch_cached_channel_data, fetch_remote_channel_data, fetch_local_channel_data)
    xml_data = ET.fromstring(channel_data)

    stations = xml_data.findall(".//channel")
    for station in stations:
        channel = Channel(handle, tempdir, station)
        li = xbmcgui.ListItem(
            channel.get_simple_element('title'),
            channel.get_simple_element('description'),
            channel.geticon(),
            channel.getthumbnail(),
            plugin_url + channel.getid())
        li.setArt({"fanart": xbmc.translatePath("special://home/addons/%s/fanart.jpg" % __addonid__)})

        li.setProperty("IsPlayable", "true")

        for element, info in [('listeners', 'listeners'),
                              ('genre', 'genre'),
                              ('dj', 'artist'),
                              ('description', 'comment'),
                              ('title', 'title')]:
            value = channel.get_simple_element(element)
            li.setInfo("Music", {info: value})

        xbmcplugin.addDirectoryItem(
            handle=handle,
            url=plugin_url + channel.getid(),
            listitem=li,
            totalItems=len(stations))
    xbmcplugin.addSortMethod(handle, SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(handle, SORT_METHOD_LISTENERS)
    xbmcplugin.addSortMethod(handle, SORT_METHOD_GENRE)
Exemplo n.º 3
0
def build_directory():
    channel_data = fetch_channel_data(fetch_cached_channel_data,
                                      fetch_remote_channel_data,
                                      fetch_local_channel_data)
    xml_data = ET.fromstring(channel_data)

    stations = xml_data.findall(".//channel")
    for station in stations:
        channel = Channel(handle, tempdir, station)
        li = xbmcgui.ListItem(channel.get_simple_element('title'),
                              channel.get_simple_element('description'),
                              channel.geticon(), channel.getthumbnail(),
                              plugin_url + channel.getid())
        li.setArt({
            "fanart":
            xbmc.translatePath("special://home/addons/%s/fanart.jpg" %
                               __addonid__)
        })

        li.setProperty("IsPlayable", "true")

        for element, info in [('listeners', 'listeners'), ('genre', 'genre'),
                              ('dj', 'artist'), ('description', 'comment'),
                              ('title', 'title')]:
            value = channel.get_simple_element(element)
            li.setInfo("Music", {info: value})

        xbmcplugin.addDirectoryItem(handle=handle,
                                    url=plugin_url + channel.getid(),
                                    listitem=li,
                                    totalItems=len(stations))
    xbmcplugin.addSortMethod(handle, SORT_METHOD_UNSORTED)
    xbmcplugin.addSortMethod(handle, SORT_METHOD_LISTENERS)
    xbmcplugin.addSortMethod(handle, SORT_METHOD_GENRE)
def play(item_to_play):
    channel_data = fetch_channel_data(fetch_local_channel_data, fetch_remote_channel_data)
    xml_data = ET.fromstring(channel_data)
    try:
        channel_data = xml_data.find(".//channel[@id='" + item_to_play + "']")
        channel = Channel(handle, tempdir, channel_data, quality_priority(), format_priority())
    except:
        for element in xml_data.findall(".//channel"):
            channel = Channel(handle, tempdir, element, quality_priority(), format_priority())
            if channel.getid() == item_to_play:
                break

    list_item = ListItem(channel.get_simple_element('title'),
                         channel.get_simple_element('description'),
                         channel.geticon(),
                         channel.getthumbnail(),
                         channel.get_content_url())
    list_item.setArt({"fanart": xbmc.translatePath("special://home/addons/%s/fanart.jpg" % __addonid__)})
    xbmcplugin.setResolvedUrl(handle, True, list_item)