Copy album art in separate method
This commit is contained in:
parent
c73217843b
commit
4d011c0d5d
|
@ -13,7 +13,6 @@ class Transcoder:
|
||||||
|
|
||||||
def transcode(self):
|
def transcode(self):
|
||||||
transcode_list = []
|
transcode_list = []
|
||||||
file_whitelist = ['.jpg', '.jpeg', '.png']
|
|
||||||
for artist in self.input_root.iterdir():
|
for artist in self.input_root.iterdir():
|
||||||
if artist.is_dir():
|
if artist.is_dir():
|
||||||
artist_out = Path(self.output_root) / artist.name
|
artist_out = Path(self.output_root) / artist.name
|
||||||
|
@ -27,11 +26,10 @@ class Transcoder:
|
||||||
album_out.mkdir()
|
album_out.mkdir()
|
||||||
done_file = album / 'DONE'
|
done_file = album / 'DONE'
|
||||||
open(done_file, 'a').close()
|
open(done_file, 'a').close()
|
||||||
|
self.copy_album_art(album, album_out)
|
||||||
for file in album.iterdir():
|
for file in album.iterdir():
|
||||||
if file.is_file() and file.suffix.lower() == '.flac':
|
if file.is_file() and file.suffix.lower() == '.flac':
|
||||||
transcode_list.append((str(file), str(album_out / f"{file.stem}.{self.extension}")))
|
transcode_list.append((str(file), str(album_out / f"{file.stem}.{self.extension}")))
|
||||||
elif file.is_file() and file.suffix.lower() in file_whitelist:
|
|
||||||
shutil.copy(file, album_out / file.name)
|
|
||||||
else:
|
else:
|
||||||
print(f"Warning, skipping non-dir '{album}' found in artist '{artist.parts[-1]}'")
|
print(f"Warning, skipping non-dir '{album}' found in artist '{artist.parts[-1]}'")
|
||||||
continue
|
continue
|
||||||
|
@ -70,3 +68,11 @@ class Transcoder:
|
||||||
except Exception:
|
except Exception:
|
||||||
return f"ERROR: Transcoding of '{in_track}' failed."
|
return f"ERROR: Transcoding of '{in_track}' failed."
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def copy_album_art(in_dir: Path, out_dir: Path, file_whitelist: list = None):
|
||||||
|
if file_whitelist is None:
|
||||||
|
file_whitelist = ['.jpg', '.jpeg', '.png']
|
||||||
|
|
||||||
|
for file in in_dir.iterdir():
|
||||||
|
if file.is_file() and file.suffix.lower() in file_whitelist:
|
||||||
|
shutil.copy(file, out_dir / file.name)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user