Exemplo n.º 1
0
def get(id):
    with shelf("com.imdb.{id}".format(id=id), DEFAULT_TTL) as movie:
        if not movie:
            meta = url_get("{base_url}/movie/{id}".format(base_url=BASE_URL,
                                                          id=id),
                           params={
                               "api_key": API_KEY,
                               "append_to_response": "credits",
                               "language": "en",
                               "include_image_language": "en,null"
                           },
                           headers=HEADERS)
            if meta.get('status_code'):
                return dict()
            sys_lang = xbmc.getLanguage(xbmc.ISO_639_1)
            if not sys_lang == 'en':
                sys_meta = url_get("{base_url}/movie/{id}".format(
                    base_url=BASE_URL, id=id),
                                   params={
                                       "api_key": API_KEY,
                                       "append_to_response": "credits",
                                       "language": sys_lang,
                                       "include_image_language": sys_lang
                                   },
                                   headers=HEADERS)
                meta.update(cleanDictList(sys_meta))
            movie = _get_list_item(meta)
        return movie
Exemplo n.º 2
0
def get(id):
    with shelf("com.imdb.{id}".format(id=id), DEFAULT_TTL) as movie:
        if not movie:
            meta = url_get("{base_url}/movie/{id}".format(base_url=BASE_URL, id=id), params={"api_key": API_KEY, "append_to_response": "credits", "language": "en", "include_image_language": "en,null"}, headers=HEADERS)
            if meta.get('status_code'):
                return dict()
            sys_lang = xbmc.getLanguage(xbmc.ISO_639_1)
            if not sys_lang == 'en':
                sys_meta = url_get("{base_url}/movie/{id}".format(base_url=BASE_URL, id=id), params={"api_key": API_KEY, "append_to_response": "credits", "language": sys_lang, "include_image_language": sys_lang}, headers=HEADERS)
                meta.update(cleanDictList(sys_meta))
            movie = _get_list_item(meta)
        return movie
Exemplo n.º 3
0
def search(query, page, **kwargs):
    params = {
        'limit': kwargs['limit'],
        'page': page,
        'quality': 'all',
        'query_term': query
    }
    data = url_get(_getDomains(),
                   "/api/v2/list_movies.json",
                   params=params,
                   proxyid=_proxy_identifier)
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    items = []
    for movie in movies:
        if not movie.get("title") or not movie.get("imdb_code"):
            continue
        item = _create_item(movie, kwargs['qualities'])
        if not item:
            continue
        items.append(item)

    _tmp = int(data.get("data", {}).get("movie_count", 20)) / int(
        kwargs['limit'])
    pages = int(_tmp)
    if _tmp > pages:
        pages = pages + 1

    return {'pages': pages, 'items': items}
Exemplo n.º 4
0
def get(id, label, year):
    data = url_get("http://api.yifysubtitles.com", "/subs/" + id).get("subs", {}).get(id)
    if not data:
        return {}

    for l in [
        _subtitlelang[int(__addon__.getSetting("sub_language1"))],
        _subtitlelang[int(__addon__.getSetting("sub_language2"))],
        _subtitlelang[int(__addon__.getSetting("sub_language3"))],
    ]:
        subtitles = data.get(l)
        if not subtitles:
            continue
        subtitle = subtitles.pop(0)
        for s in subtitles:
            hi = s["hi"]
            if __addon__.getSetting("hearing_impaired") == "true":
                hi = -(s["hi"] - 2)
            if s["rating"] <= subtitle["rating"] and hi >= subtitle["hi"] or hi > subtitle["hi"]:
                continue
            subtitle = s

        lang = _subtitle_iso[l]
        return {
            "label": label,
            "subtitle": "http://www.yifysubtitles.com" + subtitle["url"],
            "stream_info": {"subtitle": {"language": lang}},
        }
    return {}
