Ejemplo n.º 1
0
def movie_lists():
	items = [
	{
		'label': 'Collection',
		'path': plugin.url_for('lists_trakt_movies_collection'),
		'thumbnail': plugin.get_media_icon('traktcollection'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('lists_trakt_movies_play_random_collection')),
			('Add to library', 'RunPlugin(%s)' % plugin.url_for('lists_trakt_movies_collection_to_library'))]
	},
	{
		'label': 'Watchlist',
		'path': plugin.url_for('trakt_movies_watchlist'),
		'thumbnail': plugin.get_media_icon('traktwatchlist'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
				('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_watchlist'))]
	},
	{
		'label': 'My Lists',
		'path': plugin.url_for('lists_trakt_my_movie_lists'),
		'thumbnail': plugin.get_media_icon('traktmylists'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Liked Lists',
		'path': plugin.url_for('lists_trakt_liked_movie_lists', page=1),
		'thumbnail': plugin.get_media_icon('traktlikedlists'),
		'fanart': plugin.get_addon_fanart()
	}]
	return items
Ejemplo n.º 2
0
def root():
	items = [
	{
		'label': 'Movies',
		'path': plugin.url_for('movies'),
		'thumbnail': plugin.get_media_icon('movies'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'TV Shows',
		'path': plugin.url_for('tv'),
		'thumbnail': plugin.get_media_icon('tv'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'My Trakt',
		'path': plugin.url_for('my_trakt'),
		'thumbnail': plugin.get_media_icon('trakt'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Search...',
		'path': plugin.url_for('search_term'),
		'thumbnail': plugin.get_media_icon('search'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Settings',
		'path': plugin.url_for('open_settings'),
		'thumbnail': plugin.get_media_icon('settings'),
		'fanart': plugin.get_addon_fanart()
	}]
	return items
Ejemplo n.º 3
0
def lists_trakt_liked_tv_lists(page):
    lists, pages = Trakt.get_liked_lists(page)
    items = []
    for list in lists:
        info = list['list']
        name = info['name']
        user = info['user']['username']
        slug = info['ids']['slug']
        items.append({
            'label':
            name,
            'path':
            plugin.url_for('lists_trakt_show_tv_list', user=user, slug=slug),
            'thumbnail':
            plugin.get_media_icon('traktlikedlists'),
            'fanart':
            plugin.get_addon_fanart()
        })
    nextpage = int(page) + 1
    if pages > page:
        items.append({
            'label':
            '%s/%s  [I]Next page[/I]  >>' % (nextpage, pages),
            'path':
            plugin.url_for('lists_trakt_liked_tv_lists', page=int(page) + 1),
            'thumbnail':
            plugin.get_media_icon('item_next'),
            'fanart':
            plugin.get_addon_fanart()
        })
    return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 4
0
def lists_search_for_lists_term(term, page):
    lists, pages = Trakt.search_for_list(term, page)
    items = []
    for list in lists:
        if 'list' in list:
            list_info = list['list']
        else:
            continue
        name = list_info['name']
        user = list_info['username']
        slug = list_info['ids']['slug']
        total = list_info['item_count']
        info = {}
        info['title'] = name
        if 'description' in list_info:
            info['plot'] = list_info['description']
        else:
            info['plot'] = 'No description available'
        if user != None and total != None and total != 0:
            items.append({
                'label':
                '%s - %s (%s)' %
                (text.to_utf8(name), text.to_utf8(user), total),
                'path':
                plugin.url_for('lists_trakt_show_list', user=user, slug=slug),
                'thumbnail':
                plugin.get_media_icon('traktlikedlists'),
                'context_menu':
                [('Play (random)', 'RunPlugin(%s)' % plugin.url_for(
                    'lists_trakt_play_random', user=user, slug=slug))],
                'info':
                info
            })
            for item in items:
                item['properties'] = {
                    'fanart_image': plugin.get_addon_fanart()
                }
    nextpage = int(page) + 1
    if pages > page:
        items.append({
            'label':
            '%s/%s  [I]Next page[/I]  >>' % (nextpage, pages),
            'path':
            plugin.url_for('lists_search_for_lists_term',
                           term=term,
                           page=int(page) + 1),
            'thumbnail':
            plugin.get_media_icon('item_next'),
            'properties': {
                'fanart_image': plugin.get_addon_fanart()
            }
        })
    return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 5
0
def lists():
    items = [{
        'label': 'My Lists',
        'path': plugin.url_for('lists_trakt_my_lists'),
        'thumbnail': plugin.get_media_icon('traktmylists'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Liked Lists',
        'path': plugin.url_for('lists_trakt_liked_lists', page=1),
        'thumbnail': plugin.get_media_icon('traktlikedlists'),
        'fanart': plugin.get_addon_fanart()
    }]
    return items
Ejemplo n.º 6
0
def tv():
    items = [{
        'label': 'Currently Airing (TMDB)',
        'path': plugin.url_for('tmdb_tv_on_the_air', page=1),
        'thumbnail': plugin.get_media_icon('ontheair'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Popular (TMDB)',
        'path': plugin.url_for('tmdb_tv_most_popular', page=1),
        'thumbnail': plugin.get_media_icon('popular'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Most Watched (Trakt)',
        'path': plugin.url_for('trakt_tv_watched', page=1),
        'thumbnail': plugin.get_media_icon('traktwatchlist'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Most Collected (Trakt)',
        'path': plugin.url_for('trakt_tv_collected', page=1),
        'thumbnail': plugin.get_media_icon('traktcollection'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Most Collected Netflix (Trakt)',
        'path': plugin.url_for('trakt_netflix_tv_collected', page=1),
        'thumbnail': plugin.get_media_icon('traktcollection'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Most Popular (Trakt)',
        'path': plugin.url_for('tv_trakt_popular', page=1),
        'thumbnail': plugin.get_media_icon('traktrecommendations'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Trending (Trakt)',
        'path': plugin.url_for('trakt_tv_trending', page=1),
        'thumbnail': plugin.get_media_icon('trending'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label':
        'New Shows (Trakt)',
        'path':
        plugin.url_for('trakt_tv_new_shows'),
        'thumbnail':
        plugin.get_media_icon('traktcalendar'),
        'fanart':
        plugin.get_addon_fanart(),
        'context_menu':
        [('Play (random)',
          'RunPlugin(%s)' % plugin.url_for('trakt_tv_play_random_new_shows'))]
    }, {
        'label': 'Genres',
        'path': plugin.url_for('tmdb_tv_genres'),
        'thumbnail': plugin.get_media_icon('genres'),
        'fanart': plugin.get_addon_fanart()
    }]
    return items
Ejemplo n.º 7
0
def tv_trakt_popular(page, raw=False):
    results, pages = Trakt.get_popular_shows_paginated(page)
    if raw:
        return results
    else:
        genres_dict = dict([(x['slug'], x['name'])
                            for x in Trakt.get_genres('shows')])
        shows = [
            meta_info.get_tvshow_metadata_trakt(item, genres_dict)
            for item in results
        ]
        items = [
            make_tvshow_item(show) for show in shows if show.get('tvdb_id')
        ]
        page = int(page)
        pages = int(pages)
        if pages > 1:
            items.append({
                'label':
                '%s/%s  [I]Next page[/I]  >>' % (page + 1, pages + 1),
                'path':
                plugin.url_for('tv_trakt_popular', page=page + 1),
                'thumbnail':
                plugin.get_media_icon('item_next'),
                'fanart':
                plugin.get_addon_fanart()
            })
        return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 8
0
def list_tvshows(response):
    items = []
    results = response['results']
    for tvdb_show, tmdb_show in executor.execute(tmdb_to_tvdb,
                                                 results,
                                                 workers=10):
        if tvdb_show is not None:
            info = build_tvshow_info(tvdb_show, tmdb_show)
            items.append(make_tvshow_item(info))
    if xbmc.Monitor().abortRequested():
        return
    if 'page' in response:
        page = response['page']
        args = nav_base.caller_args()
        if page < response['total_pages']:
            args['page'] = str(page + 1)
            items.append({
                'label':
                '%s/%s  [I]Next page[/I]  >>' %
                (page + 1, response['total_pages']),
                'path':
                plugin.url_for(nav_base.caller_name(), **args),
                'thumbnail':
                plugin.get_media_icon('item_next'),
                'fanart':
                plugin.get_addon_fanart()
            })
    return items
Ejemplo n.º 9
0
def list_trakt_movies(results, pages=1, page=1):
    genres_dict = dict([(x['slug'], x['name'])
                        for x in Trakt.get_genres('movies')])
    try:
        movies = [
            meta_info.get_trakt_movie_metadata(item['movie'], genres_dict)
            for item in results
        ]
    except KeyError:
        movies = [
            meta_info.get_trakt_movie_metadata(item, 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 = nav_base.caller_args()
        args['page'] = page + 1
        args['confirm'] = 'yes'
        items.append({
            'label': '%s/%s  [I]Next page[/I]  >>' % (page, pages + 1),
            'path': plugin.url_for(nav_base.caller_name(), **args),
            'thumbnail': plugin.get_media_icon('item_next'),
            'fanart': plugin.get_addon_fanart()
        })
    return plugin.finish(items=items, sort_methods=SORTRAKT)
Ejemplo n.º 10
0
def list_tvshows(response):
	items = []
	results = response['results']
	for tvdb_show, tmdb_show in executor.execute(tmdb_to_tvdb, results, workers=10):
		if tvdb_show is not None:
			try:
				info = build_tvshow_info(tvdb_show, tmdb_show)
			except Exception as e:
				xbmc.log('Failed to parse show, tvdbID: {}'.format(tvdb_show.get('id')), xbmc.LOGERROR)
				xbmc.log('Error: {}'.format(e), xbmc.LOGERROR)
				continue
			else:
				items.append(make_tvshow_item(info))
	if xbmc.Monitor().abortRequested():
		return
	if 'page' in response:
		page = response['page']
		args = nav_base.caller_args()
		if page < response['total_pages']:
			args['page'] = str(page + 1)
			items.append(
				{
					'label': '%s/%s  [I]Next page[/I]  >>' % (page + 1, response['total_pages']),
					'path': plugin.url_for(nav_base.caller_name(), **args),
					'thumbnail': plugin.get_media_icon('item_next'),
					'fanart': plugin.get_addon_fanart()
				})
	return items
Ejemplo n.º 11
0
def list_trakt_tvshows(results, pages, page):
    genres_dict = dict([(x['slug'], x['name'])
                        for x in Trakt.get_genres('shows')])
    try:
        shows = [
            meta_info.get_tvshow_metadata_trakt(item['show'], genres_dict)
            for item in results
        ]
    except KeyError:
        shows = [
            meta_info.get_tvshow_metadata_trakt(item, genres_dict)
            for item in results
        ]
    items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')]
    page = int(page)
    pages = int(pages)
    if pages > 1:
        args = nav_base.caller_args()
        args['page'] = page + 1
        args['confirm'] = 'yes'
        items.append({
            'label':
            '%s/%s  [I]Next page[/I]  >>' % (page + 1, pages + 1),
            'path':
            plugin.url_for(nav_base.caller_name(), **args),
            'thumbnail':
            plugin.get_media_icon('item_next'),
            'fanart':
            plugin.get_addon_fanart()
        })
    return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 12
0
def list_tmdb_movies(result):
    genres_dict = nav_base.get_base_genres()
    movies = [
        meta_info.get_movie_metadata(item, genres_dict)
        for item in result['results']
    ]
    items = [make_movie_item(movie) for movie in movies]
    if 'page' in result:
        page = int(result['page'])
        pages = int(result['total_pages'])
        args = nav_base.caller_args()
        if pages > page:
            args['page'] = page + 1
            args['confirm'] = 'yes'
            items.append({
                'label':
                '%s/%s  [I]Next page[/I]  >>' % (page, pages + 1),
                'path':
                plugin.url_for(nav_base.caller_name(), **args),
                'thumbnail':
                plugin.get_media_icon('item_next'),
                'fanart':
                plugin.get_addon_fanart()
            })
    return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 13
0
def my_trakt():
    items = [{
        'label': 'Movies',
        'path': plugin.url_for('movie_lists'),
        'thumbnail': plugin.get_media_icon('movies'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'TV Shows',
        'path': plugin.url_for('tv_lists'),
        'thumbnail': plugin.get_media_icon('tv'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Lists (Movies & TV Shows)',
        'path': plugin.url_for('lists'),
        'thumbnail': plugin.get_media_icon('traktmylists'),
        'fanart': plugin.get_addon_fanart()
    }]
    return items
Ejemplo n.º 14
0
def tmdb_tv_genres():
    genres = nav_base.get_tv_genres()
    items = sorted([{
        'label': name,
        'path': plugin.url_for('tmdb_tv_genre', id=id, page=1),
        'thumbnail': nav_base.get_genre_icon(id),
        'fanart': plugin.get_addon_fanart()
    } for id, name in genres.items()],
                   key=lambda k: k['label'])
    return items
Ejemplo n.º 15
0
def _lists_trakt_show_movie_list(list_items):
    from resources.lib.TheMovieDB import People
    items = []
    for list_item in list_items:
        item = None
        item_type = list_item['type']
        if item_type == 'movie':
            movie = list_item['movie']
            movie_info = meta_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
            item = make_movie_item(movie_info)
        elif item_type == 'person':
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            try:
                person_images = 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 = text.to_utf8(list_item['person']['name'])
            item = ({
                'label':
                person_name,
                'path':
                plugin.url_for('trakt_movies_person', person_id=person_id),
                'thumbnail':
                person_image,
                'poster':
                person_image,
                'fanart':
                plugin.get_addon_fanart()
            })
        if item is not None:
            items.append(item)
    return items
Ejemplo n.º 16
0
def tv():
	items = [
	{
		'label': 'Currently Airing (TMDB)',
		'path': plugin.url_for('tmdb_tv_on_the_air', page=1),
		'thumbnail': plugin.get_media_icon('ontheair'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Popular (TMDB)',
		'path': plugin.url_for('tmdb_tv_most_popular', page=1),
		'thumbnail': plugin.get_media_icon('popular'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Most Watched (Trakt)',
		'path': plugin.url_for('trakt_tv_watched', page=1),
		'thumbnail': plugin.get_media_icon('traktwatchlist'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Most Collected (Trakt)',
		'path': plugin.url_for('trakt_tv_collected', page=1),
		'thumbnail': plugin.get_media_icon('traktcollection'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Most Collected Netflix (Trakt)',
		'path': plugin.url_for('trakt_netflix_tv_collected', page=1),
		'thumbnail': plugin.get_media_icon('traktcollection'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Most Popular (Trakt)',
		'path': plugin.url_for('tv_trakt_popular', page=1),
		'thumbnail': plugin.get_media_icon('traktrecommendations'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Trending (Trakt)',
		'path': plugin.url_for('trakt_tv_trending', page=1),
		'thumbnail': plugin.get_media_icon('trending'),
		'fanart': plugin.get_addon_fanart()
	},
	{
		'label': 'Genres',
		'path': plugin.url_for('tmdb_tv_genres'),
		'thumbnail': plugin.get_media_icon('genres'),
		'fanart': plugin.get_addon_fanart()
	}]
	return items
Ejemplo n.º 17
0
def tmdb_movies_genres():
	genres = nav_base.get_base_genres()
	items = sorted([
		{
			'label': name,
			'path': plugin.url_for('tmdb_movies_genre', id=id, page=1),
			'thumbnail': nav_base.get_genre_icon(id),
			'fanart': plugin.get_addon_fanart(),
			'context_menu': [
				('Play (random)', 'RunPlugin(%s)' % plugin.url_for('tmdb_movies_play_random_genre', id = id))]
		} for id, name in genres.items()], key=lambda k: k['label'])
	return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 18
0
def lists_trakt_my_movie_lists():
	lists = Trakt.get_lists()
	items = []
	for list in lists:
		name = list['name']
		user = list['user']['username']
		slug = list['ids']['slug']
		items.append(
			{
				'label': name,
				'path': plugin.url_for('lists_trakt_show_movie_list', user=user, slug=slug),
				'thumbnail': plugin.get_media_icon('traktmylists'),
				'fanart': plugin.get_addon_fanart()
			})
	return plugin.finish(items=items, sort_methods=SORT)
Ejemplo n.º 19
0
def list_trakt_search_items(results, pages, page):
	movies = [meta_info.get_trakt_movie_metadata(item['movie'], None) for item in results]
	items = [make_movie_item(movie) for movie in movies]
	page = int(page)
	pages = int(pages)
	if pages > 1:
		args = nav_base.caller_args()
		args['page'] = page + 1
		items.append(
			{
				'label': '%s/%s  [I]Next page[/I]  >>' % (page, pages + 1),
				'path': plugin.url_for(nav_base.caller_name(), **args),
				'thumbnail': plugin.get_media_icon('item_next'),
				'fanart': plugin.get_addon_fanart()
			})
	return items
Ejemplo n.º 20
0
def list_trakt_search_items(results, pages, page):
	shows = [meta_info.get_tvshow_metadata_trakt(item['show'], None) for item in results]
	items = [make_tvshow_item(show) for show in shows if show.get('tvdb_id')]
	page = int(page)
	pages = int(pages)
	if pages > 1:
		args = nav_base.caller_args()
		nextpage = page + 1
		args['page'] = page + 1
		items.append(
			{
				'label': '%s/%s  [I]Next page[/I]  >>' % (nextpage, pages),
				'path': plugin.url_for(nav_base.caller_name(), **args),
				'thumbnail': plugin.get_media_icon('item_next'),
				'fanart': plugin.get_addon_fanart()
			})
	return items
Ejemplo n.º 21
0
def tv_lists():
    items = [{
        'label':
        'Collection',
        'path':
        plugin.url_for('lists_trakt_tv_collection'),
        'thumbnail':
        plugin.get_media_icon('traktcollection'),
        'fanart':
        plugin.get_addon_fanart(),
        'context_menu':
        [('Add to library', 'RunPlugin(%s)' %
          plugin.url_for('lists_trakt_tv_collection_to_library'))]
    }, {
        'label': 'Recommendations',
        'path': plugin.url_for('trakt_tv_recommendations'),
        'thumbnail': plugin.get_media_icon('traktrecommendations'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Watchlist',
        'path': plugin.url_for('trakt_tv_watchlist', page=1),
        'thumbnail': plugin.get_media_icon('traktwatchlist'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'My Lists',
        'path': plugin.url_for('lists_trakt_my_tv_lists'),
        'thumbnail': plugin.get_media_icon('traktmylists'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Liked Lists',
        'path': plugin.url_for('lists_trakt_liked_tv_lists', page=1),
        'thumbnail': plugin.get_media_icon('traktlikedlists'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Next Episodes',
        'path': plugin.url_for('trakt_tv_next_episodes'),
        'thumbnail': plugin.get_media_icon('traktnextepisodes'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'Upcoming Episodes',
        'path': plugin.url_for('trakt_tv_upcoming_episodes'),
        'thumbnail': plugin.get_media_icon('traktcalendar'),
        'fanart': plugin.get_addon_fanart()
    }]
    return items
Ejemplo n.º 22
0
def search(term):
    items = [{
        'label':
        'Movies (TMDB) search - ' + term,
        'path':
        plugin.url_for('tmdb_movies_search_term', term=term, page=1),
        'thumbnail':
        plugin.get_media_icon('search'),
        'fanart':
        plugin.get_addon_fanart()
    }, {
        'label':
        'Movies (Trakt) search - ' + term,
        'path':
        plugin.url_for('trakt_movies_search_term', term=term, page=1),
        'thumbnail':
        plugin.get_media_icon('search'),
        'fanart':
        plugin.get_addon_fanart()
    }, {
        'label': 'TV shows (TVDB) search - ' + term,
        'path': plugin.url_for('tvdb_tv_search_term', term=term, page=1),
        'thumbnail': plugin.get_media_icon('search'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label': 'TV shows (Trakt) search - ' + term,
        'path': plugin.url_for('trakt_tv_search_term', term=term, page=1),
        'thumbnail': plugin.get_media_icon('search'),
        'fanart': plugin.get_addon_fanart()
    }, {
        'label':
        'Lists (Trakt) search - ' + term,
        'path':
        plugin.url_for('lists_search_for_lists_term', term=term, page=1),
        'thumbnail':
        plugin.get_media_icon('search'),
        'fanart':
        plugin.get_addon_fanart(),
    }, {
        'label': 'Edit search string',
        'path': plugin.url_for('search_edit', term=term),
        'thumbnail': plugin.get_media_icon('search'),
        'fanart': plugin.get_addon_fanart()
    }]
    return items
Ejemplo n.º 23
0
def _lists_trakt_show_list(list_items):
    from resources.lib.TheMovieDB import People
    #genres_dict = Trakt.get_genres('tv')
    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 = meta_info.get_tvshow_metadata_trakt(show)
                item = nav_tvshows.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 = meta_info.get_tvshow_metadata_trakt(show)
            season_info = meta_info.get_season_metadata_trakt(
                show_info, season)
            label = '%s - Season %s' % (show['title'], season['number'])
            item = ({
                'label':
                label,
                'path':
                plugin.url_for('tv_season',
                               id=tvdb_id,
                               season_num=list_item['season']['number']),
                'info':
                season_info,
                'thumbnail':
                season_info['poster'],
                '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 = meta_info.get_tvshow_metadata_trakt(show)
            episode_info = meta_info.get_episode_metadata_trakt(
                show_info, episode)
            label = '%s - S%sE%s - %s' % (show_info['title'], season_number,
                                          episode_number,
                                          episode_info['title'])
            item = ({
                'label':
                label,
                'path':
                plugin.url_for('tv_play',
                               id=tvdb_id,
                               season=season_number,
                               episode=episode_number),
                'info':
                episode_info,
                'is_playable':
                True,
                'info_type':
                'video',
                'stream_info': {
                    'video': {}
                },
                'thumbnail':
                episode_info['poster'],
                'poster':
                episode_info['poster'],
                'properties': {
                    'fanart_image': episode_info['fanart']
                }
            })
        elif item_type == 'movie':
            movie = list_item['movie']
            movie_info = meta_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
            item = nav_movies.make_movie_item(movie_info)
        elif item_type == 'person':
            person_id = list_item['person']['ids']['trakt']
            person_tmdb_id = list_item['person']['ids']['tmdb']
            try:
                person_images = 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 = text.to_utf8(list_item['person']['name'])
            item = ({
                'label':
                person_name,
                'path':
                plugin.url_for('trakt_movies_person', person_id=person_id),
                'thumbnail':
                person_image,
                'poster':
                person_image,
                'properties': {
                    'fanart_image': person_image
                }
            })
        if item is not None:
            items.append(item)
    for item in items:
        item['properties'] = {'fanart_image': plugin.get_addon_fanart()}
    return items
Ejemplo n.º 24
0
def make_tvshow_item(info):
    from resources.lib.TheMovieDB import TV, Find
    try:
        tvdb_id = info['tvdb']
    except:
        tvdb_id = ''
    if tvdb_id == '':
        try:
            tvdb_id = info['tvdb_id']
        except:
            tvdb_id = ''
    try:
        tmdb_id = info['tmdb']
    except:
        tmdb_id = ''
    if tmdb_id == '':
        try:
            tmdb_id = info['id']
        except:
            tmdb_id = ''
    try:
        imdb_id = info['imdb_id']
    except:
        imdb_id = ''
    if imdb_id == '':
        try:
            imdb_id = info['imdb']
        except:
            imdb_id = ''
    if not info['poster']:
        info['poster'] = None
    if not info['fanart']:
        info['fanart'] = None
    if info['poster'] == None or info['poster'] == '':
        if tmdb_id != None and tmdb_id != '':
            show = TV(tmdb_id).info()
            if show['poster_path'] != None and show['poster_path'] != '':
                info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[
                    'poster_path']
            if info['fanart'] == None or info['fanart'] == '':
                if show['backdrop_path'] != None and show[
                        'backdrop_path'] != '':
                    info[
                        'fanart'] = u'https://image.tmdb.org/t/p/original' + show[
                            'backdrop_path']
    if info['poster'] == None or info['poster'] == '':
        if tvdb_id != None and tvdb_id != '':
            show = TVDB.get_show(int(tvdb_id), full=False)
            if show != None:
                if show['seriesname'] != None and show['seriesname'] != '':
                    if show.get('poster', '') != None and show.get(
                            'poster', '') != '':
                        info['poster'] = show.get('poster', '')
                    if info['fanart'] == None or info['fanart'] == '':
                        if show.get('fanart', '') != None and show.get(
                                'fanart', '') != '':
                            info['fanart'] = show.get('fanart', '')
    if info['poster'] == None or info['poster'] == '':
        if imdb_id != None and imdb_id != '':
            preshow = Find(imdb_id).info(external_source='imdb_id')
            proshow = preshow['tv_results']
            if proshow != []:
                show = proshow[0]
            else:
                show = []
            if show != []:
                if show['poster_path'] != None and show['poster_path'] != '':
                    info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[
                        'poster_path']
                if info['fanart'] == None or info['fanart'] == '':
                    if show['backdrop_path'] != None and show[
                            'backdrop_path'] != '':
                        info[
                            'fanart'] = u'https://image.tmdb.org/t/p/original' + show[
                                'backdrop_path']
    if info['fanart'] == None or info['fanart'] == '':
        info['fanart'] = plugin.get_addon_fanart()
    if xbmc.getCondVisibility('system.hasaddon(script.extendedinfo)'):
        context_menu = [
            ('OpenInfo',
             'RunScript(script.extendedinfo,info=extendedtvinfo,tvdb_id=%s)' %
             tvdb_id),
            ('TV trailer',
             'RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id=%s)' %
             tvdb_id),
            ('Add to library',
             'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id))
        ]
    else:
        context_menu = [
            ('Add to library',
             'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id))
        ]
    return {
        'label': text.to_utf8(info['title']),
        'path': plugin.url_for('tv_tvshow', id=tvdb_id),
        'context_menu': context_menu,
        'thumbnail': info['poster'],
        'poster': info['poster'],
        'fanart': info['fanart'],
        'info_type': 'video',
        'stream_info': {
            'video': {}
        },
        'info': info
    }
Ejemplo n.º 25
0
def make_tvshow_item(info):
    from resources.lib.TheMovieDB import TV, Find
    try:
        tvdb_id = info['tvdb']
    except:
        tvdb_id = ''
    if tvdb_id == '':
        try:
            tvdb_id = info['tvdb_id']
        except:
            tvdb_id = ''
    try:
        tmdb_id = info['tmdb']
    except:
        tmdb_id = ''
    if tmdb_id == '':
        try:
            tmdb_id = info['id']
        except:
            tmdb_id = ''
    try:
        imdb_id = info['imdb_id']
    except:
        imdb_id = ''
    if imdb_id == '':
        try:
            imdb_id = info['imdb']
        except:
            imdb_id = ''
    if not info['poster']:
        info['poster'] = None
    if not info['fanart']:
        info['fanart'] = None
    if info['poster'] == None or info['poster'] == '':
        if tmdb_id != None and tmdb_id != '':
            show = TV(tmdb_id).info()
            if show['poster_path'] != None and show['poster_path'] != '':
                info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[
                    'poster_path']
            if info['fanart'] == None or info['fanart'] == '':
                if show['backdrop_path'] != None and show[
                        'backdrop_path'] != '':
                    info[
                        'fanart'] = u'https://image.tmdb.org/t/p/original' + show[
                            'backdrop_path']
    if info['poster'] == None or info['poster'] == '':
        if tvdb_id != None and tvdb_id != '':
            show = TVDB.get_show(int(tvdb_id), full=False)
            if show != None:
                if show['seriesname'] != None and show['seriesname'] != '':
                    if show.get('poster', '') != None and show.get(
                            'poster', '') != '':
                        info['poster'] = show.get('poster', '')
                    if info['fanart'] == None or info['fanart'] == '':
                        if show.get('fanart', '') != None and show.get(
                                'fanart', '') != '':
                            info['fanart'] = show.get('fanart', '')
    if info['poster'] == None or info['poster'] == '':
        if imdb_id != None and imdb_id != '':
            preshow = Find(imdb_id).info(external_source='imdb_id')
            proshow = preshow['tv_results']
            if proshow != []:
                show = proshow[0]
            else:
                show = []
            if show != []:
                if show['poster_path'] != None and show['poster_path'] != '':
                    info['poster'] = u'https://image.tmdb.org/t/p/w500' + show[
                        'poster_path']
                if info['fanart'] == None or info['fanart'] == '':
                    if show['backdrop_path'] != None and show[
                            'backdrop_path'] != '':
                        info[
                            'fanart'] = u'https://image.tmdb.org/t/p/original' + show[
                                'backdrop_path']
    if info['fanart'] == None or info['fanart'] == '':
        info['fanart'] = plugin.get_addon_fanart()
    if xbmc.getCondVisibility('system.hasaddon(script.extendedinfo)'):
        context_menu = [
            ('OpenInfo',
             'RunScript(script.extendedinfo,info=extendedtvinfo,tvdb_id=%s)' %
             tvdb_id),
            ('TV trailer',
             'RunScript(script.extendedinfo,info=playtvtrailer,tvdb_id=%s)' %
             tvdb_id),
            ('Add to library',
             'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id))
        ]
    else:
        context_menu = [
            ('Add to library',
             'RunPlugin(%s)' % plugin.url_for('tv_add_to_library', id=tvdb_id))
        ]
    properties = {}
    try:
        if traktenabled and countenabled:
            if 'trakt_id' in info.keys() and info['trakt_id'] != '':
                id = info['trakt_id']
            else:
                id = Trakt.find_trakt_ids('tvdb', tvdb_id, 'show')['trakt']
            playdata = get_show_play_count(id)
            properties = {
                'TotalSeasons': len(playdata['seasons']),
                'TotalEpisodes': playdata['aired'],
                'WatchedEpisodes': playdata['completed'],
                'UnWatchedEpisodes': playdata['aired'] - playdata['completed']
            }
            if properties['UnWatchedEpisodes'] == 0:
                info.update({'playcount': 1})
    except:
        pass
    showitem = {
        'label': text.to_utf8(info['title']),
        'path': plugin.url_for('tv_tvshow', id=tvdb_id),
        'context_menu': context_menu,
        'thumbnail': info['poster'],
        'poster': info['poster'],
        'fanart': info['fanart'],
        'info_type': 'video',
        'stream_info': {
            'video': {}
        },
        'properties': properties,
        'info': info
    }
    if enablefanart:
        try:
            art = get_fanarttv_art(tvdb_id, query='show')
            art = checkart(art)
            showitem.update(art)
        except:
            pass
    return showitem
Ejemplo n.º 26
0
def movies():
	items = [
	{
		'label': 'Blockbusters (TMDB)',
		'path': plugin.url_for('tmdb_movies_blockbusters', page=1),
		'thumbnail': plugin.get_media_icon('most_voted'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('tmdb_movies_play_random_blockbuster'))]
	},
	{
		'label': 'In theatres (TMDB)',
		'path': plugin.url_for('tmdb_movies_now_playing', page=1),
		'thumbnail': plugin.get_media_icon('intheatres'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('tmdb_movies_play_random_now_playing'))]
	},
	{
		'label': 'Popular (TMDB)',
		'path': plugin.url_for('tmdb_movies_popular', page=1),
		'thumbnail': plugin.get_media_icon('popular'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('tmdb_movies_play_random_popular'))]
	},
	{
		'label': 'Top rated (TMDB)',
		'path': plugin.url_for('tmdb_movies_top_rated', page=1),
		'thumbnail': plugin.get_media_icon('top_rated'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('tmdb_movies_play_random_top_rated'))]
	},
	{
		'label': 'Most watched (Trakt)',
		'path': plugin.url_for('trakt_movies_watched', page=1),
		'thumbnail': plugin.get_media_icon('traktwatchlist'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_watched'))]
	},
	{
		'label': 'Most collected (Trakt)',
		'path': plugin.url_for('trakt_movies_collected', page=1),
		'thumbnail': plugin.get_media_icon('traktcollection'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_collected'))]
	},
	{
		'label': 'Popular (Trakt)',
		'path': plugin.url_for('trakt_movies_popular', page=1),
		'thumbnail': plugin.get_media_icon('traktrecommendations'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_popular'))]
	},
	{
		'label': 'Trending (Trakt)',
		'path': plugin.url_for('trakt_movies_trending', page=1),
		'thumbnail': plugin.get_media_icon('trending'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_trending'))]
	},
	{
		'label': 'Latest releases (Trakt)',
		'path': plugin.url_for('trakt_movies_latest_releases'),
		'thumbnail': plugin.get_media_icon('traktcalendar'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_latest_releases'))]
	},
	{
		'label': 'Top 250 (IMDB)',
		'path': plugin.url_for('trakt_movies_imdb_top_rated', page=1),
		'thumbnail': plugin.get_media_icon('imdb'),
		'fanart': plugin.get_addon_fanart(),
		'context_menu': [
			('Play (random)', 'RunPlugin(%s)' % plugin.url_for('trakt_movies_play_random_imdb_top_rated'))]
	},
	{
		'label': 'Genres',
		'path': plugin.url_for('tmdb_movies_genres'),
		'thumbnail': plugin.get_media_icon('genres'),
		'fanart': plugin.get_addon_fanart()
	}]
	return items