summaryrefslogtreecommitdiff
path: root/jamos
diff options
context:
space:
mode:
Diffstat (limited to 'jamos')
-rwxr-xr-xjamos26
1 files changed, 18 insertions, 8 deletions
diff --git a/jamos b/jamos
index 309ad6c..4435653 100755
--- a/jamos
+++ b/jamos
@@ -121,19 +121,29 @@ def get_directories():
def move_file(file, metadata):
- p = os.path.join(
+ artist = 'unknownartist'
+ album = 'unknownalbum'
+ title = 'unknownsong'
+
+ if ('artist' in metadata.keys()) and (metadata['artist'] is not None):
+ artist = metadata['artist'].replace(' ', '_').lower()
+
+ if ('album' in metadata.keys()) and (metadata['album'] is not None):
+ album = metadata['album'].replace(' ', '_').lower()
+
+ if ('title' in metadata.keys()) and (metadata['title'] is not None):
+ title = metadata['title'].replace(' ', '_').lower()
+
+ final_directory = os.path.join(
MUSIC_DIRECTORY,
- metadata['artist'].replace(' ', '_').lower(),
- metadata['album'].replace(' ', '_').lower())
+ artist,
+ album)
- Path(p).mkdir(parents=True, exist_ok=True)
+ Path(final_directory).mkdir(parents=True, exist_ok=True)
os.rename(
file,
- os.path.join(
- p,
- metadata['artist'].replace(' ', '_').lower() +
- '_' + metadata['title'].replace(' ', '_').lower() + '.mp3'))
+ os.path.join(final_directory, artist + '_' + title + '.mp3'))
if __name__ == "__main__":