+
Re-encode downloads during postprocessing
diff --git a/headphones/config.py b/headphones/config.py
index 181d89406..c781a3be6 100644
--- a/headphones/config.py
+++ b/headphones/config.py
@@ -240,6 +240,7 @@ def __repr__(self):
'QBITTORRENT_PASSWORD': (str, 'QBitTorrent', ''),
'QBITTORRENT_USERNAME': (str, 'QBitTorrent', ''),
'RENAME_FILES': (int, 'General', 0),
+ 'RENAME_SINGLE_DISC_IGNORE': (int, 'General', 0),
'RENAME_UNPROCESSED': (bool_int, 'General', 1),
'RENAME_FROZEN': (bool_int, 'General', 1),
'REPLACE_EXISTING_FOLDERS': (int, 'General', 0),
diff --git a/headphones/metadata.py b/headphones/metadata.py
index 20bdddd4c..55a55dd4a 100644
--- a/headphones/metadata.py
+++ b/headphones/metadata.py
@@ -79,6 +79,7 @@ class Vars:
Metadata $variable names (only ones set explicitly by headphones).
"""
DISC = '$Disc'
+ DISC_TOTAL = '$DiscTotal',
TRACK = '$Track'
TITLE = '$Title'
ARTIST = '$Artist'
@@ -171,7 +172,7 @@ def _lower(s):
return None
-def file_metadata(path, release):
+def file_metadata(path, release, single_disc_ignore=False):
# type: (str,sqlite3.Row)->Tuple[Mapping[str,str],bool]
"""
Prepare metadata dictionary for path substitution, based on file name,
@@ -194,7 +195,13 @@ def file_metadata(path, release):
_row_to_dict(release, res)
date, year = _date_year(release)
- if not f.disc:
+
+ if not f.disctotal or (f.disctotal == 1 and single_disc_ignore):
+ disc_total = ''
+ else:
+ disc_total = '%d' % f.disctotal
+
+ if not f.disc or (f.disctotal == 1 and single_disc_ignore):
disc_number = ''
else:
disc_number = '%d' % f.disc
@@ -226,6 +233,7 @@ def file_metadata(path, release):
album_title = release['AlbumTitle']
override_values = {
Vars.DISC: disc_number,
+ Vars.DISC_TOTAL: disc_total,
Vars.TRACK: track_number,
Vars.TITLE: title,
Vars.ARTIST: artist_name,
diff --git a/headphones/postprocessor.py b/headphones/postprocessor.py
index 8f1468ea8..dc7ac271e 100755
--- a/headphones/postprocessor.py
+++ b/headphones/postprocessor.py
@@ -1085,7 +1085,11 @@ def renameFiles(albumpath, downloaded_track_list, release):
# Until tagging works better I'm going to rely on the already provided metadata
for downloaded_track in downloaded_track_list:
- md, from_metadata = metadata.file_metadata(downloaded_track, release)
+ md, from_metadata = metadata.file_metadata(
+ downloaded_track,
+ release,
+ headphones.CONFIG.RENAME_SINGLE_DISC_IGNORE
+ )
if md is None:
# unable to parse media file, skip file
continue
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 0820d43c4..29817d862 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -1268,6 +1268,7 @@ def config(self):
"cue_split_shntool_path": headphones.CONFIG.CUE_SPLIT_SHNTOOL_PATH,
"move_files": checked(headphones.CONFIG.MOVE_FILES),
"rename_files": checked(headphones.CONFIG.RENAME_FILES),
+ "rename_single_disc_ignore": checked(headphones.CONFIG.RENAME_SINGLE_DISC_IGNORE),
"correct_metadata": checked(headphones.CONFIG.CORRECT_METADATA),
"cleanup_files": checked(headphones.CONFIG.CLEANUP_FILES),
"keep_nfo": checked(headphones.CONFIG.KEEP_NFO),
@@ -1460,8 +1461,8 @@ def configUpdate(self, **kwargs):
"use_waffles", "use_rutracker",
"use_orpheus", "use_redacted", "redacted_use_fltoken", "preferred_bitrate_allow_lossless",
"detect_bitrate", "ignore_clean_releases", "freeze_db", "cue_split", "move_files",
- "rename_files", "correct_metadata", "cleanup_files", "keep_nfo", "add_album_art",
- "embed_album_art", "embed_lyrics",
+ "rename_files", "rename_single_disc_ignore", "correct_metadata", "cleanup_files",
+ "keep_nfo", "add_album_art", "embed_album_art", "embed_lyrics",
"replace_existing_folders", "keep_original_folder", "file_underscores",
"include_extras", "official_releases_only",
"wait_until_release_date", "autowant_upcoming", "autowant_all",