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