-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from yuygfgg/develop
fix several bugs
- Loading branch information
Showing
5 changed files
with
70 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import importlib | ||
import os | ||
|
||
from .tag_extracter import TagExtractor | ||
|
||
|
||
class MusicLibraryTagExtractor: | ||
def load_extractors(self): | ||
extractors = {} | ||
for file in os.listdir("music_library/tag_extracter"): | ||
if file.endswith("_extractor.py"): | ||
module_name = file[:-3] | ||
module = importlib.import_module( | ||
f"music_library.tag_extracter.{module_name}" | ||
) | ||
for attr in dir(module): | ||
cls = getattr(module, attr) | ||
if ( | ||
isinstance(cls, type) | ||
and issubclass(cls, TagExtractor) | ||
and cls is not TagExtractor | ||
): | ||
# Extract the extension from the module name | ||
extension = module_name.split("_")[0] | ||
extractors[extension] = cls() | ||
return extractors | ||
|
||
def extract_tags(self, file_path): | ||
extension = os.path.splitext(file_path)[1][1:].lower() | ||
extractor = self.extractors.get(extension) | ||
if extractor: | ||
return extractor.extract(file_path) | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters