Exemple #1
0
def add_next_url(url, action):
    next_page = page_from_url(url) + 1
    next_url = edit_url(url, {'page': next_page})
    li = xbmcgui.ListItem()
    li.setLabel('[COLOR blue]{0}[/COLOR]'.format(Language.next_page))
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=action, url=next_url),
                                li,
                                isFolder=True)
Exemple #2
0
def list_categories(url):
    json_data = requests.get(url).json()
    for i in json_data:
        name = unescape(i.get('name'))
        category_id = i.get('id')

        li = xbmcgui.ListItem()
        li.setLabel(name)
        xbmcplugin.addDirectoryItem(plugin.handle,
                                    plugin.get_url(action=posts_by_category,
                                                   id=category_id),
                                    li,
                                    isFolder=True)
    if len(json_data) == PER_PAGE:
        add_next_url(url, categories_by_url)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=True)
Exemple #3
0
def list_video_playlist(params):
    _id = params.get("id")
    parser = parse_post(_id)

    for v in parser.videos:
        image = "https://i.ytimg.com/vi/{0}/hqdefault.jpg".format(v.id)

        li = xbmcgui.ListItem()
        li.setLabel(v.title)
        li.setInfo("video", {
            "title": v.title,
        })
        li.setProperty("isPlayable", "true")
        li.setArt({'thumb': image})
        xbmcplugin.addDirectoryItem(plugin.handle,
                                    plugin.get_url(action=play,
                                                   youtube_id=v.id,
                                                   name=v.title),
                                    li,
                                    isFolder=False)
    xbmcplugin.endOfDirectory(plugin.handle)
Exemple #4
0
def root(params):
    li = xbmcgui.ListItem()
    li.setLabel(Language.documentations)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=all_posts),
                                li,
                                isFolder=True)

    li = xbmcgui.ListItem()
    li.setLabel(Language.tags)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=all_tags),
                                li,
                                isFolder=True)

    li = xbmcgui.ListItem()
    li.setLabel(Language.categories)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=all_categories),
                                li,
                                isFolder=True)

    li = xbmcgui.ListItem()
    li.setLabel(Language.search_documentations)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=search_posts),
                                li,
                                isFolder=True)

    li = xbmcgui.ListItem()
    li.setLabel(Language.search_tags)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=search_tags),
                                li,
                                isFolder=True)

    li = xbmcgui.ListItem()
    li.setLabel(Language.search_categories)
    xbmcplugin.addDirectoryItem(plugin.handle,
                                plugin.get_url(action=search_categories),
                                li,
                                isFolder=True)

    xbmcplugin.endOfDirectory(plugin.handle)
Exemple #5
0
def list_videos(url):
    json_data = requests.get(url).json()

    for i in json_data:
        _id = i.get('id')
        title = unescape(i.get('title')['rendered'])
        title = py2_encode(title)
        content = i.get('content')['rendered']
        date = i.get('date')[:10]
        soup = bs4.BeautifulSoup(content, 'html5lib')
        try:
            plot = soup.find('meta', {'itemprop': 'description'})['content']
        except TypeError:
            plot = ""
        parser = Parser(content).parse()

        li = xbmcgui.ListItem()
        li.setLabel(title)
        li.setInfo("video", {
            "title": title,
            "plot": plot,
            "aired": date,
            "year": date[:4]
        })
        li.addContextMenuItems([
            (Language.show_tags, 'XBMC.Container.Update({0})'.format(
                plugin.get_url(action=tags_by_post, id=_id))),
            (Language.show_categories, 'XBMC.Container.Update({0})'.format(
                plugin.get_url(action=categories_by_post, id=_id))),
        ])

        if len(parser.videos) == 0 and len(
                parser.playlists) == 0:  # search for mirror
            li.setProperty("isPlayable", "true")
            xbmcplugin.addDirectoryItem(plugin.handle,
                                        plugin.get_url(action=play,
                                                       name=title),
                                        li,
                                        isFolder=False)
        elif len(parser.videos) == 1:  # video found
            v = parser.videos[0]
            image = "https://i.ytimg.com/vi/{0}/hqdefault.jpg".format(v.id)

            li.setArt({'thumb': image})
            li.setProperty("isPlayable", "true")
            xbmcplugin.addDirectoryItem(plugin.handle,
                                        plugin.get_url(action=play,
                                                       youtube_id=v.id,
                                                       name=title),
                                        li,
                                        isFolder=False)
        elif len(parser.videos) > 0:  # new playlist type found
            image = "https://i.ytimg.com/vi/{0}/hqdefault.jpg".format(
                parser.videos[0].id)  # image of the first video

            li.setArt({'thumb': image})
            xbmcplugin.addDirectoryItem(
                plugin.handle,
                plugin.get_url(action=list_video_playlist, id=_id),
                li,
                isFolder=True)
        elif len(parser.playlists) > 0:  # old playlist type found
            xbmcplugin.addDirectoryItem(plugin.handle,
                                        plugin.get_url(action=list_playlist,
                                                       id=_id),
                                        li,
                                        isFolder=True)

    if len(json_data) == PER_PAGE:
        add_next_url(url, posts_by_url)
    xbmcplugin.endOfDirectory(plugin.handle, cacheToDisc=True)