Exemple #1
0
 def _get_ep_name(self):
     ep_name = None
     if self.vid_type == 'episode':
         ep_name = self.meta.get('ep_name')
         try:
             ep_name = to_utf8(safe_string(remove_accents(ep_name)))
         except:
             ep_name = to_utf8(safe_string(ep_name))
     return ep_name
Exemple #2
0
 def cast(self):
     key = 'cast'
     if self._action(key) in ('clear', None): return
     from apis.tmdb_api import get_tmdb
     from caches.main_cache import cache_object
     result = None
     actor_id = None
     search_name = None
     search_name = kodi_utils.dialog.input(self.heading_base % ls(32664))
     if not search_name: return
     string = '%s_%s' % ('tmdb_movies_people_search_actor_data',
                         search_name)
     url = 'https://api.themoviedb.org/3/search/person?api_key=%s&language=en-US&query=%s' % (
         self.tmdb_api, search_name)
     result = cache_object(get_tmdb, string, url, 4)
     result = result['results']
     if not result: return
     actor_list = []
     append = actor_list.append
     if len(result) > 1:
         for item in result:
             name = item['name']
             known_for_list = [
                 i.get('title', 'NA') for i in item['known_for']
             ]
             known_for_list = [i for i in known_for_list if not i == 'NA']
             known_for = ', '.join(known_for_list) if known_for_list else ''
             if item.get('profile_path'):
                 icon = 'https://image.tmdb.org/t/p/h632/%s' % item[
                     'profile_path']
             else:
                 icon = kodi_utils.translate_path(
                     'special://home/addons/script.tikiart/resources/media/genre_family.png'
                 )
             append({
                 'line1': name,
                 'line2': known_for,
                 'icon': icon,
                 'name': name,
                 'id': item['id']
             })
         heading = self.heading_base % ls(32664)
         kwargs = {
             'items': json.dumps(actor_list),
             'heading': heading,
             'enumerate': 'false',
             'multi_choice': 'false',
             'multi_line': 'true'
         }
         choice = kodi_utils.select_dialog(actor_list, **kwargs)
         if choice == None: return self._set_property()
         actor_id = choice['id']
         actor_name = choice['name']
     else:
         actor_id = [item['id'] for item in result][0]
         actor_name = [item['name'] for item in result][0]
     if actor_id:
         values = ('&with_cast=%s' % str(actor_id),
                   to_utf8(safe_string(remove_accents(actor_name))))
         self._process(key, values)
Exemple #3
0
 def getFilename(self):
     if self.final_name: final_name = self.final_name
     elif self.action == 'meta.pack':
         name = self.params_get('pack_files')['filename']
         final_name = os.path.splitext(
             urlparse(name).path)[0].split('/')[-1]
     elif self.action == 'image':
         final_name = self.title
     else:
         name_url = unquote(self.url)
         file_name = clean_title(name_url.split('/')[-1])
         if clean_title(self.title).lower() in file_name.lower():
             final_name = os.path.splitext(
                 urlparse(name_url).path)[0].split('/')[-1]
         else:
             try:
                 final_name = self.name.translate(None,
                                                  r'\/:*?"<>|').strip('.')
             except:
                 final_name = os.path.splitext(
                     urlparse(name_url).path)[0].split('/')[-1]
     self.final_name = to_utf8(safe_string(remove_accents(final_name)))
