mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-22 12:49:26 +00:00
Merge branch 'prefer-torrents-bugfixes' into develop
This commit is contained in:
@@ -500,7 +500,12 @@
|
||||
<fieldset>
|
||||
<legend>Post-Processing</legend>
|
||||
<div class="row checkbox left clearfix">
|
||||
<input type="checkbox" name="move_files" value="1" ${config['move_files']} /><label>Move downloads to Destination Folder</label>
|
||||
<input type="checkbox" name="move_files" id="move_files" value="1" ${config['move_files']} /><label>Move downloads to Destination Folder</label>
|
||||
<div id="move_files_options">
|
||||
<div class="row indent">
|
||||
<input type="checkbox" name="replace_existing_folders" value="1" ${config['replace_existing_folders']}><label>Replace existing folders?</label>
|
||||
</div>
|
||||
</div>
|
||||
<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>
|
||||
@@ -1215,6 +1220,26 @@
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#move_files").is(":checked"))
|
||||
{
|
||||
$("#move_files_options").show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#move_files_options").hide();
|
||||
}
|
||||
|
||||
$("#move_files").click(function(){
|
||||
if ($("#move_files").is(":checked"))
|
||||
{
|
||||
$("#move_files_options").slideDown();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#move_files_options").slideUp();
|
||||
}
|
||||
});
|
||||
|
||||
if ($("#growl").is(":checked"))
|
||||
{
|
||||
$("#growloptions").show();
|
||||
|
||||
@@ -393,6 +393,9 @@ form .checkbox small {
|
||||
margin: 0 !important;
|
||||
width: auto;
|
||||
}
|
||||
form .indent input {
|
||||
margin-left: 15px;
|
||||
}
|
||||
ul,
|
||||
ol {
|
||||
margin-left: 2em;
|
||||
|
||||
@@ -115,6 +115,7 @@ ADD_ALBUM_ART = False
|
||||
ALBUM_ART_FORMAT = None
|
||||
EMBED_ALBUM_ART = False
|
||||
EMBED_LYRICS = False
|
||||
REPLACE_EXISTING_FOLDERS = False
|
||||
NZB_DOWNLOADER = None # 0: sabnzbd, 1: nzbget, 2: blackhole
|
||||
TORRENT_DOWNLOADER = None # 0: blackhole, 1: transmission, 2: utorrent
|
||||
DOWNLOAD_DIR = None
|
||||
@@ -441,6 +442,7 @@ def initialize():
|
||||
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))
|
||||
REPLACE_EXISTING_FOLDERS = bool(check_setting_int(CFG, 'General', 'replace_existing_folders', 0))
|
||||
NZB_DOWNLOADER = check_setting_int(CFG, 'General', 'nzb_downloader', 0)
|
||||
TORRENT_DOWNLOADER = check_setting_int(CFG, 'General', 'torrent_downloader', 0)
|
||||
DOWNLOAD_DIR = check_setting_str(CFG, 'General', 'download_dir', '')
|
||||
@@ -849,6 +851,7 @@ def config_write():
|
||||
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']['replace_existing_folders'] = int(REPLACE_EXISTING_FOLDERS)
|
||||
new_config['General']['nzb_downloader'] = NZB_DOWNLOADER
|
||||
new_config['General']['torrent_downloader'] = TORRENT_DOWNLOADER
|
||||
new_config['General']['download_dir'] = DOWNLOAD_DIR
|
||||
|
||||
@@ -608,18 +608,28 @@ def moveFiles(albumpath, release, tracks):
|
||||
if make_lossless_folder:
|
||||
# Only rename the folder if they use the album name, otherwise merge into existing folder
|
||||
if os.path.exists(lossless_destination_path) and 'album' in last_folder.lower():
|
||||
|
||||
temp_folder = folder
|
||||
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossless_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
temp_folder = newfolder
|
||||
break
|
||||
|
||||
create_duplicate_folder = False
|
||||
|
||||
if headphones.REPLACE_EXISTING_FOLDERS:
|
||||
try:
|
||||
shutil.rmtree(lossless_destination_path)
|
||||
except Exception, e:
|
||||
logger.error("Error deleting existing folder: %s. Creating duplicate folder. Error: %s" % (lossless_destination_path.decode(headphones.SYS_ENCODING, 'replace'), str(e)))
|
||||
create_duplicate_folder = True
|
||||
|
||||
if not headphones.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
temp_folder = folder
|
||||
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossless_destination_path = os.path.normpath(os.path.join(headphones.LOSSLESS_DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossless_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
temp_folder = newfolder
|
||||
break
|
||||
|
||||
if not os.path.exists(lossless_destination_path):
|
||||
try:
|
||||
@@ -631,18 +641,28 @@ def moveFiles(albumpath, release, tracks):
|
||||
|
||||
if make_lossy_folder:
|
||||
if os.path.exists(lossy_destination_path) and 'album' in last_folder.lower():
|
||||
|
||||
create_duplicate_folder = False
|
||||
|
||||
if headphones.REPLACE_EXISTING_FOLDERS:
|
||||
try:
|
||||
shutil.rmtree(lossy_destination_path)
|
||||
except Exception, e:
|
||||
logger.error("Error deleting existing folder: %s. Creating duplicate folder. Error: %s" % (lossy_destination_path.decode(headphones.SYS_ENCODING, 'replace'), str(e)))
|
||||
create_duplicate_folder = True
|
||||
|
||||
temp_folder = folder
|
||||
if not headphones.REPLACE_EXISTING_FOLDERS or create_duplicate_folder:
|
||||
temp_folder = folder
|
||||
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossy_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
temp_folder = newfolder
|
||||
break
|
||||
i = 1
|
||||
while True:
|
||||
newfolder = temp_folder + '[%i]' % i
|
||||
lossy_destination_path = os.path.normpath(os.path.join(headphones.DESTINATION_DIR, newfolder)).encode(headphones.SYS_ENCODING, 'replace')
|
||||
if os.path.exists(lossy_destination_path):
|
||||
i += 1
|
||||
else:
|
||||
temp_folder = newfolder
|
||||
break
|
||||
|
||||
if not os.path.exists(lossy_destination_path):
|
||||
try:
|
||||
|
||||
@@ -130,7 +130,7 @@ def searchforalbum(albumid=None, new=False, losslessOnly=False):
|
||||
do_sorted_search(album, new, losslessOnly)
|
||||
|
||||
else:
|
||||
logger.info("Got to zero")
|
||||
|
||||
album = myDB.action('SELECT * from albums WHERE AlbumID=?', [albumid]).fetchone()
|
||||
logger.info('Searching for %s' % album['AlbumTitle'])
|
||||
do_sorted_search(album, new, losslessOnly)
|
||||
@@ -672,27 +672,27 @@ def send_to_downloader(data, bestqual, album):
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
nzb.name = nzb_folder_name
|
||||
nzb.name = folder_name
|
||||
nzbget.sendNZB(nzb)
|
||||
|
||||
elif headphones.NZB_DOWNLOADER == 0:
|
||||
|
||||
nzb = classes.NZBDataSearchResult()
|
||||
nzb.extraInfo.append(data)
|
||||
nzb.name = nzb_folder_name
|
||||
nzb.name = folder_name
|
||||
sab.sendNZB(nzb)
|
||||
|
||||
# If we sent the file to sab, we can check how it was renamed and insert that into the snatched table
|
||||
(replace_spaces, replace_dots) = sab.checkConfig()
|
||||
|
||||
if replace_dots:
|
||||
nzb_folder_name = helpers.sab_replace_dots(nzb_folder_name)
|
||||
folder_name = helpers.sab_replace_dots(folder_name)
|
||||
if replace_spaces:
|
||||
nzb_folder_name = helpers.sab_replace_spaces(nzb_folder_name)
|
||||
folder_name = helpers.sab_replace_spaces(folder_name)
|
||||
|
||||
else:
|
||||
|
||||
nzb_name = nzb_folder_name + '.nzb'
|
||||
nzb_name = folder_name + '.nzb'
|
||||
download_path = os.path.join(headphones.BLACKHOLE_DIR, nzb_name)
|
||||
try:
|
||||
prev = os.umask(headphones.UMASK)
|
||||
|
||||
@@ -939,6 +939,7 @@ class WebInterface(object):
|
||||
"album_art_format" : headphones.ALBUM_ART_FORMAT,
|
||||
"embed_album_art" : checked(headphones.EMBED_ALBUM_ART),
|
||||
"embed_lyrics" : checked(headphones.EMBED_LYRICS),
|
||||
"replace_existing_folders" : checked(headphones.REPLACE_EXISTING_FOLDERS),
|
||||
"dest_dir" : headphones.DESTINATION_DIR,
|
||||
"lossless_dest_dir" : headphones.LOSSLESS_DESTINATION_DIR,
|
||||
"folder_format" : headphones.FOLDER_FORMAT,
|
||||
@@ -1048,7 +1049,7 @@ class WebInterface(object):
|
||||
use_headphones_indexer=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, nzbsrus=0, nzbsrus_uid=None, nzbsrus_apikey=None, omgwtfnzbs=0, omgwtfnzbs_uid=None, omgwtfnzbs_apikey=None,
|
||||
preferred_words=None, required_words=None, ignored_words=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
|
||||
numberofseeders=None, use_piratebay=0, piratebay_proxy_url=None, 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, album_art_format=None, 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, replace_existing_folders=None,
|
||||
destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, file_underscores=0, 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, prefer_torrents=0, 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,
|
||||
@@ -1142,6 +1143,7 @@ class WebInterface(object):
|
||||
headphones.ALBUM_ART_FORMAT = album_art_format
|
||||
headphones.EMBED_ALBUM_ART = embed_album_art
|
||||
headphones.EMBED_LYRICS = embed_lyrics
|
||||
headphones.REPLACE_EXISTING_FOLDERS = replace_existing_folders
|
||||
headphones.DESTINATION_DIR = destination_dir
|
||||
headphones.LOSSLESS_DESTINATION_DIR = lossless_destination_dir
|
||||
headphones.FOLDER_FORMAT = folder_format
|
||||
|
||||
Reference in New Issue
Block a user