Example #1
0
def download_tv_show_meta(imdb_id, path):
    (data_file, poster_file, fanart_file, poster_missing,
     fanart_missing) = _get_meta_paths(imdb_id, path)
    if not os.path.isfile(data_file) or not os.path.isfile(
            poster_file) or not os.path.isfile(fanart_file):
        info = TheTVDBInfo(imdb_id)
        title = info.SeriesName()
        year = info.FirstAired().split('-')[0]
        genre = info.Genre()
        overview = info.Overview()
        rating = info.Rating()
        votes = info.RatingCount()
        premiered = info.FirstAired()
        mpaa = info.ContentRating()

        content = '%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s' % (
            title, year, genre, overview, rating, votes, premiered, mpaa)
        write_to_file(data_file, content)

        if not os.path.isfile(poster_file) or not os.path.isfile(
                poster_missing):
            if USE_POSTERS:
                if META_QUALITY == 'low':
                    image_base_url = 'http://thetvdb.com/banners/_cache/'
                else:
                    image_base_url = 'http://thetvdb.com/banners/'
                poster_href = info.poster()
                if len(poster_href) > 0:
                    poster = '%s%s' % (image_base_url, poster_href)
                    try:
                        urllib.urlretrieve(poster, poster_file)
                    except:
                        pass
                else:
                    write_to_file(poster_missing, '')

        if not os.path.isfile(fanart_file) or not os.path.isfile(
                fanart_missing):
            if USE_FANART:
                if META_QUALITY == 'low':
                    image_base_url = 'http://thetvdb.com/banners/_cache/'
                else:
                    image_base_url = 'http://thetvdb.com/banners/'
                fanart_href = info.fanart()
                if len(fanart_href) > 0:
                    fanart = '%s%s' % (image_base_url, fanart_href)
                    try:
                        urllib.urlretrieve(fanart, fanart_file)
                    except:
                        pass
                else:
                    write_to_file(fanart_missing, '')