Skip to content

Commit

Permalink
episode thumbnail
Browse files Browse the repository at this point in the history
add the option to use the episode thumbnail instead of the season
artwork
  • Loading branch information
michael committed Aug 29, 2015
1 parent db7125c commit 6062f04
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion autoProcess.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion postConversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 15 additions & 2 deletions readSettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tmdb_mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
35 changes: 19 additions & 16 deletions tvdb_mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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'):
Expand Down Expand Up @@ -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
Expand All @@ -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


Expand Down

0 comments on commit 6062f04

Please sign in to comment.