Example #1
0
def createEITtvdb(file_name,
                  title,
                  cover_type='poster',
                  overwrite_jpg=False,
                  overwrite_eit=False,
                  serie=None,
                  episode=None):
    try:
        if not os.path.isdir(file_name):
            f_name = os.path.splitext(file_name)[0]
        else:
            f_name = file_name
        eit_file = f_name + '.eit'
        jpg_file = f_name + '.jpg'
        if os.path.exists(
                jpg_file) and overwrite_jpg == False and os.path.exists(
                    eit_file) and overwrite_eit == False:
            print("Info's already exists, download skipped!")
            return True
        if serie == None and title:
            print('Fetching info for movie: ' + str(title))
            results = tvdb.search(title)
            if len(results) == 0:
                print('No info found for: ' + str(title))
                return False
            searchResult = results[0]
            movie = tvdb.getMovieInfo(searchResult['id'])
            serie = movie['Serie'][0]
        cover_url = serie[cover_type]
        if not cover_url:
            print('No Cover found for', str(title), '\n')
        else:
            downloadCover(cover_url, jpg_file, overwrite_jpg)
        if os.path.exists(eit_file) and overwrite_eit == False:
            print("File '%s' already exists, eit creation skipped!" % eit_file)
            return True
        name = serie['SeriesName']
        overview = serie['Overview']
        print('Series title:', str(name))
        if not name or len(name) == 0:
            print('tvdb search results no valid movie name')
            return False
        if not overview or len(overview) == 0:
            print('tvdb search results no valid movie overview')
            return False
        runtime = serie['Runtime']
        genre = ''
        if serie['Genre']:
            genre = (' ').join(serie['Genre'])
        directors = None
        actors = None
        if serie['Actors']:
            actors = serie['Actors']
        released = None
        if serie['FirstAired']:
            released = serie['FirstAired']
        if episode:
            episode_name = episode['EpisodeName']
            if episode_name:
                name = name + ' - ' + episode_name
            episode_overview = episode['Overview']
            if episode_overview:
                overview = episode_overview
            if episode['FirstAired']:
                released = episode['FirstAired']
            if episode.has_key('Director') and episode['Director']:
                directors = episode['Director']
        ex_info = []
        if released:
            try:
                year = released[0:4]
                ex_info.append(year)
            except Exception as e:
                print(e)

        if runtime:
            try:
                rt = str(int(runtime))
                ex_info.append(rt + ' Min')
            except Exception as e:
                print(e)

        if directors:
            ex_info.append('Von ' + (', ').join(directors))
        if actors:
            ex_info.append('Mit ' + (', ').join(actors))
        extended_info = ('. ').join(ex_info)
        print('Extended info:')
        print('    ', extended_info)
        language_code = getLanguageCode(tvdb)
        return writeEIT(file_name, eit_file, name, overview, genre,
                        extended_info, released, runtime, language_code)
    except:
        printStackTrace()
        return False

    return
