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 writeEITex(file_name, movie=MovieDBI(), overwrite=OverwriteSettings()): 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" # check and cancel if all exists if (not overwrite.eit and os.path.exists(eit_file)) and \ (not overwrite.cover and os.path.exists(jpg_file)) and \ (not overwrite.backdrop and os.path.exists(backdrop_file)): print "Cancel all data exists:", str(file_name) return movie.update() name = movie.Title overview = movie.Overview runtime = movie.Runtime genre = " ".join(movie.Genres) directors = movie.Directors writers = movie.Writers producers = movie.Producers actors = movie.Cast released = movie.ReleaseDate countries = movie.CountriesShort # update certificate and meta genre appendShortDescriptionToMeta(file_name, genre) setTmdbCertificationtion(movie, file_name) downloadCover(movie.poster_url, jpg_file, overwrite.cover) downloadCover(movie.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 # Checking valid movie name if not name or len(name) == 0: print "tmdb search results no valid movie name" return False # Checking valid movie overview if not overview or len(overview) == 0: print "tmdb search results no valid movie overview" return False ex_info = [] print countries country = ", ".join(countries) print country country = country.replace("US", "USA").replace("DE", "GER") if released: country += " " + str(released.year) country = country.lstrip() print country ex_info.append(country) print ex_info if runtime: ex_info.append(str.format("{0} Min", runtime)) if len(directors) > 0: ex_info.append("Von " + ", ".join(directors)) elif len(writers) > 0: ex_info.append("Von " + ", ".join(writers)) elif len(producers) > 0: ex_info.append("Von " + ", ".join(producers)) if len(actors) > 0: ex_info.append("Mit " + ", ".join(actors)) extended_info = ". ".join(ex_info) print "Overview:" print " " * 4, overview print "Extended info:" print " " * 4, extended_info language_code = "DEU" if movie.language == "ru": language_code = "rus" return writeEIT(file_name, eit_file, name, overview, genre, extended_info, str(released), runtime, language_code) except: printStackTrace() return False
def createEIT(file_name, title, overwrite_jpg=False, overwrite_eit=False, movie=None): try: if title: title = title.replace('-', ' ').replace('#', '%23') print('Fetching info for movie: ' + str(title)) 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 movie == None: tmdb3 = tmdb.init_tmdb3() results = tmdb3.searchMovie(title) if len(results) == 0: print('No info found for: ' + str(title)) return False searchResult = None for result in results: if result.title == title: searchResult = result break if not searchResult: searchResult = results[0] movie = searchResult name = movie.title overview = movie.overview runtime = movie.runtime genre = [] for x in movie.genres: genre.append(x.name) genre = (' ').join(genre) appendShortDescriptionToMeta(file_name, genre) setTmdbCertificationtion(movie, file_name) 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 name: print('Movie title: ' + name.encode('utf-8', 'ignore')) cover_url = movie.poster_url if cover_url is None: 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 if not name or len(name) == 0: print('tmdb search results no valid movie name') return False if not overview or len(overview) == 0: print('tmdb search results no valid movie overview') return False directors = [x.name for x in movie.crew if x.job == 'Director'] actors = [x.name for x in movie.cast] try: released = movie.releasedate print('Released:') print(' ', str(released)) for cast in movie.cast: print(cast.name) except Exception as e: print(e) else: ex_info = [] if released: try: try: print(movie.countries) countries = [c.code for c in movie.countries] country = (', ').join(countries) + ' ' country = country.replace('US', 'USA').replace('DE', 'GER') except: country = '' year = str(released.year) ex_info.append(country + year) except Exception as e: print(e) else: try: countries = [c.code for c in movie.countries] country = (', ').join(countries) + ' ' country = country.replace('US', 'USA').replace('DE', 'GER') ex_info.append(country) except: pass if runtime: try: rt = str(int(runtime)) ex_info.append(rt + ' Min') except Exception as e: print(e) if len(directors) > 0: ex_info.append('Von ' + (', ').join(directors)) if len(actors) > 0: ex_info.append('Mit ' + (', ').join(actors)) extended_info = ('. ').join(ex_info) print('Overview:') print(' ', overview) print('Extended info:') print(' ', extended_info) language_code = getLanguageCode(tmdb) return writeEIT(file_name, eit_file, name, overview, genre, extended_info, str(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