Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions audioman/files/restructure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
),
)
Comment on lines -18 to +24
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function FileRestructurer.move refactored with the following changes:


def __create_dir_structure(self):
dir_path = self.struct.folder_struct.human_readable().lower().replace(
Expand Down
6 changes: 2 additions & 4 deletions audioman/fingerprint/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()):
Comment on lines -21 to +22
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_api_key refactored with the following changes:

return match.group().replace("<td>", "").replace("</td>", "")
else:
print("No API Key found", file=sys.stderr)
6 changes: 2 additions & 4 deletions audioman/locator/audio_file_locator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AudioFileLocator.__init__ refactored with the following changes:


def locate_files(self) -> list:
"""
Expand All @@ -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)
Comment on lines -34 to +32
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AudioFileLocator.__get_files_recursive refactored with the following changes:

return [element for element in result if os.path.isfile(element)]

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 18-18 refactored with the following changes:


data = MetadataLookup.lookup(str(id))
metadata = MetadataParser(data, TerminalAlbumChooser(files[0])).parse_metadata()
Expand Down