示例#1
0
def trakt_get_genres():
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    genres_dict.update(
        dict([(x['slug'], x['name'])
              for x in trakt.trakt_get_genres("shows")]))
    return genres_dict
示例#2
0
def list_trakt_movies_basic(results):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item, genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#3
0
def trakt_movies_recommendations(raw=False):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    result = trakt.get_recommendations("movies")
    if raw: return result
    else: return list_trakt_movies_basic(result)
示例#4
0
def list_trakt_movies_trending_paginated(results, pages, page):
    from trakt import trakt
    results = sorted(
        results,
        key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    movies = [
        get_trakt_movie_metadata(item["movie"], genres_dict)
        for item in results
    ]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > page:
        items.append({
            'label':
            "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path':
            plugin.url_for("trakt_movies_trending", page=page + 1),
            'icon':
            get_icon_path("item_next"),
            'properties': {
                'fanart_image': get_background_path()
            },
        })
    if FORCE == True:
        return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else:
        return plugin.finish(items=items, sort_methods=SORT)
示例#5
0
def list_trakt_movie_items_with_genres(results, pages, page):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    movies = [
        get_trakt_movie_metadata(item["movie"], genres_dict)
        for item in results
    ]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > 1:
        args = caller_args()
        args['page'] = page + 1
        items.append({
            'label':
            "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path':
            plugin.url_for(caller_name(), **args),
            'icon':
            get_icon_path("item_next"),
            'properties': {
                'fanart_image': get_background_path()
            }
        })
    if FORCE == True:
        return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else:
        return plugin.finish(items=items, sort_methods=SORT)
示例#6
0
文件: movies.py 项目: uguer30/Project
def list_trakt_movies_basic(results):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item, genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORTRAKT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORTRAKT)
示例#7
0
def list_trakt_movies(results):
    from trakt import trakt
    results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return items
示例#8
0
def tv_trakt_recommendations():
    from trakt import trakt
    genres_dict = trakt.trakt_get_genres("tv")
    shows = trakt.get_recommendations("shows")
    items = []
    for show in shows:
        items.append(make_tvshow_item(get_tvshow_metadata_trakt(show, genres_dict)))
    return items
示例#9
0
def tv_trakt_recommendations():
    from trakt import trakt
    genres_dict = trakt.trakt_get_genres("tv")
    shows = trakt.get_recommendations("shows")
    items = []
    for show in shows:
        items.append(make_tvshow_item(get_tvshow_metadata_trakt(show, genres_dict)))
    return items
示例#10
0
def movies_trakt_recommendations():
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = trakt.get_recommendations("movies")
    items = []
    for movie in movies:
        items.append(make_movie_item(get_trakt_movie_metadata(movie, genres_dict)))
    return items
示例#11
0
def trakt_tv_recommendations():
    from trakt import trakt
    genres_dict = trakt.trakt_get_genres("tv")
    shows = trakt.get_recommendations("shows")
    items = []
    for show in shows:
        items.append(make_tvshow_item(get_tvshow_metadata_trakt(show, genres_dict)))
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#12
0
def list_trakt_movies(results):
    from trakt import trakt
    
    results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    return items
示例#13
0
def movies_trakt_recommendations():
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = trakt.get_recommendations("movies")
    items = []
    for movie in movies:
        items.append(make_movie_item(get_trakt_movie_metadata(movie, genres_dict)))
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#14
0
def movies_trakt_recommendations():
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    movies = trakt.get_recommendations("movies")
    items = []
    for movie in movies:
        items.append(
            make_movie_item(get_trakt_movie_metadata(movie, genres_dict)))
    return items
示例#15
0
def list_trakt_movies_trending_paginated(results, pages, page):
    from trakt import trakt
    results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    if int(pages) > int(page):
        items.append({
            'label': _("Next page").format() + "  >>  (%s/%s)" % (int(page) + 1, int(pages)),
            'path': plugin.url_for("trakt_movies_trending", page=int(page) + 1),
            'icon': get_icon_path("item_next"),
        })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#16
0
def list_trakt_movies(results):
    from trakt import trakt

    results = sorted(
        results,
        key=lambda item: item["movie"]["title"].lower().replace("the ", ""))

    genres_dict = dict([(x['slug'], x['name'])
                        for x in trakt.trakt_get_genres("movies")])
    movies = [
        get_trakt_movie_metadata(item["movie"], genres_dict)
        for item in results
    ]
    items = [make_movie_item(movie) for movie in movies]
    return items
