Copy album art and log files to output dir
This commit is contained in:
		
							parent
							
								
									a6cdc8d31e
								
							
						
					
					
						commit
						6574182bfe
					
				| 
						 | 
					@ -1,5 +1,6 @@
 | 
				
			||||||
import argparse
 | 
					import argparse
 | 
				
			||||||
import subprocess
 | 
					import subprocess
 | 
				
			||||||
 | 
					import shutil
 | 
				
			||||||
from subprocess import CalledProcessError
 | 
					from subprocess import CalledProcessError
 | 
				
			||||||
from pathlib import Path
 | 
					from pathlib import Path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,6 +43,7 @@ def transcode(transcode_list: list, encoder: Path):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def main(input_dir: Path, output_dir: Path, encoder: Path):
 | 
					def main(input_dir: Path, output_dir: Path, encoder: Path):
 | 
				
			||||||
    transcode_list = []
 | 
					    transcode_list = []
 | 
				
			||||||
 | 
					    file_whitelist = ['.jpg', '.jpeg', '.png', '.log']
 | 
				
			||||||
    for artist in input_dir.iterdir():
 | 
					    for artist in input_dir.iterdir():
 | 
				
			||||||
        if artist.is_dir():
 | 
					        if artist.is_dir():
 | 
				
			||||||
            artist_out = Path(output_dir) / artist.name
 | 
					            artist_out = Path(output_dir) / artist.name
 | 
				
			||||||
| 
						 | 
					@ -57,11 +59,11 @@ def main(input_dir: Path, output_dir: Path, encoder: Path):
 | 
				
			||||||
                            print(f"Skipping '{artist.parts[-1]} / {album.parts[-1]}'")
 | 
					                            print(f"Skipping '{artist.parts[-1]} / {album.parts[-1]}'")
 | 
				
			||||||
                        else:
 | 
					                        else:
 | 
				
			||||||
                            album_out.mkdir()
 | 
					                            album_out.mkdir()
 | 
				
			||||||
                            # todo: copy files not on blacklist
 | 
					 | 
				
			||||||
                            # todo: create blacklist
 | 
					 | 
				
			||||||
                            for track in album.iterdir():
 | 
					                            for track in album.iterdir():
 | 
				
			||||||
                                if track.is_file() and track.suffix.lower() == '.flac':
 | 
					                                if track.is_file() and track.suffix.lower() == '.flac':
 | 
				
			||||||
                                    transcode_list.append((str(track), str(album_out / f"{track.stem}.opus")))
 | 
					                                    transcode_list.append((str(track), str(album_out / f"{track.stem}.opus")))
 | 
				
			||||||
 | 
					                                elif track.is_file() and track.suffix.lower() in file_whitelist:
 | 
				
			||||||
 | 
					                                    shutil.copy(track, album_out / track.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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user