当前位置: 首页>>代码示例>>Python>>正文


Python plugin.url_for函数代码示例

本文整理汇总了Python中xbmctorrent.plugin.url_for函数的典型用法代码示例。如果您正苦于以下问题:Python url_for函数的具体用法?Python url_for怎么用?Python url_for使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了url_for函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: cpb_page

def cpb_page(cat, query, sort, page):

    log.debug("THE CAT = " + cat + " & THE Q = " + query)
    if not "cpasbien" in query:
        url_adr = BASE_URL + "/" + cat + "/" + query.replace(" ", "+") + "/page-" + str(page) + "," + sort
    else:
        url_adr = BASE_URL + "/view_cat.php?categorie=" + cat + "&page=" + str(page) + "&trie=" + sort[5:]
    log.debug("THE URL = " + url_adr)
    html_data = url_get(url_adr)

    soup = BeautifulSoup(html_data, "html5lib")
    name_nodes = soup.findAll("td", "torrent-aff")

    for name_node in name_nodes:
        title = name_node.find("a").text
        html_uri = name_node.find("a")["href"]
        torrent_basename = os.path.basename(html_uri)
        uri_addr = BASE_URL + "/_torrents/" + torrent_basename.replace(".html", ".torrent")
        img_addr = BASE_URL + "/_pictures/" + torrent_basename.replace(".html", ".jpg")
        yield {
            "label": title,
            "path": plugin.url_for("play", uri=uri_addr),
            "is_playable": True,
            "thumbnail": img_addr,
            "properties": {"fanart_image": img_addr},
        }
    yield {
        "label": ">> Next page",
        "path": plugin.url_for("cpb_page", cat=cat, query=query, sort=sort, page=int(page) + 1),
        "is_playable": False,
    }
开发者ID:JonathanHuot,项目名称:xbmctorrent,代码行数:31,代码来源:cpb.py

示例2: kat_anime

def kat_anime():
    return [
        {
            "label": "Search Anime",
            "path": plugin.url_for(
                "kat_search", query_suffix="category:anime", sort_field="seeders", sort_order="desc"
            ),
        },
        {
            "label": "All Anime",
            "path": plugin.url_for("kat_page", root="tv", page=1, sort_field="seeders", sort_order="desc"),
        },
        {
            "label": "    HD",
            "path": plugin.url_for(
                "kat_search", query="(1080p OR 720p) category:anime", sort_field="seeders", sort_order="desc"
            ),
        },
        {
            "label": "    720p",
            "path": plugin.url_for("kat_search", query="720p category:anime", sort_field="seeders", sort_order="desc"),
        },
        {
            "label": "    1080p",
            "path": plugin.url_for("kat_search", query="1080p category:anime", sort_field="seeders", sort_order="desc"),
        },
    ]
开发者ID:JonathanHuot,项目名称:xbmctorrent,代码行数:27,代码来源:kickass.py

示例3: piratebay_page

def piratebay_page(root, page):
    import re
    from bs4 import BeautifulSoup
    from urlparse import urljoin
    from xbmctorrent.utils import url_get

    page = int(page)
    html_data = url_get(urljoin(BASE_URL, "%s/%d/7/100,200,500" % (root, page)), headers=HEADERS)
    soup = BeautifulSoup(html_data, "html5lib")
    nodes = soup.findAll("div", "detName")

    for node in nodes:
        seeds, peers = map(lambda x: x.text, node.parent.parent.findAll("td")[2:])
        magnet_node = node.parent.findAll("a")[1]
        desc_node = node.parent.findAll("font", "detDesc")[0]
        size = re.search("Size (.*?),", desc_node.text).group(1)
        text = "%s (%s S:%s P:%s)" % (node.a.text, size.replace(" ", " "), seeds, peers)
        yield {
            "label": text,
            "path": plugin.url_for("play", uri=magnet_node["href"]),
            "is_playable": True,
        }
    yield {
        "label": ">> Next page",
        "path": plugin.url_for("piratebay_page", root=root, page=page + 1),
        "is_playable": False,
    }
开发者ID:smoky-jr,项目名称:XBMC.ru-forum-Add-ons,代码行数:27,代码来源:tpb.py

示例4: cpb_index

def cpb_index():
    cats = [
        {"label": "Recherche", "path": plugin.url_for("cpb_search")},
        {"label": "Films", "path": plugin.url_for("cpb_movies")},
        {"label": "Series", "path": plugin.url_for("cpb_series")},
    ]
    return cats