示例#17
0
def list_trakt_movies_trending_paginated(results, pages, page):
    from trakt import trakt
    results = sorted(results,key=lambda item: item["movie"]["title"].lower().replace("the ", ""))
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > page:
        items.append({
            'label': "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path': plugin.url_for("trakt_movies_trending", page=page + 1),
            'icon': get_icon_path("item_next"),
            'properties' : {'fanart_image' : get_background_path()},
        })
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#18
0
def list_trakt_movie_items_with_genres(results, pages, page):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    movies = [get_trakt_movie_metadata(item["movie"], genres_dict) for item in results]
    items = [make_movie_item(movie) for movie in movies]
    page = int(page)
    pages = int(pages)
    if pages > 1:
        args = caller_args()
        args['page'] = page + 1
        items.append({
            'label': "{0}  >>  ({1}/{2})".format(_("Next page"), page + 1, pages),
            'path': plugin.url_for(caller_name(), **args),
            'icon': get_icon_path("item_next"),
            'properties' : {'fanart_image' : get_background_path()}})
    if FORCE == True: return plugin.finish(items=items, sort_methods=SORT, view_mode=VIEW)
    else: return plugin.finish(items=items, sort_methods=SORT)
示例#19
0
def _lists_trakt_show_list(list_items):
    genres_dict = trakt.trakt_get_genres("tv")
    if type(list_items) == str:
        import urllib
        list_items = eval(urllib.unquote(list_items))
    items = []
    for list_item in list_items:
        item = None
        item_type = list_item["type"]
        if item_type == "show":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            if tvdb_id != "" and tvdb_id != None:
                show = list_item["show"]
                info = get_tvshow_metadata_trakt(show, genres_dict)
                context_menu = [
                    (
                        _("Scan item to library"),
                        "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                    ),
                    (
                        _("TV show information"), 'Action(Info)'
                    ),
                    (
                        "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                        "RunPlugin({0})".format(plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id))
                    )
                ]
                if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK, bool) == False:
                    item = ({
                        'label': info['title'],
                        'path': plugin.url_for("tv_tvshow", id=tvdb_id),
                        'context_menu': context_menu,
                        'thumbnail': info['poster'],
                        'icon': get_icon_path("tv"),
                        'poster': info['poster'],
                        'properties' : {'fanart_image' : info['fanart']},
                        'info_type': 'video',
                        'stream_info': {'video': {}},
                        'info': info
                    })
                else: item = make_tvshow_item(info)
            else: item = None
        elif item_type == "season":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            season = list_item["season"]
            show = list_item["show"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            season_info = get_season_metadata_trakt(show_info,season, genres_dict)
            label = "{0} - Season {1}".format(show["title"],season["number"])
            context_menu = [
                (
                    _("Scan item to library"),
                    "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                ),
                (
                    "%s %s" % (_("Season"), _("Information").lower()), 'Action(Info)'
                ),
                (
                    "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb",
                                                           id=tvdb_id, season=list_item["season"]["number"]))
                )
            ]
            item = ({
                'label': label,
                'path': plugin.url_for("tv_season", id=tvdb_id, season_num=list_item["season"]["number"]),
                'context_menu': context_menu,
                'info': season_info,
                'thumbnail': season_info['poster'],
                'icon': get_icon_path("tv"),
                'poster': season_info['poster'],
                'properties': {'fanart_image': season_info['fanart']},
            })
        elif item_type == "episode":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            episode = list_item["episode"]
            show = list_item["show"]
            season_number = episode["season"]
            episode_number = episode["number"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            episode_info = get_episode_metadata_trakt(show_info, episode)
            label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number,
                                                  episode_number, episode_info["title"])
            context_menu = [
                (
                    "{0} {1}...".format(_("Select"), _("Stream").lower()),
                    "PlayMedia({0})".format(
                        plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='select'))
                ),
                (
                    "%s %s" % (_("Episode"), _("Information").lower()),
                    'Action(Info)'
                ),
                (
                    _("Add to playlist"),
                    "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id,
                                                           season=season_number, episode=episode_number))
                ),
                (
                    "{0}".format(_("Remove from library").replace(_("Library").lower(),_("Playlist").lower())),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id,
                                                           season=season_number, episode = episode_number))
                )
            ]
            item = ({
                'label': label,
                'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='default'),
                'context_menu': context_menu,
                'info': episode_info,
                'is_playable': True,
                'info_type': 'video',
                'stream_info': {'video': {}},
                'thumbnail': episode_info['poster'],
                'poster': episode_info['poster'],
                'icon': get_icon_path("tv"),
                'properties': {'fanart_image': episode_info['fanart']},
                })
        elif item_type == "movie":
            movie = list_item["movie"]
            movie_info = get_trakt_movie_metadata(movie)
            try: tmdb_id = movie_info['tmdb']
            except: tmdb_id = ""
            try: imdb_id = movie_info['imdb']
            except: imdb_id = ""
            if tmdb_id != None and tmdb_id != "":
                src = "tmdb"
                id = tmdb_id
            elif imdb_id != None and mdb_id != "":
                src = "imdb"
                id = imdb_id
            else:
                src = ""
                id = ""
            if src == "": item = None
            else:
                if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))), 
                                    ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.qlickplay,info=playtrailer,id={0})".format(id)), 
                                    ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay", "RunScript(script.qlickplay,info=movieinfo,id={0})".format(id)), 
                                    ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})".format(id))]
                elif xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id))),
                                    ("%s %s" % (_("Movie"), _("Trailer").lower()), "RunScript(script.extendedinfo,info=playtrailer,id={0})".format(id)), (
                                    (_("Extended movie info"),_("Extended movie info"), "RunScript(script.extendedinfo,info=extendedinfo,id={0})".format(id)), 
                                    ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"), "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})".format(id)))]
                else:
                    context_menu = [( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("movies_add_to_library", src=src, id=id)))]
                    context_menu.append(("%s %s (%s)" % ("Related", _("movies"), "Trakt"), "ActivateWindow(10025,{0})".format(plugin.url_for("movies_related", id=id, page=1))))
                    context_menu.append(("{0} {1}...".format(_("Select"), _("Stream").lower()), "PlayMedia({0})".format(plugin.url_for("movies_play", src=src, id=id, mode='select'))))
                    context_menu.append((_("Add to playlist"), "RunPlugin({0})".format(plugin.url_for("lists_add_movie_to_list", src=src, id=id))))
                    context_menu.append((_("Movie information"), 'Action(Info)'))
                if imdb_id != None and imdb_id != "":
                    context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=imdb_id, source="imdb", fanart=get_background_path()))))
                elif tmdb_id != None and tmdb_id != "":
                    context_menu.append(("Show Actors", "ActivateWindow(10025,{0})".format(plugin.url_for("people_list_movie_people", id=tmdb_id, source="tmdb", fanart=get_background_path()))))
            item = make_movie_item(movie_info, True)
        elif item_type == "person":
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            context_menu= []
            try:
                import_tmdb()
                person_images = tmdb.People(person_tmdb_id).images()['profiles']
                person_image = 'https://image.tmdb.org/t/p/w640' + person_images[0]['file_path']
            except: person_image = ''
            person_name = to_utf8(list_item['person']['name'])
            item = ({
                'label': person_name,
                'path': plugin.url_for("trakt_movies_person", person_id=person_id),
                'context_menu': context_menu,
                #'info': season_info,
                'thumbnail': person_image,
                'icon': get_icon_path("movies"),
                'poster': person_image,
                'properties': {'fanart_image': person_image},
            })
        if item is not None:
            items.append(item)
    for item in items:
        item['properties'] = {'fanart_image' : get_background_path()}
    return items
