diff --git a/audioman/files/restructure.py b/audioman/files/restructure.py index fd49973..6776ce2 100644 --- a/audioman/files/restructure.py +++ b/audioman/files/restructure.py @@ -15,8 +15,13 @@ def __init__(self, root: str, struct: Structure): def move(self, file: str, meta: Metadata): self.meta = meta self.__create_dir_structure() - shutil.move(file, os.path.join( - self.root, self.__create_file_name_structure() + "." + file.split(".")[-1])) + shutil.move( + file, + os.path.join( + self.root, + f"{self.__create_file_name_structure()}." + file.split(".")[-1], + ), + ) def __create_dir_structure(self): dir_path = self.struct.folder_struct.human_readable().lower().replace( diff --git a/audioman/fingerprint/api.py b/audioman/fingerprint/api.py index 3f55255..bdf36a2 100644 --- a/audioman/fingerprint/api.py +++ b/audioman/fingerprint/api.py @@ -18,10 +18,8 @@ def get_api_key() -> str: """ url = 'https://acoustid.org/webservice' html = requests.get(url) - match = re.search(table_pattern, html.text) - if match: - match = re.search(id_section_pattern, match.group()) - if match: + if match := re.search(table_pattern, html.text): + if match := re.search(id_section_pattern, match.group()): return match.group().replace("", "").replace("", "") else: print("No API Key found", file=sys.stderr) diff --git a/audioman/locator/audio_file_locator.py b/audioman/locator/audio_file_locator.py index 327c750..63005ef 100644 --- a/audioman/locator/audio_file_locator.py +++ b/audioman/locator/audio_file_locator.py @@ -8,9 +8,7 @@ class AudioFileLocator: def __init__(self, root_dir: str, *excluded_dirs): self.root = root_dir - self.excluded_items = [] - for i in list(excluded_dirs[0]): - self.excluded_items.append(os.path.abspath(i)) + self.excluded_items = [os.path.abspath(i) for i in list(excluded_dirs[0])] def locate_files(self) -> list: """ @@ -31,7 +29,7 @@ def locate_files(self) -> list: return files def __get_files_recursive(self): - result = glob.glob(self.root + "/**/*.*", recursive=True) + result = glob.glob(f"{self.root}/**/*.*", recursive=True) return [element for element in result if os.path.isfile(element)] @staticmethod diff --git a/test.py b/test.py index d622b55..7271cfe 100644 --- a/test.py +++ b/test.py @@ -15,7 +15,7 @@ identifier = AudioFileIdentifier(files[0]) id = identifier.identify -print('http://musicbrainz.org/recording/%s' % id) +print(f'http://musicbrainz.org/recording/{id}') data = MetadataLookup.lookup(str(id)) metadata = MetadataParser(data, TerminalAlbumChooser(files[0])).parse_metadata()