Compare commits
No commits in common. "3bf2ad38c21b0f0ead083776d5083f39cbfea4b8" and "c73217843bdfc4d261d0885f1eeb8b7b0a8fe29e" have entirely different histories.
3bf2ad38c2
...
c73217843b
|
@ -13,6 +13,7 @@ class Transcoder:
|
|||
|
||||
def transcode(self):
|
||||
transcode_list = []
|
||||
file_whitelist = ['.jpg', '.jpeg', '.png']
|
||||
for artist in self.input_root.iterdir():
|
||||
if artist.is_dir():
|
||||
artist_out = Path(self.output_root) / artist.name
|
||||
|
@ -26,10 +27,11 @@ class Transcoder:
|
|||
album_out.mkdir()
|
||||
done_file = album / 'DONE'
|
||||
open(done_file, 'a').close()
|
||||
self.copy_album_art(album, album_out)
|
||||
for file in album.iterdir():
|
||||
if file.is_file() and file.suffix.lower() == '.flac':
|
||||
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:
|
||||
print(f"Warning, skipping non-dir '{album}' found in artist '{artist.parts[-1]}'")
|
||||
continue
|
||||
|
@ -68,18 +70,3 @@ class Transcoder:
|
|||
except Exception:
|
||||
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']
|
||||
art_file_name = "cover.jpg"
|
||||
|
||||
art_found = False
|
||||
for file in in_dir.iterdir():
|
||||
if file.is_file() and file.suffix.lower() in file_whitelist:
|
||||
if file.name == art_file_name:
|
||||
art_found = True
|
||||
shutil.copy(file, out_dir / file.name)
|
||||
|
||||
if not art_found:
|
||||
print(f"Warning: {art_file_name} not found in {in_dir}")
|
||||
|
|
Loading…
Reference in New Issue
Block a user