开发者ID:JonathanHuot,项目名称:xbmctorrent,代码行数:7,代码来源:cpb.py

示例5: btdigg_page

def btdigg_page(query, sort, page):
    from bs4 import BeautifulSoup
    from xbmctorrent.utils import url_get

    html_data = url_get("%s/search" % BASE_URL, headers=HEADERS, params={
        "order": sort,
        "q": query,
        "p": page,
    })
    soup = BeautifulSoup(html_data, "html5lib")
    name_nodes = soup.findAll("td", "torrent_name")
    attr_nodes = soup.findAll("table", "torrent_name_tbl")[1::2]

    for name_node, attr_node in zip(name_nodes, attr_nodes):
        attrs = attr_node.findAll("span", "attr_val")
        title = "%s (%s, DLs:%s)" % (name_node.find("a").text, attrs[0].text, attrs[2].text)
        yield {
            "label": title,
            "path": plugin.url_for("play", uri=attr_node.find("a")["href"]),
            "is_playable": True,
        }
    yield {
        "label": ">> Next page",
        "path": plugin.url_for("btdigg_page", query=query, sort=sort, page=int(page) + 1),
        "is_playable": False,
    }
开发者ID:1c0n,项目名称:xbmctorrent,代码行数:26,代码来源:btdigg.py

示例6: _eztv_shows_by_letter

    def _eztv_shows_by_letter(letter):
        with closing(xbmcgui.DialogProgress()) as dialog:
            dialog.create(plugin.name)
            dialog.update(percent=0, line1="Fetching serie information...", line2="", line3="")

            state = {"done": 0}
            def on_serie(data):
                state["done"] += 1
                dialog.update(
                    percent=int(state["done"] * 100.0 / len(shows_list)),
                    line2=data and data["seriesname"] or "",
                )

            with terminating(ThreadPool(5)) as pool_tvdb:
                tvdb_list = [pool_tvdb.apply_async(tvdb.search, [show["name"], True], callback=on_serie) for show in shows_list]
                while not all(job.ready() for job in tvdb_list):
                    if dialog.iscanceled():
                        dialog.close()
                        return
                    xbmc.sleep(50)

        tvdb_list = [job.get() for job in tvdb_list]
        for i, (eztv_show, tvdb_show) in enumerate(izip(shows_list, tvdb_list)):
            if tvdb_show:
                item = tvdb.get_list_item(tvdb_show)
                item.update({
                    "path": plugin.url_for("eztv_get_show_seasons", show_id=eztv_show["id"], tvdb_id=tvdb_show["id"])
                })
                yield item
            else:
                yield {
                    "label": eztv_show["name"],
                    "path": plugin.url_for("eztv_get_show_seasons", show_id=eztv_show["id"])
                }
开发者ID:neno1978,项目名称:xbmctorrent,代码行数:34,代码来源:eztv.py

示例7: iplay_page

def iplay_page(cat, page):
    import re
    from bs4 import BeautifulSoup
    from urlparse import urljoin
    from xbmctorrent.utils import url_get

    page = int(page)
    url = urljoin(BASE_URL, "test/proxy.php")
    html_data = url_get(url, params = {"cat": cat, "page": page}, headers = HEADERS)
    soup = BeautifulSoup(html_data, "html5lib")

    nodes = soup.findAll('a', 'torrent')

    next_page = {
        "label": "Next page...",
        "path": plugin.url_for("iplay_page", cat = cat, page = page + 1),
        "is_playable": False,
    }

    for node in nodes:
        text = "%s" % node.get('title')
        torrent_node = node.parent.find('img', {"class": "dld"}).parent

        yield {
            "label": text,
            "path": plugin.url_for("play", uri=torrent_node["href"]),
            "is_playable": False,
        }
    #print 'DBG URL:' + url
    yield next_page
开发者ID:vladady,项目名称:xbmctorrent,代码行数:30,代码来源:iplay.py

示例8: cpb_listAll