Exemple #4
0
def build_tvshow_meta(data, fanarttv_data=None):
    data_get = data.get
    image_resolution = data['image_resolution']
    profile_resolution = image_resolution['profile']
    poster_resolution = image_resolution['poster']
    fanart_resolution = image_resolution['fanart']
    cast, studio, all_trailers, country, country_codes = [], [], [], [], []
    writer, mpaa, director, trailer = '', '', '', ''
    tmdb_id = data_get('id', '')
    imdb_id = data['external_ids'].get('imdb_id', '')
    tvdb_id = data['external_ids'].get('tvdb_id', 'None')
    rating = data_get('vote_average', '')
    plot = to_utf8(data_get('overview', ''))
    tagline = to_utf8(data_get('tagline', ''))
    votes = data_get('vote_count', '')
    premiered = data_get('first_air_date', '')
    season_data = data['seasons']
    total_seasons = data['number_of_seasons']
    total_aired_eps = data['number_of_episodes']
    if data_get('poster_path'):
        poster = 'https://image.tmdb.org/t/p/%s%s' % (poster_resolution,
                                                      data['poster_path'])
    else:
        poster = ''
    if data_get('backdrop_path'):
        fanart = 'https://image.tmdb.org/t/p/%s%s' % (fanart_resolution,
                                                      data['backdrop_path'])
    else:
        fanart = ''
    if fanarttv_data:
        fanart_added = True
        poster2, fanart2 = fanarttv_data['fanarttv_poster'], fanarttv_data[
            'fanarttv_fanart']
        banner, clearart, clearlogo = fanarttv_data['banner'], fanarttv_data[
            'clearart'], fanarttv_data['clearlogo']
        landscape, discart = fanarttv_data['landscape'], fanarttv_data[
            'discart']
    else:
        fanart_added = False
        poster2, fanart2, banner, clearart, clearlogo, landscape, discart = '', '', '', '', '', '', ''
    try:
        title = to_utf8(safe_string(remove_accents(data['name'])))
    except:
        title = to_utf8(safe_string(data['name']))
    try:
        original_title = to_utf8(
            safe_string(remove_accents(data['original_name'])))
    except:
        original_title = to_utf8(safe_string(data['original_name']))
    try:
        english_title = [
            i['data']['name'] for i in data['translations']['translations']
            if i['iso_639_1'] == 'en'
        ][0]
    except:
        english_title = None
    try:
        year = try_parse_int(data['first_air_date'].split('-')[0])
    except:
        year = ''
    try:
        duration = min(data['episode_run_time']) * 60
    except:
        duration = 30 * 60
    rootname = '%s (%s)' % (title, year)
    try:
        genre = ', '.join([i['name'] for i in data['genres']])
    except:
        genre == []
    if data_get('networks'):
        try:
            studio = [i['name'] for i in data['networks']][0]
        except:
            pass
    if 'production_countries' in data:
        production_countries = data['production_countries']
        country = [i['name'] for i in production_countries]
        country_codes = [i['iso_3166_1'] for i in production_countries]
    if 'content_ratings' in data:
        try:
            mpaa = [
                i['rating'] for i in data['content_ratings']['results']
                if i['iso_3166_1'] == 'US'
            ][0]
        except:
            pass
    elif 'release_dates' in data:
        try:
            mpaa = [
                i['release_dates'][0]['certification']
                for i in data['release_dates']['results']
                if i['iso_3166_1'] == 'US'
            ][0]
        except:
            pass
    if 'credits' in data:
        credits = data['credits']
        if 'cast' in credits:
            try:                cast = [{'name': i['name'], 'role': i['character'],
                'thumbnail': 'https://image.tmdb.org/t/p/%s%s' % (profile_resolution, i['profile_path']) if i['profile_path'] else ''}\
              for i in credits['cast']]
            except:
                pass
        if 'crew' in credits:
            try:
                writer = ', '.join([
                    i['name'] for i in credits['crew']
                    if i['job'] in writer_credits
                ])
            except:
                pass
            try:
                director = [
                    i['name'] for i in credits['crew']
                    if i['job'] == 'Director'
                ][0]
            except:
                pass
    if 'alternative_titles' in data:
        alternatives = data['alternative_titles']['results']
        alternative_titles = [
            i['title'] for i in alternatives
            if i['iso_3166_1'] in alt_titles_test
        ]
    if 'videos' in data:
        all_trailers = data['videos']['results']
        try:
            trailer = [
                'plugin://plugin.video.youtube/play/?video_id=%s' % i['key']
                for i in all_trailers
                if i['site'] == 'YouTube' and i['type'] in trailers_test
            ][0]
        except:
            pass
    status = data_get('status', 'N/A')
    ei_type = data_get('type', 'N/A')
    ei_homepage = data_get('homepage', 'N/A')
    if data_get('created_by', False):
        try:
            ei_created_by = ', '.join([i['name'] for i in data['created_by']])
        except:
            ei_created_by = 'N/A'
    else:
        ei_created_by = 'N/A'
    if data_get('next_episode_to_air', False):
        ei_next_episode_to_air = data['next_episode_to_air']
    else:
        ei_next_episode_to_air = None
    if data_get('last_episode_to_air', False):
        ei_last_episode_to_air = data['last_episode_to_air']
        if not status.lower() in finished_show_check:
            total_aired_eps = sum([i['episode_count'] for i in data['seasons'] if i['season_number'] < ei_last_episode_to_air['season_number'] and i['season_number'] != 0]) \
                  + ei_last_episode_to_air['episode_number']
    else:
        ei_last_episode_to_air = None
    extra_info = {
        'status': status,
        'type': ei_type,
        'homepage': ei_homepage,
        'created_by': ei_created_by,
        'next_episode_to_air': ei_next_episode_to_air,
        'last_episode_to_air': ei_last_episode_to_air
    }
    return {
        'tmdb_id': tmdb_id,
        'tvdb_id': tvdb_id,
        'imdb_id': imdb_id,
        'rating': rating,
        'plot': plot,
        'tagline': tagline,
        'votes': votes,
        'premiered': premiered,
        'poster': poster,
        'fanart': fanart,
        'poster2': poster2,
        'fanart2': fanart2,
        'banner': banner,
        'clearart': clearart,
        'clearlogo': clearlogo,
        'landscape': landscape,
        'discart': discart,
        'genre': genre,
        'title': title,
        'original_title': original_title,
        'english_title': english_title,
        'alternative_titles': alternative_titles,
        'year': year,
        'duration': duration,
        'rootname': rootname,
        'imdbnumber': imdb_id,
        'country': country,
        'country_codes': country_codes,
        'mpaa': mpaa,
        'cast': cast,
        'writer': writer,
        'director': director,
        'all_trailers': all_trailers,
        'trailer': trailer,
        'studio': studio,
        'fanart_added': fanart_added,
        'extra_info': extra_info,
        'mediatype': 'tvshow',
        'season_data': season_data,
        'total_seasons': total_seasons,
        'total_aired_eps': total_aired_eps,
        'tvshowtitle': title,
        'status': status
    }