Exemplo n.º 5
0
def browse(separate, page, **kwargs):
    params = {
        'limit': kwargs['limit'],
        'page': page,
        'quality': 'all',
        'genre': separate == "genre" and kwargs['genre'] or 'all',
        'sort_by': separate == "genre" and "seeds" or separate,
        'order_by': 'desc',
    }
    data = url_get(_getDomains(),
                   "/api/v2/list_movies.json",
                   params=params,
                   proxyid=_proxy_identifier)
    if not data:
        return {}
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    items = []
    for movie in movies:
        if not movie.get("title") or not movie.get("imdb_code"):
            continue
        item = _create_item(movie, kwargs['qualities'])
        if not item:
            continue
        items.append(item)

    _tmp = int(data["data"].get("movie_count", 20)) / int(kwargs['limit'])
    pages = int(_tmp)
    if _tmp > pages:
        pages = pages + 1

    return {'pages': pages, 'items': items}
Exemplo n.º 6
0
def search(query, page, **kwargs):
    params = {
        'limit': kwargs['limit'],
        'page': page,
        'quality': 'all',
        'query_term': query
    }
    data = url_get(_getDomains(), "/api/v2/list_movies.json", params=params, proxyid=_proxy_identifier)
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    items = []
    for movie in movies:
        if not movie.get("title") or not movie.get("imdb_code"):
            continue
        item = _create_item(movie, kwargs['qualities'])
        if not item:
            continue
        items.append(item)

    _tmp = int(data.get("data", {}).get("movie_count", 20))/int(kwargs['limit'])
    pages = int(_tmp)
    if _tmp > pages:
        pages = pages+1

    return {
        'pages': pages,
        'items': items
    }
Exemplo n.º 7
0
def browse(separate, page, **kwargs):
    params = {
        'limit': kwargs['limit'],
        'page': page,
        'quality': 'all',
        'genre': separate == "genre" and kwargs['genre'] or 'all',
        'sort_by': separate == "genre" and "seeds" or separate,
        'order_by': 'desc',
    }
    data = url_get(_getDomains(), "/api/v2/list_movies.json", params=params, proxyid=_proxy_identifier)
    if not data:
        return {}
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    items = []
    for movie in movies:
        if not movie.get("title") or not movie.get("imdb_code"):
            continue
        item = _create_item(movie, kwargs['qualities'])
        if not item:
            continue
        items.append(item)

    _tmp = int(data["data"].get("movie_count", 20))/int(kwargs['limit'])
    pages = int(_tmp)
    if _tmp > pages:
        pages = pages+1

    return {
        'pages': pages,
        'items': items
    }
Exemplo n.º 8
0
def search(query):
    return url_get("{base_url}/search/movie".format(base_url=BASE_URL),
                   params={
                       "api_key": API_KEY,
                       "query": query,
                       "language": "en"
                   },
                   headers=HEADERS)
Exemplo n.º 9
0
def _tmdb_config():
    with shelf("meta.imdb.conf", 24 * 3600) as conf:
        if not conf:
            try:
                conf.update(url_get(_base_url, "/3/configuration", params={"api_key": _api_key}))
            except:
                return {}
        return dict(conf)
Exemplo n.º 10
0
def _tmdb_config():
    with shelf("meta.imdb.conf", 24 * 3600) as conf:
        if not conf:
            try:
                conf.update(url_get(_base_url, "/3/configuration", params={"api_key": _api_key}))
            except:
                return {}
        return dict(conf)
Exemplo n.º 11
0
def tmdb_config():
    with shelf("com.imdb.conf", DEFAULT_TTL) as conf:
        if not conf:
            try:
                conf.update(url_get("{base_url}/configuration".format(base_url=BASE_URL), params={"api_key": API_KEY}, headers=HEADERS))
            except:
                return dict()
        return dict(conf)
Exemplo n.º 12
0
def get(id, label, year):
    # English
    params={
        "api_key": _api_key,
        "append_to_response": "credits",
        "language": "en",
        "include_image_language": "en,null"
    }
    meta = url_get(_base_url, "/3/movie/{id}".format(id=id), params=params)
    if not meta or meta.get('status_code'):
        return {}

    # System language
    sys_lang = xbmc.getLanguage(xbmc.ISO_639_1)
    if not sys_lang == 'en':
        params.update({"language": sys_lang, "include_image_language": sys_lang})
        sys_meta = url_get(_base_url, "/3/movie/{id}".format(id=id), params=params)
        if sys_meta and not sys_meta.get('status_code'):
            meta.update(cleanDictList(sys_meta))

    return _create_item(meta)