def cpb_listAll(cat, page):
    from bs4 import BeautifulSoup
    from xbmctorrent.utils import url_get

    url_adr = "%s/view_cat.php?categorie=%s&page=%s" % (BASE_URL, cat, page) #view_cat.php?categorie=films&page=1
    html_data = url_get(url_adr)

    soup = BeautifulSoup(html_data, "html5lib")
    name_nodes = soup.findAll('div', re.compile('ligne[0,1]'))

    for name_node in name_nodes:
        title = name_node.find("a").text
        tds = name_node.parent.findAll("td")
        seed = name_node.find("div","up").text
        leech = name_node.find("div","down").text
        color = getColor(seed, leech)
        title = title + " [COLOR %s][S:%s|L:%s][/COLOR]" %(color, seed, leech)
        html_uri=name_node.find("a")["href"]
        torrent_basename = os.path.basename(html_uri)
        uri_addr= BASE_URL + "/_torrents/" + torrent_basename.replace(".html",".torrent")
        img_addr = BASE_URL + "/_pictures/" + torrent_basename.replace(".html",".jpg")
        yield {
            "label": title,
            "path": plugin.url_for("play", uri=uri_addr),
            "is_playable": True,
            "thumbnail" : img_addr , 
            "properties": {
              "fanart_image" : img_addr , 
            } ,
        }
    yield {
        "label": ">> Next page",
        "path": plugin.url_for("cpb_listAll", cat=cat, page=int(page) + 1),
        "is_playable": False,
    }
开发者ID:Sheppounet,项目名称:xbmctorrent,代码行数:35,代码来源:cpb.py

示例9: ilcorsaronero_page

def ilcorsaronero_page(root, page):
    from bs4 import BeautifulSoup
    from urlparse import urljoin
    from xbmctorrent.utils import url_get

    page = int(page)
    html_data = url_get(urljoin(BASE_URL, "%s&page=%d" % (root, page)), headers=HEADERS)
    soup = BeautifulSoup(html_data, "html5lib")
    nodes = soup.findAll("a", class_="tab")

    for node in nodes:
        size, null, data, seeds, peers = map(lambda x: (x.font.text if x.font is not None else None), node.parent.parent.findAll("td")[-5:])
        text = "%s (%s S:%s P:%s %s)" % (node.text, size, seeds, peers, data)

        yield {
            "label": text,
            "path": plugin.url_for("ilcorsaronero_play", uri=node["href"]),
            "is_playable": True,
        }

    if root.find('search') == -1:
        yield {
            "label": ">> Next page",
            "path": plugin.url_for("ilcorsaronero_page", root=root, page=page + 1),
            "is_playable": False,
        }
开发者ID:elbowz,项目名称:xbmctorrent,代码行数:26,代码来源:ilcorsaronero.py

示例10: lostfilm_all

def lostfilm_all(page):
    from json import loads
    from contextlib import closing
    from xbmctorrent.utils import SafeDialogProgress

    page = int(page)
    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1=u"Получение информации ...", line2="", line3="")

        params = {"act": "serial", "type": "search", "o": page * 30, "t": 0, "s": 2}

        data = []
        tvshows = []
        try:
            while True:
                json_data = url_get(AJAX_URL, params=params)
                data = loads(json_data).get("data", [])
                tvshows += data
                if len(data) < 10 or len(tvshows) >= 30:
                    break
                params["o"] += len(data)
        except Exception:
            plugin.log.error("Unexpected error: %s" % sys.exc_info()[0])
            xbmcgui.Dialog().ok(plugin.name, u"Не удалось получить данные от сервера")
            return

        done = 0
        for tvshow in tvshows:
            if dialog.iscanceled():
                return

            item = _lostfilm_updateitem_from_db({
                "label": "[COLOR FFFFFFFF][B]%s[/B][/COLOR] [%s]" % (tvshow["title"], tvshow["title_orig"]),
                "path": plugin.url_for("lostfilm_tvshow", alias=tvshow["alias"]),
                "is_playable": False,
                "info": {
                    "title": "%s [%s]" % (tvshow["title"], tvshow["title_orig"])
                }
            }, tvshow)

            done += 1
            dialog.update(
                percent=int(done * 100.0 / len(tvshows)),
                line2=item.get("info", {}).get("tvshowtitle", "") or item.get("info", {}).get("title", "") or item["label"],
                line3=""
            )

            yield item

        _lostfilm_close_dbase()

        if len(data) == 10:
            yield {
                "label": "[COLOR FF00FF00][Далее >][/COLOR]",
                "path": plugin.url_for("lostfilm_all", page=page + 1),
            }
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:57,代码来源:lostfilm.py

示例11: rutor_index

