Allow for album metadata entries
This commit is contained in:
parent
b4bab99ef9
commit
91c968e9c3
37
badwitch.py
37
badwitch.py
@ -46,6 +46,8 @@ class Library:
|
||||
def validate(self):
|
||||
self.load()
|
||||
for album, albumcontent in self.albums.items():
|
||||
if album == 'meta':
|
||||
continue
|
||||
for song, songcontent in albumcontent.items():
|
||||
for field in ['track', 'artist', 'source']:
|
||||
if field not in songcontent:
|
||||
@ -58,10 +60,19 @@ class Library:
|
||||
else:
|
||||
print('Downloading entire library')
|
||||
for album, albumcontent in self.albums.items():
|
||||
# Try to grab a metadata entry
|
||||
metadata = {}
|
||||
for song, songcontent in albumcontent.items():
|
||||
if song == 'meta':
|
||||
metadata = self.albums['meta']
|
||||
# Skip albums that don't match our criterea
|
||||
if targetalbum is not None and not album == targetalbum:
|
||||
logging.debug('Skipping album ' + album)
|
||||
continue
|
||||
# Just skip metadata (for now)
|
||||
if album == 'meta':
|
||||
logging.debug('Skipping metadata entry for album ' + album)
|
||||
continue
|
||||
# Get albumartist
|
||||
# Sets to Various Artists if multiple
|
||||
albumartist=''
|
||||
@ -165,18 +176,25 @@ class BadWitch:
|
||||
print('\tLoaded existing album')
|
||||
album = lib.albums[in_album]
|
||||
try:
|
||||
# Input metadata
|
||||
if 'meta' not in album:
|
||||
album['meta'] = {}
|
||||
metadata = album['meta']
|
||||
meta_releaseyear = input('\tRelease year: ')
|
||||
if meta_releaseyear is not '': metadata['releaseyear'] = meta_releaseyear
|
||||
# Input songs
|
||||
while True:
|
||||
in_song = input('\t\tSong title: ')
|
||||
in_song = input('\t\t*Song title: ')
|
||||
if auto_artist is not '':
|
||||
in_artist = auto_artist
|
||||
else:
|
||||
in_artist = input('\t\tArtist: ')
|
||||
in_artist = input('\t\t*Artist: ')
|
||||
if auto_track is not -1:
|
||||
in_track = auto_track
|
||||
auto_track += 1
|
||||
else:
|
||||
in_track = input('\t\tTrack number: ')
|
||||
in_source = input('\t\tSource URL: ')
|
||||
in_track = input('\t\t*Track number: ')
|
||||
in_source = input('\t\t*Source URL: ')
|
||||
# Only assign values if we gave them
|
||||
if in_song not in album:
|
||||
album[in_song] = {}
|
||||
@ -187,10 +205,13 @@ class BadWitch:
|
||||
if in_artist is not '': song['artist'] = in_artist
|
||||
if in_source is not '': song['source'] = in_source
|
||||
# Bail if song is bad
|
||||
for field in ['track', 'artist', 'source']:
|
||||
if field not in song:
|
||||
print('\t\tError: Critical field is empty: ' + field)
|
||||
continue
|
||||
if in_song in ['meta']:
|
||||
print('\t\tError: Song title collides with a reserved field: ' + in_song)
|
||||
continue
|
||||
if '' in [in_song, in_track, in_artist, in_source]:
|
||||
print('\t\tError: A critical field was empty')
|
||||
continue
|
||||
album[in_song] = song
|
||||
except KeyboardInterrupt:
|
||||
print('\n\t\tAborting, changes were not saved')
|
||||
except EOFError:
|
||||
|
Loading…
x
Reference in New Issue
Block a user