def nyaa_search():
    query = plugin.request.args.get("query")
    if query:
        query = query[0]
    else:
        query = plugin.keyboard("", "streamajoker - NyaaTorrents - Search")
    if query:
        plugin.redirect(plugin.url_for("search_result_page", page="search", cats="0_0", filter=0, term=query, offset=1, sort=SORT_DATE, order=SORT_DESCENDING))
def bitsnoop_search():
    import urllib
    from streamajoker.utils import first

    query = plugin.request.args_dict.pop("query", None)
    if not query:
        query = plugin.keyboard("", "streamajoker - Bitsnoop - Search")
    if query:
        plugin.redirect(plugin.url_for("bitsnoop_page", root="/search/video/%s/c/d/" % urllib.quote("%s safe:no" % query, safe=""), page=1, **plugin.request.args_dict))
def piratebay_search():
    import urllib

    query = plugin.request.args.get("query")
    if query:
        query = query[0]
    else:
        query = plugin.keyboard("", "streamajoker - The Pirate Bay - Search")
    if query:
        plugin.redirect(plugin.url_for("piratebay_page", root="/search/%s" % urllib.quote(query, safe=""), page=0))
def yify_search():
    query = plugin.request.args.get("query")
    if query:
        query = query[0]
    else:
        query = plugin.keyboard("", "streamajoker - YIFY - Search")
    if query:
        plugin.redirect(
            plugin.url_for("yify_search_query", keywords=query, quality="all", set=1, limit=MOVIES_PER_PAGE)
        )
def extratorrent_search():
    query = plugin.request.args_dict.pop("query", None)
    if not query:
        query = plugin.keyboard("", "streamajoker - ExtraTorrent - Search")
    if query:
        plugin.redirect(plugin.url_for("extratorrent_page_search", type="search", search=query, **plugin.request.args_dict))
def bitsnoop_index():
    plugin.redirect(plugin.url_for("bitsnoop_search"))
def btdigg_search():
    query = plugin.request.args_dict.pop("query", None)
    if not query:
        query = plugin.keyboard("", "streamajoker - BTDigg - Search")
    if query:
        plugin.redirect(plugin.url_for("btdigg_page", query=query, sort=SORT_POPULARITY, page=0, **plugin.request.args_dict))
def btdigg_index():
    plugin.redirect(plugin.url_for("btdigg_search"))