Exemple #5
0
def build_movie_meta(data, fanarttv_data=None):
    data_get = data.get
    image_resolution = data['image_resolution']
    profile_resolution = image_resolution['profile']
    poster_resolution = image_resolution['poster']
    fanart_resolution = image_resolution['fanart']
    cast, studio, all_trailers, country, country_codes = [], [], [], [], []
    writer, mpaa, director, trailer = '', '', '', ''
    tmdb_id = data_get('id', '')
    imdb_id = data_get('imdb_id', '')
    rating = data_get('vote_average', '')
    plot = to_utf8(data_get('overview', ''))
    tagline = to_utf8(data_get('tagline', ''))
    votes = data_get('vote_count', '')
    premiered = data_get('release_date', '')
    if data_get('poster_path'):
        poster = 'https://image.tmdb.org/t/p/%s%s' % (poster_resolution,
                                                      data['poster_path'])
    else:
        poster = ''
    if data_get('backdrop_path'):
        fanart = 'https://image.tmdb.org/t/p/%s%s' % (fanart_resolution,
                                                      data['backdrop_path'])
    else:
        fanart = ''
    if fanarttv_data:
        fanart_added = True
        poster2, fanart2 = fanarttv_data['fanarttv_poster'], fanarttv_data[
            'fanarttv_fanart']
        banner, clearart, clearlogo = fanarttv_data['banner'], fanarttv_data[
            'clearart'], fanarttv_data['clearlogo']
        landscape, discart = fanarttv_data['landscape'], fanarttv_data[
            'discart']
    else:
        fanart_added = False
        poster2, fanart2, banner, clearart, clearlogo, landscape, discart = '', '', '', '', '', '', ''
    try:
        title = to_utf8(safe_string(remove_accents(data['title'])))
    except:
        title = to_utf8(safe_string(data['title']))
    try:
        original_title = to_utf8(
            safe_string(remove_accents(data['original_title'])))
    except:
        original_title = to_utf8(safe_string(data['original_title']))
    try:
        english_title = [
            i['data']['title'] for i in data['translations']['translations']
            if i['iso_639_1'] == 'en'
        ][0]
    except:
        english_title = None
    try:
        year = try_parse_int(data['release_date'].split('-')[0])
    except:
        year = ''
    try:
        duration = int(data_get('runtime', '90') * 60)
    except:
        duration = 90 * 60
    rootname = '%s (%s)' % (title, year)
    try:
        genre = ', '.join([i['name'] for i in data['genres']])
    except:
        genre == []
    if data_get('production_companies'):
        try:
            studio = [i['name'] for i in data['production_companies']][0]
        except:
            pass
    if 'production_countries' in data:
        production_countries = data['production_countries']
        country = [i['name'] for i in production_countries]
        country_codes = [i['iso_3166_1'] for i in production_countries]
    if 'release_dates' in data:
        try:
            mpaa = [
                x['certification'] for i in data['release_dates']['results']
                for x in i['release_dates'] if i['iso_3166_1'] == 'US'
            ][0]
        except:
            pass
    if 'credits' in data:
        credits = data['credits']
        if 'cast' in credits:
            try:                cast = [{'name': i['name'], 'role': i['character'],
                'thumbnail': 'https://image.tmdb.org/t/p/%s%s' % (profile_resolution, i['profile_path']) if i['profile_path'] else ''}\
              for i in credits['cast']]
            except:
                pass
        if 'crew' in credits:
            try:
                writer = ', '.join([
                    i['name'] for i in credits['crew']
                    if i['job'] in writer_credits
                ])
            except:
                pass
            try:
                director = [
                    i['name'] for i in credits['crew']
                    if i['job'] == 'Director'
                ][0]
            except:
                pass
    if 'alternative_titles' in data:
        alternatives = data['alternative_titles']['titles']
        alternative_titles = [
            i['title'] for i in alternatives
            if i['iso_3166_1'] in alt_titles_test
        ]
    if 'videos' in data:
        all_trailers = data['videos']['results']
        try:
            trailer = [
                'plugin://plugin.video.youtube/play/?video_id=%s' % i['key']
                for i in all_trailers
                if i['site'] == 'YouTube' and i['type'] in trailers_test
            ][0]
        except:
            pass
    ei_status = data_get('status', 'N/A')
    ei_homepage = data_get('homepage', 'N/A')
    if data_get('belongs_to_collection', False):
        belongs_to_collection = data['belongs_to_collection']
        ei_collection_name = belongs_to_collection['name']
        ei_collection_id = belongs_to_collection['id']
    else:
        ei_collection_name = None
        ei_collection_id = None
    try:
        ei_budget = '${:,}'.format(data['budget'])
    except:
        ei_budget = '$0'
    try:
        ei_revenue = '${:,}'.format(data['revenue'])
    except:
        ei_revenue = '$0'
    extra_info = {
        'status': ei_status,
        'collection_name': ei_collection_name,
        'collection_id': ei_collection_id,
        'budget': ei_budget,
        'revenue': ei_revenue,
        'homepage': ei_homepage
    }
    return {
        'tmdb_id': tmdb_id,
        'imdb_id': imdb_id,
        'rating': rating,
        'plot': plot,
        'tagline': tagline,
        'votes': votes,
        'premiered': premiered,
        'imdbnumber': imdb_id,
        'poster': poster,
        'fanart': fanart,
        'poster2': poster2,
        'fanart2': fanart2,
        'banner': banner,
        'clearart': clearart,
        'clearlogo': clearlogo,
        'landscape': landscape,
        'discart': discart,
        'genre': genre,
        'title': title,
        'original_title': original_title,
        'english_title': english_title,
        'alternative_titles': alternative_titles,
        'year': year,
        'duration': duration,
        'rootname': rootname,
        'country': country,
        'country_codes': country_codes,
        'mpaa': mpaa,
        'cast': cast,
        'writer': writer,
        'director': director,
        'all_trailers': all_trailers,
        'trailer': trailer,
        'studio': studio,
        'fanart_added': fanart_added,
        'extra_info': extra_info,
        'mediatype': 'movie',
        'tvdb_id': 'None'
    }