diff --git a/README.md b/README.md index 60726a2d..6a71ea89 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ General MP4 Configuration - `fullpathguess` = True/False - When manually processing a file, enable to guess metadata using the full path versus just the file name. (Files shows placed in a 'Movies' folder will be recognized as movies, not as TV shows for example.) - `tagfile` = True/False - Enable or disable tagging file with appropriate metadata after encoding. - `tag-language` = en - Set your tag language for TMDB/TVDB entries metadata retrieval. Use either 2 or 3 character language codes. - - `download-artwork` = True/False - Enabled downloading and embeddeding of Season or Movie posters and embeddeding of that image into the mp4 as the cover image. + - `download-artwork` = Poster/Thumbnail/False - Enabled downloading and embeddeding of Season or Movie posters and embeddeding of that image into the mp4 as the cover image. For TV shows you may choose between the season artwork or the episode thumbnail by selecting the corresponding option. - `embed-subs` = True/False - Enabled by default. Embeds subtitles in the resulting MP4 file that are found embedded in the source file as well as external SRT/VTT files. Disabling embed-subs will cause the script to extract any subtitles that meet your language criteria into external SRT/VTT files. The script will also attempt to download SRT files if possible and this feature is enabled. - `download-subs` = True/False - When enabled the script will attempt to download subtitles of your specified languages automatically using subliminal and merge them into the final mp4 file. **YOU MUST INSTALL SUBLIMINAL AND ITS DEPENDENCIES FOR THIS TO WORK.** You must run `pip install subliminal` in order for this feature to be enabled. diff --git a/autoProcess.ini.sample b/autoProcess.ini.sample index ca9e5790..71e33cbe 100644 --- a/autoProcess.ini.sample +++ b/autoProcess.ini.sample @@ -42,7 +42,7 @@ fullpathguess = True convert-mp4 = False tagfile = True tag-language = en -download-artwork = True +download-artwork = Poster download-subs = False -subs = True sub-providers = addic7ed,podnapisi,thesubdb,opensubtitles diff --git a/manual.py b/manual.py index 2110ed30..d60c1e64 100755 --- a/manual.py +++ b/manual.py @@ -200,7 +200,7 @@ def processFile(inputfile, tagdata, relativePath=None): if tagmp4 is not None: try: tagmp4.setHD(output['x'], output['y']) - tagmp4.writeTags(output['output'], settings.artwork) + tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail) except Exception as e: print("There was an error tagging the file") print(e) diff --git a/postConversion.py b/postConversion.py index a212a740..e38f9a8b 100755 --- a/postConversion.py +++ b/postConversion.py @@ -43,7 +43,7 @@ log.info("Tagging %s with ID %s season %s episode %s." % (inputfile, tvdb_id, season, episode)) tagmp4 = Tvdb_mp4(tvdb_id, season, episode, original, language=settings.taglanguage) tagmp4.setHD(output['x'], output['y']) - tagmp4.writeTags(output['output'], settings.artwork) + tagmp4.writeTags(output['output'], settings.artwork, settings.thumbnail) #QTFS if settings.relocate_moov: diff --git a/readSettings.py b/readSettings.py index 28ba68bd..6aaa7c0d 100644 --- a/readSettings.py +++ b/readSettings.py @@ -65,7 +65,7 @@ def __init__(self, directory, filename, logger=None): 'fullpathguess': 'True', 'tagfile': 'True', 'tag-language': 'en', - 'download-artwork': 'True', + 'download-artwork': 'poster', 'download-subs': 'False', 'embed-subs': 'True', 'sub-providers': 'addic7ed, podnapisi, thesubdb, opensubtitles', @@ -372,7 +372,20 @@ def __init__(self, directory, filename, logger=None): elif len(self.taglanguage) < 2: log.exception("Unable to set tag language, defaulting to English.") self.taglanguage = 'en' - self.artwork = config.getboolean(section, "download-artwork") # Download and embed artwork + self.artwork = config.get(section, "download-artwork").lower() # Download and embed artwork + if self.artwork == "poster": + self.artwork = True + self.thumbnail = False + elif self.artwork == "thumb" or self.artwork == "thumbnail": + self.artwork = True + self.thumbnail = True + else: + self.thumbnail = False + try: + self.artwork = config.getboolean(section, "download-artwork") + except: + self.artwork = True + self.log.error("Invalid download-artwork value, defaulting to 'poster'.") #Read relevant CouchPotato section information section = "CouchPotato" diff --git a/tmdb_mp4.py b/tmdb_mp4.py index 2377dce8..cf19cd61 100644 --- a/tmdb_mp4.py +++ b/tmdb_mp4.py @@ -54,7 +54,7 @@ def __init__(self, imdbid, tmdbid=False, original=None, language='en', logger=No self.log.exception("Failed to connect to tMDB, trying again in 20 seconds.") time.sleep(20) - def writeTags(self, mp4Path, artwork = True): + def writeTags(self, mp4Path, artwork=True, thumbnail=False): self.log.info("Tagging file: %s." % mp4Path) ext = os.path.splitext(mp4Path)[1][1:] if ext not in valid_output_extensions: diff --git a/tvdb_mp4.py b/tvdb_mp4.py index c436c463..6de2f5ad 100755 --- a/tvdb_mp4.py +++ b/tvdb_mp4.py @@ -54,7 +54,7 @@ def __init__(self, show, season, episode, original=None, language='en', logger=N self.log.exception("Failed to connect to TVDB, trying again in 20 seconds.") time.sleep(20) - def writeTags(self, mp4Path, artwork = True): + def writeTags(self, mp4Path, artwork=True, thumbnail=False): self.log.info("Tagging file: %s." % mp4Path) ext = os.path.splitext(mp4Path)[1][1:] if ext not in valid_output_extensions: @@ -89,7 +89,7 @@ def writeTags(self, mp4Path, artwork = True): video["----:com.apple.iTunes:iTunEXTC"] = self.setRating() # iTunes content rating if artwork: - path = self.getArtwork(mp4Path) + path = self.getArtwork(mp4Path, thumbnail=thumbnail) if path is not None: cover = open(path, 'rb').read() if path.endswith('png'): @@ -185,7 +185,7 @@ def xmlTags(self): output.write(footer) return output.getvalue() - def getArtwork(self, mp4Path, filename='cover'): + def getArtwork(self, mp4Path, filename='cover', thumbnail=False): # Check for local cover.jpg or cover.png artwork in the same directory as the mp4 extensions = valid_poster_extensions poster = None @@ -198,19 +198,22 @@ def getArtwork(self, mp4Path, filename='cover'): break # Pulls down all the poster metadata for the correct season and sorts them into the Poster object if poster is None: - posters = posterCollection() - try: - for bannerid in self.showdata['_banners']['season']['season'].keys(): - if str(self.showdata['_banners']['season']['season'][bannerid]['season']) == str(self.season): - poster = Poster() - poster.ratingcount = int(self.showdata['_banners']['season']['season'][bannerid]['ratingcount']) - if poster.ratingcount > 0: - poster.rating = float(self.showdata['_banners']['season']['season'][bannerid]['rating']) - poster.bannerpath = self.showdata['_banners']['season']['season'][bannerid]['_bannerpath'] - posters.addPoster(poster) - poster = urllib.urlretrieve(posters.topPoster().bannerpath, os.path.join(tempfile.gettempdir(),"poster.jpg"))[0] - except: - poster = None + if thumbnail: + poster = urllib.urlretrieve(self.episodedata['filename'], os.path.join(tempfile.gettempdir(),"poster.jpg"))[0] + else: + posters = posterCollection() + try: + for bannerid in self.showdata['_banners']['season']['season'].keys(): + if str(self.showdata['_banners']['season']['season'][bannerid]['season']) == str(self.season): + poster = Poster() + poster.ratingcount = int(self.showdata['_banners']['season']['season'][bannerid]['ratingcount']) + if poster.ratingcount > 0: + poster.rating = float(self.showdata['_banners']['season']['season'][bannerid]['rating']) + poster.bannerpath = self.showdata['_banners']['season']['season'][bannerid]['_bannerpath'] + posters.addPoster(poster) + poster = urllib.urlretrieve(posters.topPoster().bannerpath, os.path.join(tempfile.gettempdir(),"poster.jpg"))[0] + except: + poster = None return poster