def index(): try: items = [] if len(PROVIDERS['movies']) == 1: sys_kwargs = { 'module': import_module(provider), 'provider': PROVIDERS['movies'][0] } for item in sys_kwargs['module'].list(): if not item.get("kodipopcorn_endpoint"): continue kwargs = {} if item.get("kodipopcorn_kwargs"): kwargs = item.pop('kodipopcorn_kwargs') item["path"] = plugin.url_for(item.pop('kodipopcorn_endpoint'), **kwargs.update(sys_kwargs)) items.append(item) elif len(PROVIDERS['movies']) > 0: for provider in PROVIDERS: module = import_module(provider) item["path"] = plugin.url_for('list', provider=provider, module=module) items.append(module.INDEX) plugin.finish(items, update_listing=False) except: plugin.notify("{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def index(): try: items = [] if len(PROVIDERS['movies']) == 1: sys_kwargs = { 'module': import_module(provider), 'provider': PROVIDERS['movies'][0] } for item in sys_kwargs['module'].list(): if not item.get("kodipopcorn_endpoint"): continue kwargs = {} if item.get("kodipopcorn_kwargs"): kwargs = item.pop('kodipopcorn_kwargs') item["path"] = plugin.url_for(item.pop('kodipopcorn_endpoint'), **kwargs.update(sys_kwargs)) items.append(item) elif len(PROVIDERS['movies']) > 0: for provider in PROVIDERS: module = import_module(provider) item["path"] = plugin.url_for('list', provider=provider, module=module) items.append(module.INDEX) plugin.finish(items, update_listing=False) except: plugin.notify( "{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def index(): for provider in providers['movie']: yield { "label": provider['label'], "icon": path.join(RESOURCES_PATH, 'media', provider['icon']), "thumbnail": path.join(RESOURCES_PATH, 'media', provider['thumbnail']), "path": plugin.url_for(provider['path']) } return yify.list()
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", label=label, href=item["path"])), ]) yield item
def search(): try: query = plugin.keyboard("", plugin.addon.getLocalizedString(30001)) if query: kwargs, sys_kwargs = _filter_kwargs({'query': query, 'page': 1}) plugin.redirect( plugin.url_for("search_query", **kwargs.update(sys_kwargs))) except: plugin.notify( "{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def search(): try: query = plugin.keyboard("", plugin.addon.getLocalizedString(30001)) if query: kwargs, sys_kwargs = _filter_kwargs({ 'query': query, 'page': 1 }) plugin.redirect(plugin.url_for("search_query", **kwargs.update(sys_kwargs))) except: plugin.notify("{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
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", label=label, href=item["path"])), ]) yield item
def list(): try: kwargs, sys_kwargs = _filter_kwargs() for item in sys_kwargs['module'].list(**kwargs): if not item.get("kodipopcorn_endpoint"): continue kwargs = {} if item.get("kodipopcorn_kwargs"): kwargs = item.pop('kodipopcorn_kwargs') item["path"] = plugin.url_for(item.pop('kodipopcorn_endpoint'), **kwargs.update(sys_kwargs)) yield item except: plugin.notify("{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def list(): try: kwargs, sys_kwargs = _filter_kwargs() for item in sys_kwargs['module'].list(**kwargs): if not item.get("kodipopcorn_endpoint"): continue kwargs = {} if item.get("kodipopcorn_kwargs"): kwargs = item.pop('kodipopcorn_kwargs') item["path"] = plugin.url_for(item.pop('kodipopcorn_endpoint'), **kwargs.update(sys_kwargs)) yield item except: plugin.notify( "{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def browse(provider, item, page): try: kwargs, sys_kwargs = _filter_kwargs() content = 'movies' items = [] with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1=plugin.addon.getLocalizedString(30007)) movies = sys_kwargs['module'].browse(item, page, **kwargs) jobs = len(movies) * 2 + 1 done = 1 dialog.update(percent=int(done * 100 / jobs), line2=plugin.addon.getLocalizedString(30007)) def on_future_done(future): done = done + 1 data = future.result() dialog.update(percent=int(done * 100 / jobs), line2="{prefix}{label}".format( prefix=data.get('kodipopcorn_subtitle', ''), label=data.get("label", ''))) subtitle = import_module(PROVIDERS['subtitle.yify']) meta = import_module(PROVIDERS['meta.tmdb']) with futures.ThreadPoolExecutor(max_workers=2) as pool: subtitle_list = [ pool.submit( subtitle.get, id=item.get( "info", {}).get("code")).add_done_callback(on_future_done) for item in movies ] meta_list = [ pool.submit(meta.get, id=item.get( "info", {}).get("code")).add_done_callback(on_future_done) for item in movies ] while not all(future.done() for future in subtitle_list) and not all( future.done() for future in meta_list): if dialog.iscanceled(): return xbmc.sleep(100) subtitles = map(lambda future: future.result(), subtitle_list) metadata = map(lambda future: future.result(), meta_list) for i, movie in enumerate(movies): # Update the movie with subtitle and meta data movie.update(subtitles[i]) movie.update(metadata[i]) # Catcher content type and remove it from movie # NOTE: This is not the best way to dynamic set the content type, since the content type can not be set for each movie if movie.get("kodipopcorn_content"): content = movie.pop('kodipopcorn_content') # Catcher quality, build magnet label and remove quality from movie quality = fQuality = '' if movie.get("kodipopcorn_quality"): quality = movie.pop('kodipopcorn_quality') fQuality = " [{quality}]".format(quality=quality) # Build magnet label fYear = '' if movie.get("year"): fYear = " ({year})".format(year=movie["year"]) # Builds targets for the player kwargs = {} if movie.get("kodipopcorn_subtitle"): kwargs['subtitle'] = movie.pop('kodipopcorn_subtitle') kwargs.update({ 'url': from_meta_data(movie.pop('kodipopcorn_hash'), movie["label"] + fYear + fQuality), 'info': movie }) # Update the final information for the movie if quality and not quality == '720p': movie["label"] = "{label} ({quality})".format( label=movie["label"], quality=quality) movie["path"] = plugin.url_for('play', **kwargs) items.append(movie) if items: plugin.set_content(content) return items raise AnErrorOccurred(30307) except AnErrorOccurred as e: plugin.notify("{default} {strerror}".format( default=plugin.addon.getLocalizedString(30306), strerror=plugin.addon.getLocalizedString(e.errno)), delay=15000) except: plugin.notify( "{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
def browse(provider, item, page): try: kwargs, sys_kwargs = _filter_kwargs() content = 'movies' items = [] with closing(SafeDialogProgress(delay_close=0)) as dialog: dialog.create(plugin.name) dialog.update(percent=0, line1=plugin.addon.getLocalizedString(30007)) movies = sys_kwargs['module'].browse(item, page, **kwargs) jobs = len(movies)*2+1 done = 1 dialog.update(percent=int(done*100/jobs), line2=plugin.addon.getLocalizedString(30007)) def on_future_done(future): done = done+1 data = future.result() dialog.update(percent=int(done*100/jobs), line2="{prefix}{label}".format(prefix=data.get('kodipopcorn_subtitle', ''), label=data.get("label", ''))) subtitle = import_module(PROVIDERS['subtitle.yify']) meta = import_module(PROVIDERS['meta.tmdb']) with futures.ThreadPoolExecutor(max_workers=2) as pool: subtitle_list = [pool.submit(subtitle.get, id=item.get("info", {}).get("code")).add_done_callback(on_future_done) for item in movies] meta_list = [pool.submit(meta.get, id=item.get("info", {}).get("code")).add_done_callback(on_future_done) for item in movies] while not all(future.done() for future in subtitle_list) and not all(future.done() for future in meta_list): if dialog.iscanceled(): return xbmc.sleep(100) subtitles = map(lambda future: future.result(), subtitle_list) metadata = map(lambda future: future.result(), meta_list) for i, movie in enumerate(movies): # Update the movie with subtitle and meta data movie.update(subtitles[i]) movie.update(metadata[i]) # Catcher content type and remove it from movie # NOTE: This is not the best way to dynamic set the content type, since the content type can not be set for each movie if movie.get("kodipopcorn_content"): content = movie.pop('kodipopcorn_content') # Catcher quality, build magnet label and remove quality from movie quality=fQuality='' if movie.get("kodipopcorn_quality"): quality = movie.pop('kodipopcorn_quality') fQuality = " [{quality}]".format(quality=quality) # Build magnet label fYear = '' if movie.get("year"): fYear = " ({year})".format(year=movie["year"]) # Builds targets for the player kwargs = {} if movie.get("kodipopcorn_subtitle"): kwargs['subtitle'] = movie.pop('kodipopcorn_subtitle') kwargs.update({ 'url': from_meta_data(movie.pop('kodipopcorn_hash'), movie["label"]+fYear+fQuality), 'info': movie }) # Update the final information for the movie if quality and not quality == '720p': movie["label"] = "{label} ({quality})".format(label=movie["label"], quality=quality) movie["path"] = plugin.url_for('play', **kwargs) items.append(movie) if items: plugin.set_content(content) return items raise AnErrorOccurred(30307) except AnErrorOccurred as e: plugin.notify("{default} {strerror}".format(default=plugin.addon.getLocalizedString(30306), strerror=plugin.addon.getLocalizedString(e.errno)), delay=15000) except: plugin.notify("{default}".format(default=plugin.addon.getLocalizedString(30306)), delay=15000)
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)