mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-19 18:15:31 +01:00
Merge branch 'develop': Added option to allow lossless nzbs if no good
lossy versions are found, added option to customize album art name
This commit is contained in:
@@ -350,6 +350,10 @@
|
||||
<input type="radio" id="preferred_bitrate" name="preferred_quality" value="2" ${config['pref_qual_2']} />Preferred Bitrate: <input type="text" class="override-float" name="preferred_bitrate" value="${config['pref_bitrate']}" size="3">kbps<br>
|
||||
<div id="preferred_bitrate_options">
|
||||
Reject if <strong>less than</strong> <input type="text" class="override-float" name="preferred_bitrate_low_buffer" value="${config['pref_bitrate_low']}" size="3">% or <strong>more than</strong> <input type="text" class="override-float" name="preferred_bitrate_high_buffer" value="${config['pref_bitrate_high']}" size="3">% of the target size (leave blank for no limit)<br><br>
|
||||
<div class="row checkbox left">
|
||||
<input type="checkbox" name="preferred_bitrate_allow_lossless" value="1" ${config['pref_bitrate_allow_lossless']} />
|
||||
<label>Allow lossless if no good lossy match found</label>
|
||||
</div>
|
||||
<div class="row checkbox left">
|
||||
<input type="checkbox" name="detect_bitrate" value="1" ${config['detect_bitrate']} />
|
||||
<label>Auto-Detect Preferred Bitrate</label>
|
||||
@@ -367,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>
|
||||
@@ -882,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"))
|
||||
{
|
||||
|
||||
@@ -96,6 +96,7 @@ PREFERRED_QUALITY = None
|
||||
PREFERRED_BITRATE = None
|
||||
PREFERRED_BITRATE_HIGH_BUFFER = None
|
||||
PREFERRED_BITRATE_LOW_BUFFER = None
|
||||
PREFERRED_BITRATE_ALLOW_LOSSLESS = False
|
||||
DETECT_BITRATE = False
|
||||
ADD_ARTISTS = False
|
||||
CORRECT_METADATA = False
|
||||
@@ -103,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
|
||||
@@ -273,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, \
|
||||
@@ -284,7 +286,7 @@ def initialize():
|
||||
PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_ONSNATCH, MIRRORLIST, \
|
||||
MIRROR, CUSTOMHOST, CUSTOMPORT, CUSTOMSLEEP, HPUSER, HPPASS, XBMC_ENABLED, XBMC_HOST, XBMC_USERNAME, XBMC_PASSWORD, XBMC_UPDATE, \
|
||||
XBMC_NOTIFY, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, SYNOINDEX_ENABLED, ALBUM_COMPLETION_PCT, PREFERRED_BITRATE_HIGH_BUFFER, \
|
||||
PREFERRED_BITRATE_LOW_BUFFER,CACHE_SIZEMB
|
||||
PREFERRED_BITRATE_LOW_BUFFER, PREFERRED_BITRATE_ALLOW_LOSSLESS, CACHE_SIZEMB
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
@@ -344,6 +346,7 @@ def initialize():
|
||||
PREFERRED_BITRATE = check_setting_str(CFG, 'General', 'preferred_bitrate', '')
|
||||
PREFERRED_BITRATE_HIGH_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_high_buffer', '')
|
||||
PREFERRED_BITRATE_LOW_BUFFER = check_setting_int(CFG, 'General', 'preferred_bitrate_low_buffer', '')
|
||||
PREFERRED_BITRATE_ALLOW_LOSSLESS = bool(check_setting_int(CFG, 'General', 'preferred_bitrate_allow_lossless', 0))
|
||||
DETECT_BITRATE = bool(check_setting_int(CFG, 'General', 'detect_bitrate', 0))
|
||||
ADD_ARTISTS = bool(check_setting_int(CFG, 'General', 'auto_add_artists', 1))
|
||||
CORRECT_METADATA = bool(check_setting_int(CFG, 'General', 'correct_metadata', 0))
|
||||
@@ -353,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', '')
|
||||
@@ -666,6 +670,7 @@ def config_write():
|
||||
new_config['General']['preferred_bitrate'] = PREFERRED_BITRATE
|
||||
new_config['General']['preferred_bitrate_high_buffer'] = PREFERRED_BITRATE_HIGH_BUFFER
|
||||
new_config['General']['preferred_bitrate_low_buffer'] = PREFERRED_BITRATE_LOW_BUFFER
|
||||
new_config['General']['preferred_bitrate_allow_lossless'] = int(PREFERRED_BITRATE_ALLOW_LOSSLESS)
|
||||
new_config['General']['detect_bitrate'] = int(DETECT_BITRATE)
|
||||
new_config['General']['auto_add_artists'] = int(ADD_ARTISTS)
|
||||
new_config['General']['correct_metadata'] = int(CORRECT_METADATA)
|
||||
@@ -675,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()
|
||||
|
||||
@@ -840,11 +859,15 @@ def forcePostProcess():
|
||||
# First try to see if there's a match in the snatched table, then we'll try to parse the foldername
|
||||
# TODO: Iterate through underscores -> spaces, spaces -> dots, underscores -> dots (this might be hit or miss since it assumes
|
||||
# all spaces/underscores came from sab replacing values
|
||||
snatched = myDB.action('SELECT AlbumID, Title, Kind from snatched WHERE FolderName LIKE ?', [folder_basename]).fetchone()
|
||||
snatched = myDB.action('SELECT AlbumID, Title, Kind, Status from snatched WHERE FolderName LIKE ?', [folder_basename]).fetchone()
|
||||
if snatched:
|
||||
logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album' % snatched['Title'])
|
||||
verify(snatched['AlbumID'], folder, snatched['Kind'])
|
||||
continue
|
||||
if headphones.KEEP_TORRENT_FILES and snatched['Kind'] == 'torrent' and snatched['Status'] == 'Processed':
|
||||
logger.info(folder_basename + ' is a torrent folder being preserved for seeding and has already been processed. Skipping.')
|
||||
continue
|
||||
else:
|
||||
logger.info('Found a match in the database: %s. Verifying to make sure it is the correct album' % snatched['Title'])
|
||||
verify(snatched['AlbumID'], folder, snatched['Kind'])
|
||||
continue
|
||||
|
||||
# Try to parse the folder name into a valid format
|
||||
# TODO: Add metadata lookup
|
||||
|
||||
@@ -638,6 +638,10 @@ def searchNZB(albumid=None, new=False, losslessOnly=False):
|
||||
else:
|
||||
logger.info('No more results found for %s' % term)
|
||||
return "none"
|
||||
|
||||
if not len(nzblist):
|
||||
logger.info('No appropriate matches found for %s' % term)
|
||||
return "none"
|
||||
|
||||
logger.info(u"Pre-processing result")
|
||||
|
||||
|
||||
@@ -617,12 +617,14 @@ class WebInterface(object):
|
||||
"pref_bitrate" : headphones.PREFERRED_BITRATE,
|
||||
"pref_bitrate_high" : headphones.PREFERRED_BITRATE_HIGH_BUFFER,
|
||||
"pref_bitrate_low" : headphones.PREFERRED_BITRATE_LOW_BUFFER,
|
||||
"pref_bitrate_allow_lossless" : checked(headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS),
|
||||
"detect_bitrate" : checked(headphones.DETECT_BITRATE),
|
||||
"move_files" : checked(headphones.MOVE_FILES),
|
||||
"rename_files" : checked(headphones.RENAME_FILES),
|
||||
"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,
|
||||
@@ -701,14 +703,14 @@ 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,
|
||||
delete_lossless_files=0, prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None,
|
||||
xbmc_update=0, xbmc_notify=0, nma_enabled=False, nma_apikey=None, nma_priority=0, nma_onsnatch=0, synoindex_enabled=False,
|
||||
pushover_enabled=0, pushover_onsnatch=0, pushover_keys=None, pushover_priority=0, mirror=None, customhost=None, customport=None,
|
||||
customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, cache_sizemb=None, **kwargs):
|
||||
customsleep=None, hpuser=None, hppass=None, preferred_bitrate_high_buffer=None, preferred_bitrate_low_buffer=None, preferred_bitrate_allow_lossless=0, cache_sizemb=None, **kwargs):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
headphones.HTTP_PORT = http_port
|
||||
@@ -765,12 +767,14 @@ class WebInterface(object):
|
||||
headphones.PREFERRED_BITRATE = preferred_bitrate
|
||||
headphones.PREFERRED_BITRATE_HIGH_BUFFER = preferred_bitrate_high_buffer
|
||||
headphones.PREFERRED_BITRATE_LOW_BUFFER = preferred_bitrate_low_buffer
|
||||
headphones.PREFERRED_BITRATE_ALLOW_LOSSLESS = preferred_bitrate_allow_lossless
|
||||
headphones.DETECT_BITRATE = detect_bitrate
|
||||
headphones.MOVE_FILES = move_files
|
||||
headphones.CORRECT_METADATA = correct_metadata
|
||||
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