Exemplo n.º 13
0
def get(id, label, year):
    # English
    params={
        "api_key": _api_key,
        "append_to_response": "credits",
        "language": "en",
        "include_image_language": "en,null"
    }
    meta = url_get(_base_url, "/3/movie/{id}".format(id=id), params=params)
    if not meta or meta.get('status_code'):
        return {}

    # System language
    sys_lang = xbmc.getLanguage(xbmc.ISO_639_1)
    if not sys_lang == 'en':
        params.update({"language": sys_lang, "include_image_language": sys_lang})
        sys_meta = url_get(_base_url, "/3/movie/{id}".format(id=id), params=params)
        if sys_meta and not sys_meta.get('status_code'):
            meta.update(cleanDictList(sys_meta))

    return _create_item(meta)
Exemplo n.º 14
0
def tmdb_config():
    with shelf("com.imdb.conf", DEFAULT_TTL) as conf:
        if not conf:
            try:
                conf.update(
                    url_get(
                        "{base_url}/configuration".format(base_url=BASE_URL),
                        params={"api_key": API_KEY},
                        headers=HEADERS))
            except:
                return dict()
        return dict(conf)
Exemplo n.º 15
0
def get(query, **kwargs):
    params = {'limit': 1, 'page': 1, 'quality': 'all', 'query_term': query}
    data = url_get(_getDomains(),
                   "/api/v2/list_movies.json",
                   params=params,
                   proxyid=_proxy_identifier)
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    if not movies[0].g("title") or not movies[0].get("imdb_code"):
        return []

    return _create_item(movies[0], kwargs['qualities'])
Exemplo n.º 16
0
def get(query, **kwargs):
    params = {
        'limit': 1,
        'page': 1,
        'quality': 'all',
        'query_term': query
    }
    data = url_get(_getDomains(), "/api/v2/list_movies.json", params=params, proxyid=_proxy_identifier)
    movies = data.get("data", {}).get("movies")
    if not movies:
        return {}

    if not movies[0].g("title") or not movies[0].get("imdb_code"):
        return []

    return _create_item(movies[0], kwargs['qualities'])
Exemplo n.º 17
0
def from_torrent_url(url):
    import base64
    import bencode
    import hashlib
    from kodipopcorntime.utils import url_get
    torrent_data = url_get(url)
    metadata = bencode.bdecode(torrent_data)
    hashcontents = bencode.bencode(metadata['info'])
    digest = hashlib.sha1(hashcontents).digest()
    b32hash = base64.b32encode(digest)
    params = {
        'dn': metadata['info']['name'],
        'tr': metadata['announce'],
    }
    plugin.log.info(params)
    paramstr = urllib.urlencode(params, doseq=True)
    return 'magnet:?%s&%s' % ('xt=urn:btih:%s' % b32hash, paramstr)
Exemplo n.º 18
0
def search(query, page, **kwargs):
    params = {
        "api_key": _api_key,
        "query": query,
        "language": "en",
        "page": page
    }
    results = url_get(_base_url, "/3/search/movie".format(id=id), params=params)
    if results.get('status_code'):
        return {}
    items = []
    for movie in results:
        items.append(_create_item(movie))
    return {
        'pages': data.get("total_pages", 1),
        'items': items
    }
Exemplo n.º 19
0
def search(query, page, **kwargs):
    params = {
        "api_key": _api_key,
        "query": query,
        "language": "en",
        "page": page
    }
    results = url_get(_base_url, "/3/search/movie".format(id=id), params=params)
    if results.get('status_code'):
        return {}
    items = []
    for movie in results:
        items.append(_create_item(movie))
    return {
        'pages': data.get("total_pages", 1),
        'items': items
    }
Exemplo n.º 20
0
 def proc_close():
     if not proc.poll():
         url_get("http://%s/shutdown" % proc.bind_address)
Exemplo n.º 21
0
 def proc_close():
     if not proc.poll():
         url_get("http://%s/shutdown" % proc.bind_address,
                 with_immunicity=False)