示例#20
0
def _lists_trakt_show_list(list_items):
    genres_dict = trakt.trakt_get_genres("tv")

    if type(list_items) == str:
        import urllib
        list_items = eval(urllib.unquote(list_items))

    items = []
    for list_item in list_items[:25]:
        item = None
        item_type = list_item["type"]

        if item_type == "show":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            show = list_item["show"]
            info = get_tvshow_metadata_trakt(show, genres_dict)

            context_menu = [
                (
                    _("Add to library"),
                    "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                ),
                (
                    _("Show info"), 'Action(Info)'
                ),
                (
                    _("Remove from list"),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_show_from_list", src="tvdb", id=tvdb_id))
                )
            ]

            item = ({
                'label': info['title'],
                'path': plugin.url_for("tv_tvshow", id=tvdb_id),
                'context_menu': context_menu,
                'thumbnail': info['poster'],
                'icon': "DefaultVideo.png",
                'poster': info['poster'],
                'properties' : {'fanart_image' : info['fanart']},
                'info_type': 'video',
                'stream_info': {'video': {}},
                'info': info
            })

        elif item_type == "season":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            season = list_item["season"]
            show = list_item["show"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            season_info = get_season_metadata_trakt(show_info,season, genres_dict)
            label = "{0} - Season {1}".format(show["title"],season["number"])


            context_menu = [
                (
                    _("Add to library"),
                    "RunPlugin({0})".format(plugin.url_for("tv_add_to_library", id=tvdb_id))
                ),
                (
                    _("Show info"), 'Action(Info)'
                ),
                (
                    _("Remove from list"),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb",
                                                           id=tvdb_id, season=list_item["season"]["number"]))
                )
            ]

            item = ({
                'label': label,
                'path': plugin.url_for(tv_season, id=tvdb_id, season_num=list_item["season"]["number"]),
                'context_menu': context_menu,
                'info': season_info,
                'thumbnail': season_info['poster'],
                'icon': "DefaultVideo.png",
                'poster': season_info['poster'],
                'properties': {'fanart_image': season_info['fanart']},
            })

        elif item_type == "episode":
            tvdb_id = list_item["show"]["ids"]["tvdb"]

            episode = list_item["episode"]
            show = list_item["show"]

            season_number = episode["season"]
            episode_number = episode["number"]

            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            episode_info = get_episode_metadata_trakt(show_info, episode)
            label = "{0} - S{1}E{2} - {3}".format(show_info["title"], season_number,
                                                  episode_number, episode_info["title"])

            context_menu = [
                (
                    _("Select stream..."),
                    "PlayMedia({0})".format(
                        plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='select'))
                ),
                (
                    _("Show info"),
                    'Action(Info)'
                ),
                (
                    _("Add to list"),
                    "RunPlugin({0})".format(plugin.url_for("lists_add_episode_to_list", src='tvdb', id=tvdb_id,
                                                           season=season_number, episode=episode_number))
                ),
                (
                    _("Remove from list"),
                    "RunPlugin({0})".format(plugin.url_for("lists_remove_season_from_list", src="tvdb", id=tvdb_id,
                                                           season=season_number, episode = episode_number))
                )
            ]

            item = ({
                'label': label,
                'path': plugin.url_for("tv_play", id=tvdb_id, season=season_number,
                                       episode=episode_number, mode='default'),
                'context_menu': context_menu,
                'info': episode_info,
                'is_playable': True,
                'info_type': 'video',
                'stream_info': {'video': {}},
                'thumbnail': episode_info['poster'],
                'poster': episode_info['poster'],
                'icon': "DefaultVideo.png",
                'properties': {'fanart_image': episode_info['fanart']},
                      })

        elif item_type == "movie":
            movie = list_item["movie"]
            movie_info = get_trakt_movie_metadata(movie)

            item = make_movie_item(movie_info, True)

        if item is not None:
            items.append(item)
    if len(list_items) >= 25:
        items.append({
            'label': _('Next >>'),
            'path': plugin.url_for(_lists_trakt_show_list, list_items=str(list_items[25:]))
        })
    return items