def createEITtvdb(file_name,
                  title,
                  serie=None,
                  episode=None,
                  overwrite_eit=False,
                  overwrite_cover=False,
                  overwrite_backdrop=False,
                  cover_type='poster',
                  backdrop_type='fanart'):
    try:
        # DVD directory
        if not os.path.isdir(file_name):
            f_name = os.path.splitext(file_name)[0]
        else:
            f_name = file_name
        eit_file = f_name + ".eit"
        jpg_file = f_name + ".jpg"
        backdrop_file = f_name + ".backdrop.jpg"

        if serie == None and title:
            print "Fetching info for movie: " + str(title)
            results = tvdb.search(title)
            if len(results) == 0:
                print "No info found for: " + str(title)
                return False
            searchResult = results[0]
            movie = tvdb.getMovieInfo(searchResult['id'])
            serie = movie['Serie'][0]

        cover_url = serie[cover_type]
        backdrop_url = serie[backdrop_type]
        downloadCover(cover_url, jpg_file, overwrite_cover)
        downloadCover(backdrop_url, backdrop_file, overwrite_backdrop)

        if os.path.exists(eit_file) and overwrite_eit == False:
            print "File '%s' already exists, eit creation skipped!" % (
                eit_file)
            return True

        name = serie['SeriesName']
        overview = serie['Overview']
        print "Series title:", str(name)
        # Checking valid movie name
        if not name or len(name) == 0:
            print "tvdb search results no valid movie name"
            return False
        # Checking valid movie overview
        if not overview or len(overview) == 0:
            print "tvdb search results no valid movie overview"
            return False

        runtime = serie['Runtime']
        genre = ""
        if serie['Genre']:
            genre = " ".join(serie['Genre'])

        directors = None
        actors = None
        if serie['Actors']:
            actors = serie['Actors']

        released = None
        if serie['FirstAired']:
            released = serie['FirstAired']

        if episode:
            episode_name = episode['EpisodeName']
            if episode_name:
                name = name + " - " + episode_name
            episode_overview = episode['Overview']
            if episode_overview:
                overview = episode_overview
            if episode['FirstAired']:
                released = episode['FirstAired']
            if episode.has_key('Director') and episode['Director']:
                directors = episode['Director']

        ex_info = []
        if released:
            try:
                year = released[0:4]
                ex_info.append(year)
            except Exception, e:
                print e

        if runtime:
            try:
                rt = str(int(runtime))
                ex_info.append(rt + " Min")
            except Exception, e:
                print e
Example #3
0
    testMultiEit()
    tmdb.setLocale('de')
    createEIT('./tmp/Fight Club.ts', 'Fight Club', 'cover', overwrite_eit=True)
    tmdb.setLocale('ru')
    createEIT(
        './tmp/Blitz_ru.ts',
        '\xd0\xa7\xd0\xb5\xd1\x80\xd0\xbd\xd0\xb0\xd1\x8f \xd0\x9c\xd0\xbe\xd0\xbb\xd0\xbd\xd0\xb8\xd1\x8f',
        'cover',
        overwrite_eit=True)
    tmdb.setLocale('de')
    printEIT('./tmp/Blitz_ru.eit')
    printEIT('./tmp/russia.eit')
    printEIT('./tmp/Shutter Island ru Original.eit')
    printEIT('./tmp/Shutter Island ru tmdb.eit')
    printEIT('./tmp/22 Bullets.eit')
    results = tvdb.search('Law & Order')
    for searchResult in results:
        movie = tvdb.getMovieInfo(searchResult['id'])
        serie = movie['Serie'][0]
        episode = tvdb.searchEpisode(movie['Episode'], 'Die Wunderdoktorin')
        if episode:
            createEITtvdb('./tmp/Law & Order.ts',
                          None,
                          overwrite_eit=True,
                          serie=serie,
                          episode=episode)

    supported = ['ts', 'iso', 'mkv']
    dirList = os.listdir(path)
    printEIT('./tmp/22 Bullets.eit')
    createEIT('./tmp/22 Bullets.ts', '22 Bullets', 'cover', overwrite_eit=True)
    overwrite.backdrop = True
    writeEITex("/tmp/2012_test.ts", movie, overwrite)

    tmdb.setLocale('de')
    eitFromTMDb("/tmp/Fight Club.ts", "Fight Club", overwrite)
    tmdb.setLocale('ru')
    eitFromTMDb("/tmp/Blitz_ru.ts", "Черная Молния", overwrite)
    tmdb.setLocale('de')
    printEIT("/tmp/Blitz_ru.eit")
    printEIT("/tmp/russia.eit")
    printEIT("/tmp/Shutter Island ru Original.eit")
    printEIT("/tmp/Shutter Island ru tmdb.eit")

    printEIT("/tmp/22 Bullets.eit")

    results = tvdb.search("Law & Order")
    #results = search("The Mentalist")
    for searchResult in results:
        movie = tvdb.getMovieInfo(searchResult['id'])
        serie = movie['Serie'][0]
        episode = tvdb.searchEpisode(movie['Episode'], "Die Wunderdoktorin")
        if episode:
            createEITtvdb("/tmp/Law & Order.ts",
                          None,
                          overwrite_eit=True,
                          serie=serie,
                          episode=episode)

    path = "/tmp/"
    supported = ["ts", "iso", "mkv"]
    dirList = os.listdir(path)