Exemplo n.º 22
0
def search(query):
    return url_get("{base_url}/search/movie".format(base_url=BASE_URL), params={"api_key": API_KEY, "query": query, "language": "en"}, headers=HEADERS)
Exemplo n.º 23
0
 def proc_close():
     if not proc.poll():
         url_get("http://%s/shutdown" % proc.bind_address, with_immunicity=False)
Exemplo n.º 24
0
def list(**kwargs):
    if kwargs['item'] == 'genres':
        items= []
        for i, genre in enumerate(GENRES):
            items.append({
                "label": plugin.addon.getLocalizedString((30400 + i)),
                "kodipopcorn_endpoint": "browse",
                "kodipopcorn_items": {
                    'item': "genre",
                    'genre': v
                }
            }
        return items

    return [
        {
            "label": plugin.addon.getLocalizedString(30002),
            "icon": path.join(RESOURCES_PATH, 'media', 'Search.png'),
            "thumbnail": path.join(RESOURCES_PATH, 'media', 'Search.png'),
            "kodipopcorn_endpoint": "search"
        },
        {
            "label": plugin.addon.getLocalizedString(30003),
            "icon": path.join(RESOURCES_PATH, 'media', 'Genres.png'),
            "thumbnail": path.join(RESOURCES_PATH, 'media', 'Genres.png'),
            "kodipopcorn_endpoint": "list",
            "kodipopcorn_kwargs": {
                'item': "genres"
            }
        },
        {
            "label": plugin.addon.getLocalizedString(30004),
            "icon": path.join(RESOURCES_PATH, 'media', 'Top.png'),
            "thumbnail": path.join(RESOURCES_PATH, 'media', 'Top.png'),
            "kodipopcorn_endpoint": "browse",
            "kodipopcorn_kwargs": {
                'item': "seeds",
                'page': 1
            }
        },
        {
            "label": plugin.addon.getLocalizedString(30005),
            "icon": path.join(RESOURCES_PATH, 'media', 'Top.png'),
            "thumbnail": path.join(RESOURCES_PATH, 'media', 'Top.png'),
            "kodipopcorn_endpoint": "browse",
            "kodipopcorn_kwargs": {
                'item': "rating",
                'page': 1
            }
        },
        {
            "label": plugin.addon.getLocalizedString(30006),
            "icon": path.join(RESOURCES_PATH, 'media', 'Recently.png'),
            "thumbnail": path.join(RESOURCES_PATH, 'media', 'Recently.png'),
            "kodipopcorn_endpoint": "browse",
            "kodipopcorn_kwargs": {
                'item': "date",
                'page': 1
            }
        }
    ]

def search_show_data():
    plugin.set_content("movies")
    args = dict((k, v[0]) for k, v in plugin.request.args.items())

    current_page = int(args["page"])
    limit = int(args["limit"])

    with closing(SafeDialogProgress(delay_close=0)) as dialog:
        dialog.create(plugin.name)
        dialog.update(percent=0, line1=plugin.addon.getLocalizedString(30007), line2="", line3="")

        try:
            search_result = tmdb.search(args[query])
        except:
            pass

        if not movies:
            if callback == "search_query":
                yield {
                        "label": plugin.addon.getLocalizedString(30008),
                        "icon": path.join(RESOURCES_PATH, 'icons', 'Search.png'),
                        "thumbnail": path.join(RESOURCES_PATH, 'icons', 'Search.png'),
                        "path": plugin.url_for("search")
                    }
            return

        state = {"done": 0}
        def on_movie(future):
            data = future.result()
            state["done"] += 1
            dialog.update(
                percent=int(state["done"] * 100.0 / len(movies)),
                line2=data.get("title") or data.get("MovieTitleClean") or "",
            )

        with futures.ThreadPoolExecutor(max_workers=2) as pool_tmdb:
            tmdb_list = [pool_tmdb.submit(tmdb.get, movie["imdb_code"]) for movie in movies]
            [future.add_done_callback(on_movie) for future in tmdb_list]
            while not all(job.done() for job in tmdb_list):
                if dialog.iscanceled():
                    return
                xbmc.sleep(100)

        tmdb_list = map(lambda job: job.result(), tmdb_list)
        for movie, tmdb_meta in izip(movies, tmdb_list):
            if tmdb_meta:
                sub = yifysubs.get_sub_items(movie["imdb_code"])
                if sub == None:
                    sub = ["none", ""]

                item = tmdb.get_list_item(tmdb_meta)
                for torrent in movie["torrents"]:
                    if args.get("quality") == "all" and torrent["quality"] != "720p":
                        item["label"] = "%s (%s)" % (item["label"], torrent["quality"])

                    if item.get("info", {}).get("duration") == 0:
                        item["info"]["duration"] = movie["runtime"]

                    item.update({
                        "path": plugin.url_for("play", sub=sub[0], uri=from_meta_data(torrent["hash"], movie["title_long"], torrent["quality"])),
                        "is_playable": True,
                    })

                    item.setdefault("info", {}).update({
                        "code": movie["imdb_code"],
                        "size": torrent["size_bytes"],
                    })

                    width = 1920
                    height = 1080
                    if torrent["quality"] == "720p":
                        width = 1280
                        height = 720
                    item.setdefault("stream_info", {}).update({
                        "video": {
                            "codec": "h264",
                            "width": width,
                            "height": height,
                        },
                        "audio": {
                            "codec": "aac",
                            "language": "en",
                        },
                        "subtitle": {
                            "language": sub[1],
                        },
                    })

                    yield item

        if current_page < (movie_count / limit):
            next_args = args.copy()
            next_args["page"] = int(next_args["page"]) + 1
            yield {
                "label": plugin.addon.getLocalizedString(30009),
                "path": plugin.url_for("search_query", **next_args),
            }

def browse(item, page, **kwargs):
    params = {
        'limit': kwargs['limit'],
        'page': page,
        'quality': kwargs['quality'],
        'genre': item == "genre" and item or 'all',
        'sort_by': item == "genre" and "seeds" or item,
        'order_by': 'desc',
    }
    for proxy in update_proxies(PROXY_IDENTIFIER, getURLS()): # Update proxy list if there is any changes
        try:
            search_result = url_get("{proxy}/api/v2/list_movies.json".format(proxy=proxy), params=params, headers={"Referer": proxy})
            # Prioritizes the last known domain that did work
            set_default_proxy(PROXY_ID, proxy)
            break
        except:
            pass
    if not search_result:
        raise AnErrorOccurred(30304)

    movies = search_result.get("data", {}).get("movies")
    if not movies:
        raise AnErrorOccurred(30305)

    items = []
    for movie in movies:
        if not movie.get("title") or not movie.get("imdb_code"):
            continue

        for torrent in movie["torrents"]:
            if not torrent.get("hash") or not torrent.get("quality"):
                continue

            width = 1920
            height = 1080
            if torrent["quality"] == "720p":
                width = 1280
                height = 720

            items.append({
                "label": movie["title"],
                "icon": movie.get("medium_cover_image", movie.get("small_cover_image", '')),
                "thumbnail": movie.get("medium_cover_image", movie.get("small_cover_image", '')),
                "kodipopcorn_hash": torrent["hash"],
                "kodipopcorn_quality": torrent["quality"],
                "info": {
                    "title": movie["title"],
                    "genre": movie.get("genres") and " / ".join([genre for genre in movie["genres"]]) or "",
                    "duration": movie.get("runtime", 0),
                    "code": movie["imdb_code"],
                    "size": torrent.get("size_bytes", 0),
                    "year": movie.get("year", '')
                },
                "properties": {
                    "fanart_image": movie.get("background_image", '')
                },
                "stream_info": {
                    "video": {
                        "codec": "h264",
                        "width": width,
                        "height": height
                    },
                    "audio": {
                        "codec": "aac",
                        "language": "en"
                    }
                }
            })

    if items:
        return items
    raise AnErrorOccurred(30307)

def search_query(provider, item, query, page, **kwargs):
    kwargs.update({
        "provider": provider,
        "item": item,
        "query": query,
        "page": page,
    })
    return show_data(**kwargs)