示例#21
0
文件: lists.py 项目: KingPug75/repo
def _lists_trakt_show_list(list_items):
    genres_dict = trakt.trakt_get_genres("tv")
    if type(list_items) == str:
        import urllib
        list_items = eval(urllib.unquote(list_items))
    items = []
    for list_item in list_items:
        item = None
        item_type = list_item["type"]
        if item_type == "show":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            if tvdb_id != "" and tvdb_id != None:
                show = list_item["show"]
                info = get_tvshow_metadata_trakt(show, genres_dict)
                context_menu = [
                    (_("Scan item to library"), "RunPlugin({0})".format(
                        plugin.url_for("tv_add_to_library", id=tvdb_id))),
                    (_("TV show information"), 'Action(Info)'),
                    ("{0}".format(
                        _("Remove from library").replace(
                            _("Library").lower(),
                            _("Playlist").lower())), "RunPlugin({0})".format(
                                plugin.url_for("lists_remove_show_from_list",
                                               src="tvdb",
                                               id=tvdb_id)))
                ]
                if plugin.get_setting(SETTING_TRAKT_LIST_ARTWORK,
                                      bool) == False:
                    item = ({
                        'label': info['title'],
                        'path': plugin.url_for("tv_tvshow", id=tvdb_id),
                        'context_menu': context_menu,
                        'thumbnail': info['poster'],
                        'icon': get_icon_path("tv"),
                        'poster': info['poster'],
                        'properties': {
                            'fanart_image': info['fanart']
                        },
                        'info_type': 'video',
                        'stream_info': {
                            'video': {}
                        },
                        'info': info
                    })
                else:
                    item = make_tvshow_item(info)
            else:
                item = None
        elif item_type == "season":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            season = list_item["season"]
            show = list_item["show"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            season_info = get_season_metadata_trakt(show_info, season,
                                                    genres_dict)
            label = "{0} - Season {1}".format(show["title"], season["number"])
            context_menu = [
                (_("Scan item to library"), "RunPlugin({0})".format(
                    plugin.url_for("tv_add_to_library", id=tvdb_id))),
                ("%s %s" % (_("Season"), _("Information").lower()),
                 'Action(Info)'),
                ("{0}".format(
                    _("Remove from library").replace(
                        _("Library").lower(),
                        _("Playlist").lower())),
                 "RunPlugin({0})".format(
                     plugin.url_for("lists_remove_season_from_list",
                                    src="tvdb",
                                    id=tvdb_id,
                                    season=list_item["season"]["number"])))
            ]
            item = ({
                'label':
                label,
                'path':
                plugin.url_for("tv_season",
                               id=tvdb_id,
                               season_num=list_item["season"]["number"]),
                'context_menu':
                context_menu,
                'info':
                season_info,
                'thumbnail':
                season_info['poster'],
                'icon':
                get_icon_path("tv"),
                'poster':
                season_info['poster'],
                'properties': {
                    'fanart_image': season_info['fanart']
                },
            })
        elif item_type == "episode":
            tvdb_id = list_item["show"]["ids"]["tvdb"]
            episode = list_item["episode"]
            show = list_item["show"]
            season_number = episode["season"]
            episode_number = episode["number"]
            show_info = get_tvshow_metadata_trakt(show, genres_dict)
            episode_info = get_episode_metadata_trakt(show_info, episode)
            label = "{0} - S{1}E{2} - {3}".format(show_info["title"],
                                                  season_number,
                                                  episode_number,
                                                  episode_info["title"])
            context_menu = [
                ("{0} {1}...".format(_("Select"),
                                     _("Stream").lower()),
                 "PlayMedia({0})".format(
                     plugin.url_for("tv_play",
                                    id=tvdb_id,
                                    season=season_number,
                                    episode=episode_number,
                                    mode='select'))),
                ("%s %s" % (_("Episode"), _("Information").lower()),
                 'Action(Info)'),
                (_("Add to playlist"), "RunPlugin({0})".format(
                    plugin.url_for("lists_add_episode_to_list",
                                   src='tvdb',
                                   id=tvdb_id,
                                   season=season_number,
                                   episode=episode_number))),
                ("{0}".format(
                    _("Remove from library").replace(
                        _("Library").lower(),
                        _("Playlist").lower())), "RunPlugin({0})".format(
                            plugin.url_for("lists_remove_season_from_list",
                                           src="tvdb",
                                           id=tvdb_id,
                                           season=season_number,
                                           episode=episode_number)))
            ]
            item = ({
                'label':
                label,
                'path':
                plugin.url_for("tv_play",
                               id=tvdb_id,
                               season=season_number,
                               episode=episode_number,
                               mode='default'),
                'context_menu':
                context_menu,
                'info':
                episode_info,
                'is_playable':
                True,
                'info_type':
                'video',
                'stream_info': {
                    'video': {}
                },
                'thumbnail':
                episode_info['poster'],
                'poster':
                episode_info['poster'],
                'icon':
                get_icon_path("tv"),
                'properties': {
                    'fanart_image': episode_info['fanart']
                },
            })
        elif item_type == "movie":
            movie = list_item["movie"]
            movie_info = get_trakt_movie_metadata(movie)
            try:
                tmdb_id = movie_info['tmdb']
            except:
                tmdb_id = ""
            try:
                imdb_id = movie_info['imdb']
            except:
                imdb_id = ""
            if tmdb_id != None and tmdb_id != "":
                src = "tmdb"
                id = tmdb_id
            elif imdb_id != None and mdb_id != "":
                src = "imdb"
                id = imdb_id
            else:
                src = ""
                id = ""
            if src == "": item = None
            else:
                if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id))),
                        ("%s %s" % (_("Movie"), _("Trailer").lower()),
                         "RunScript(script.qlickplay,info=playtrailer,id={0})".
                         format(id)),
                        ("[COLOR ff0084ff]Q[/COLOR]lick[COLOR ff0084ff]P[/COLOR]lay",
                         "RunScript(script.qlickplay,info=movieinfo,id={0})".
                         format(id)),
                        ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),
                         "ActivateWindow(10025,plugin://script.qlickplay/?info=similarmovies&id={0})"
                         .format(id))
                    ]
                elif xbmc.getCondVisibility(
                        "system.hasaddon(script.extendedinfo)"):
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id))),
                        ("%s %s" % (_("Movie"), _("Trailer").lower()),
                         "RunScript(script.extendedinfo,info=playtrailer,id={0})"
                         .format(id)),
                        ((_("Extended movie info"), _("Extended movie info"),
                          "RunScript(script.extendedinfo,info=extendedinfo,id={0})"
                          .format(id)),
                         ("%s %s (%s)" % ("Recommended", _("movies"), "TMDb"),
                          "ActivateWindow(10025,plugin://script.extendedinfo/?info=similarmovies&id={0})"
                          .format(id)))
                    ]
                else:
                    context_menu = [
                        (_("Scan item to library"), "RunPlugin({0})".format(
                            plugin.url_for("movies_add_to_library",
                                           src=src,
                                           id=id)))
                    ]
                    context_menu.append(
                        ("%s %s (%s)" % ("Related", _("movies"), "Trakt"),
                         "ActivateWindow(10025,{0})".format(
                             plugin.url_for("movies_related", id=id, page=1))))
                    context_menu.append(
                        ("{0} {1}...".format(_("Select"),
                                             _("Stream").lower()),
                         "PlayMedia({0})".format(
                             plugin.url_for("movies_play",
                                            src=src,
                                            id=id,
                                            mode='select'))))
                    context_menu.append(
                        (_("Add to playlist"), "RunPlugin({0})".format(
                            plugin.url_for("lists_add_movie_to_list",
                                           src=src,
                                           id=id))))
                    context_menu.append(
                        (_("Movie information"), 'Action(Info)'))
                if imdb_id != None and imdb_id != "":
                    context_menu.append(
                        ("Show Actors", "ActivateWindow(10025,{0})".format(
                            plugin.url_for("people_list_movie_people",
                                           id=imdb_id,
                                           source="imdb",
                                           fanart=get_background_path()))))
                elif tmdb_id != None and tmdb_id != "":
                    context_menu.append(
                        ("Show Actors", "ActivateWindow(10025,{0})".format(
                            plugin.url_for("people_list_movie_people",
                                           id=tmdb_id,
                                           source="tmdb",
                                           fanart=get_background_path()))))
            item = make_movie_item(movie_info, True)
        elif item_type == "person":
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            context_menu = []
            try:
                import_tmdb()
                person_images = tmdb.People(
                    person_tmdb_id).images()['profiles']
                person_image = 'https://image.tmdb.org/t/p/w640' + person_images[
                    0]['file_path']
            except:
                person_image = ''
            person_name = to_utf8(list_item['person']['name'])
            item = ({
                'label':
                person_name,
                'path':
                plugin.url_for("trakt_movies_person", person_id=person_id),
                'context_menu':
                context_menu,
                #'info': season_info,
                'thumbnail':
                person_image,
                'icon':
                get_icon_path("movies"),
                'poster':
                person_image,
                'properties': {
                    'fanart_image': person_image
                },
            })
        if item is not None:
            items.append(item)
    for item in items:
        item['properties'] = {'fanart_image': get_background_path()}
    return items
示例#22
0
文件: tvshows.py 项目: podgod/podgod
def trakt_get_genres():
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    genres_dict.update(dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("shows")]))
    return genres_dict
示例#23
0
def trakt_movies_recommendations(raw=False):
    from trakt import trakt
    genres_dict = dict([(x['slug'], x['name']) for x in trakt.trakt_get_genres("movies")])
    result = trakt.get_recommendations("movies")
    if raw: return result
    else: return list_trakt_movies_basic(result)