def rutor_index():
    yield {
        "label": u"[COLOR FFFFFF00][ Поиск ][/COLOR]",
        "path": plugin.url_for("rutor_search"),
    }
    for cat in CATEGORIES:
        yield {
            "label": cat[1],
            "path": plugin.url_for("rutor_page", catind=cat[0], page=0, query=str(None)),
        }
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:10,代码来源:rutor.py

示例12: kat_index

def kat_index():
    cats = [
        {"label": "Search", "path": plugin.url_for("kat_search", sort_field="seeders", sort_order="desc")},
        {"label": "Movies", "path": plugin.url_for("kat_movies")},
        {"label": "Series", "path": plugin.url_for("kat_series", sort_field="seeders", sort_order="desc")},
        {"label": "Anime", "path": plugin.url_for("kat_anime")},
    ]
    if plugin.get_setting("porn", bool):
        cats += [{"label": "XXX", "path": plugin.url_for("kat_porn")}]
    return cats
开发者ID:JonathanHuot,项目名称:xbmctorrent,代码行数:10,代码来源:kickass.py

示例13: _fn

 def _fn(*a, **kwds):
     items = fn(*a, **kwds)
     if items is not None:
         from xbmctorrent.magnet import ensure_magnet
         for item in items:
             if item.get("is_playable"):
                 item.setdefault("context_menu", []).extend([
                     ("Add to Movies", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="movies", href=item["path"])),
                     ("Add to TV", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="tvshows", href=item["path"])),
                 ])
             yield item
开发者ID:vizzah,项目名称:xbmctorrent,代码行数:11,代码来源:library.py

示例14: _fn

 def _fn(*a, **kwds):
     items = fn(*a, **kwds)
     if items is not None:
         for item in items:
             if item.get("is_playable"):
                 label = item["label"].encode("utf-8")
                 item.setdefault("context_menu", []).extend([
                     ("Add to Movies", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="movies", label=label, href=item["path"])),
                     ("Add to TV", "XBMC.RunPlugin(%s)" % plugin.url_for("library_add", content_type="tvshows", label=label, href=item["path"])),
                 ])
             yield item
开发者ID:smoky-jr,项目名称:XBMC.ru-forum-Add-ons,代码行数:11,代码来源:library.py

示例15: rutor_play

def rutor_play(tid, pulsar):
    from contextlib import closing
    from bencode import bdecode
    from urlparse import urljoin
    from xbmctorrent.magnet import generate_magnet
    from xbmctorrent.utils import first, SafeDialogProgress
    from xbmctorrent.acestream import ace_supported

    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1="Получение информации о раздаче...")

        torrent_url = urljoin(BASE_URL, "download/%s" % tid)
        try:
            metadata = bdecode(url_get(torrent_url, headers=HEADERS))
        except Exception:
            import xbmcgui
            plugin.log.error("Unexpected error: %s" % sys.exc_info()[0])
            xbmcgui.Dialog().ok(plugin.name, "Не удалось получить данные от сервера")
            return

        dialog.update(percent=100, line1="Готово")

        if "files" in metadata["info"]:  # and ace_supported():
            items = []
            for index, info in enumerate(metadata["info"]["files"]):
                name = "/".join(info["path"])
                if not _rutor_valid_file(name):
                    continue

                if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                    path = plugin.url_for("torrent_play", url=torrent_url, index=index, name=name)
                else:
                    path = plugin.url_for("play_file", uri=generate_magnet(metadata, name), index=index)

                items.append({"label": name, "path": path})

            items = sorted(items, key=lambda x: x["label"])
            if len(items) == 1:  # start playback if torrent contains only one file
                plugin.redirect(items[0]["path"])
            else:               # ask to select which file to play
                import xbmcgui
                select_items = [item["label"] for item in items]
                select = xbmcgui.Dialog().select("Выберите файл для проигрывания", select_items)
                if select >= 0:
                    plugin.redirect(items[select]["path"])
        else:
            name = metadata["info"].get("name") or " / ".join(first(metadata["info"]["files"])["path"]) or "rutor.org"
            if plugin.get_setting("torrent_engine", int) == 1 and ace_supported():
                path = plugin.url_for("torrent_play", url=torrent_url, index=0, name=name)
            else:
                path = plugin.url_for(["play", "play_with_pulsar"][int(pulsar)], uri=generate_magnet(metadata, name))
            plugin.redirect(path)
开发者ID:afedchin,项目名称:xbmctorrent,代码行数:53,代码来源:rutor.py


注:本文中的xbmctorrent.plugin.url_for函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。