summaryrefslogtreecommitdiff
path: root/jamos
diff options
context:
space:
mode:
Diffstat (limited to 'jamos')
-rwxr-xr-xjamos34
1 files changed, 29 insertions, 5 deletions
diff --git a/jamos b/jamos
index b3b04c7..9b9c150 100755
--- a/jamos
+++ b/jamos
@@ -108,7 +108,7 @@ def move_file(file, metadata):
album = metadata['album'].replace(' ', '_').lower()
if ('title' in metadata.keys()) and (metadata['title'] is not None):
- title = metadata['title'].replace(' ', '_').lower()
+ title = metadata['title'].replace(' ', '_').replace('/', '').lower()
final_directory = os.path.join(
MUSIC_DIRECTORY,
@@ -125,10 +125,34 @@ def move_file(file, metadata):
def write_metadata_to_song_file(file, metadata):
f = music_tag.load_file(file)
- f['name'] = metadata['title']
- f['artist'] = metadata['artist']
- f['album'] = metadata['album']
- f['year'] = format_youtube_date(metadata['release_date'])
+ artist = 'unknownartist'
+ album = 'unknownalbum'
+ title = 'unknownsong'
+ year = 9999
+
+ if ('artist' in metadata.keys()) and (metadata['artist'] is not None):
+ if len(metadata['artist'].split(',')) > 1:
+ # If there are multiple artists, pick the first one
+ # NOTE: This may break if the artist has a comma in their name
+ artist = metadata['artist'].split(',')[0].replace(' ', '_').lower()
+ else:
+ artist = metadata['artist'].replace(' ', '_').lower()
+
+ artist = artist.replace('&', 'and')
+
+ 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()
+
+ if ('release_date' in metadata.keys()):
+ year = format_youtube_date(metadata['release_date'])
+
+ f['name'] = title
+ f['artist'] = artist
+ f['album'] = album
+ f['year'] = year
f.save()