mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Added option to customize album art name
This commit is contained in:
@@ -371,7 +371,13 @@
|
||||
<input type="checkbox" name="rename_files" value="1" ${config['rename_files']} /><label>Rename files</label>
|
||||
<input type="checkbox" name="correct_metadata" value="1" ${config['correct_metadata']} /><label>Correct metadata</label>
|
||||
<input type="checkbox" name="cleanup_files" value="1" ${config['cleanup_files']} /><label>Delete leftover files <small>(.m3u, .nfo, .sfv, .nzb, etc.)</small></label>
|
||||
<input type="checkbox" name="add_album_art" value="1" ${config['add_album_art']}><label>Add album art as 'folder.jpg' to album folder</label>
|
||||
<input type="checkbox" name="add_album_art" id="add_album_art" value="1" ${config['add_album_art']}><label>Add album art jpeg to album folder</label>
|
||||
<div id="album_art_options">
|
||||
<div class="row">
|
||||
as <input type="text" class="override-float" name="album_art_format" value="${config['album_art_format']}" size="10">.jpg
|
||||
</div>
|
||||
<small>Use $Artist/$artist, $Album/$album, $Year/$year</small>
|
||||
</div>
|
||||
<input type="checkbox" name="embed_album_art" value="1" ${config['embed_album_art']}><label>Embed album art in each file</label>
|
||||
<input type="checkbox" name="embed_lyrics" value="1" ${config['embed_lyrics']}><label>Embed lyrics</label>
|
||||
</div>
|
||||
@@ -886,6 +892,26 @@
|
||||
$("#encoderoptions").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#add_album_art").is(":checked"))
|
||||
{
|
||||
$("#album_art_options").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#album_art_options").hide();
|
||||
}
|
||||
|
||||
$("#add_album_art").click(function(){
|
||||
if ($("#add_album_art").is(":checked"))
|
||||
{
|
||||
$("#album_art_options").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#album_art_options").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#prowl").is(":checked"))
|
||||
{
|
||||
|
||||
@@ -104,6 +104,7 @@ MOVE_FILES = False
|
||||
RENAME_FILES = False
|
||||
CLEANUP_FILES = False
|
||||
ADD_ALBUM_ART = False
|
||||
ALBUM_ART_FORMAT = None
|
||||
EMBED_ALBUM_ART = False
|
||||
EMBED_LYRICS = False
|
||||
DOWNLOAD_DIR = None
|
||||
@@ -274,7 +275,7 @@ def initialize():
|
||||
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, \
|
||||
LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \
|
||||
RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, \
|
||||
ADD_ALBUM_ART, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
|
||||
ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
|
||||
TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \
|
||||
RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \
|
||||
LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
|
||||
@@ -355,6 +356,7 @@ def initialize():
|
||||
FILE_FORMAT = check_setting_str(CFG, 'General', 'file_format', 'Track Artist - Album [Year]- Title')
|
||||
CLEANUP_FILES = bool(check_setting_int(CFG, 'General', 'cleanup_files', 0))
|
||||
ADD_ALBUM_ART = bool(check_setting_int(CFG, 'General', 'add_album_art', 0))
|
||||
ALBUM_ART_FORMAT = check_setting_str(CFG, 'General', 'album_art_format', 'folder')
|
||||
EMBED_ALBUM_ART = bool(check_setting_int(CFG, 'General', 'embed_album_art', 0))
|
||||
EMBED_LYRICS = bool(check_setting_int(CFG, 'General', 'embed_lyrics', 0))
|
||||
DOWNLOAD_DIR = check_setting_str(CFG, 'General', 'download_dir', '')
|
||||
@@ -678,6 +680,7 @@ def config_write():
|
||||
new_config['General']['file_format'] = FILE_FORMAT
|
||||
new_config['General']['cleanup_files'] = int(CLEANUP_FILES)
|
||||
new_config['General']['add_album_art'] = int(ADD_ALBUM_ART)
|
||||
new_config['General']['album_art_format'] = ALBUM_ART_FORMAT
|
||||
new_config['General']['embed_album_art'] = int(EMBED_ALBUM_ART)
|
||||
new_config['General']['embed_lyrics'] = int(EMBED_LYRICS)
|
||||
new_config['General']['download_dir'] = DOWNLOAD_DIR
|
||||
|
||||
@@ -354,7 +354,7 @@ def doPostProcessing(albumid, albumpath, release, tracks, downloaded_track_list,
|
||||
cleanupFiles(albumpath)
|
||||
|
||||
if headphones.ADD_ALBUM_ART and artwork:
|
||||
addAlbumArt(artwork, albumpath)
|
||||
addAlbumArt(artwork, albumpath, release)
|
||||
|
||||
if headphones.CORRECT_METADATA:
|
||||
correctMetadata(albumid, release, downloaded_track_list)
|
||||
@@ -425,11 +425,30 @@ def embedAlbumArt(artwork, downloaded_track_list):
|
||||
f.art = artwork
|
||||
f.save()
|
||||
|
||||
def addAlbumArt(artwork, albumpath):
|
||||
def addAlbumArt(artwork, albumpath, release):
|
||||
logger.info('Adding album art to folder')
|
||||
|
||||
artwork_file_name = os.path.join(albumpath, 'folder.jpg')
|
||||
file = open(artwork_file_name, 'wb')
|
||||
try:
|
||||
year = release['ReleaseDate'][:4]
|
||||
except TypeError:
|
||||
year = ''
|
||||
|
||||
values = { '$Artist': release['ArtistName'],
|
||||
'$Album': release['AlbumTitle'],
|
||||
'$Year': year,
|
||||
'$artist': release['ArtistName'].lower(),
|
||||
'$album': release['AlbumTitle'].lower(),
|
||||
'$year': year
|
||||
}
|
||||
|
||||
album_art_name = helpers.replace_all(headphones.ALBUM_ART_FORMAT.strip(), values).replace('/','_') + ".jpg"
|
||||
|
||||
album_art_name = album_art_name.replace('?','_').replace(':', '_').encode(headphones.SYS_ENCODING, 'replace')
|
||||
|
||||
if album_art_name.startswith('.'):
|
||||
album_art_name = album_art_name.replace(0, '_')
|
||||
|
||||
file = open(os.path.join(albumpath, album_art_name), 'wb')
|
||||
file.write(artwork)
|
||||
file.close()
|
||||
|
||||
|
||||
@@ -624,6 +624,7 @@ class WebInterface(object):
|
||||
"correct_metadata" : checked(headphones.CORRECT_METADATA),
|
||||
"cleanup_files" : checked(headphones.CLEANUP_FILES),
|
||||
"add_album_art" : checked(headphones.ADD_ALBUM_ART),
|
||||
"album_art_format" : headphones.ALBUM_ART_FORMAT,
|
||||
"embed_album_art" : checked(headphones.EMBED_ALBUM_ART),
|
||||
"embed_lyrics" : checked(headphones.EMBED_LYRICS),
|
||||
"dest_dir" : headphones.DESTINATION_DIR,
|
||||
@@ -702,7 +703,7 @@ class WebInterface(object):
|
||||
newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, nzbsrus=0, nzbsrus_uid=None, nzbsrus_apikey=None, nzbx=0, preferred_quality=0, preferred_bitrate=None,
|
||||
detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
|
||||
numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None,
|
||||
rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0,
|
||||
rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0,
|
||||
destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0,
|
||||
remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None,
|
||||
bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0,
|
||||
@@ -773,6 +774,7 @@ class WebInterface(object):
|
||||
headphones.RENAME_FILES = rename_files
|
||||
headphones.CLEANUP_FILES = cleanup_files
|
||||
headphones.ADD_ALBUM_ART = add_album_art
|
||||
headphones.ALBUM_ART_FORMAT = album_art_format
|
||||
headphones.EMBED_ALBUM_ART = embed_album_art
|
||||
headphones.EMBED_LYRICS = embed_lyrics
|
||||
headphones.DESTINATION_DIR = destination_dir
|
||||
|
||||
Reference in New Issue
Block a user