Support some tags for ID3 usage, fix list dying on metadata
This commit is contained in:
		
							
								
								
									
										20
									
								
								badwitch.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								badwitch.py
									
									
									
									
									
								
							| @@ -122,6 +122,16 @@ class Library: | |||||||
|                     resultfile.tag.album = album |                     resultfile.tag.album = album | ||||||
|                     resultfile.tag.title = song |                     resultfile.tag.title = song | ||||||
|                     resultfile.tag.track_num = songcontent['track'] |                     resultfile.tag.track_num = songcontent['track'] | ||||||
|  |                     # Add optional album metadata tags | ||||||
|  |                     if 'genre' in metadata: | ||||||
|  |                         resultfile.tag.genre = metadata['genre'] | ||||||
|  |                     if 'publisher' in metadata: | ||||||
|  |                         resultfile.tag.publisher = metadata['publisher'] | ||||||
|  |                     if 'release_date' in metadata: | ||||||
|  |                         resultfile.tag.original_release_date = metadata['release_date'] | ||||||
|  |                     if 'composer' in metadata: | ||||||
|  |                         resultfile.tag.composer = metadata['composer'] | ||||||
|  |                     # Save | ||||||
|                     resultfile.tag.save() |                     resultfile.tag.save() | ||||||
|                 except (KeyboardInterrupt, EOFError): |                 except (KeyboardInterrupt, EOFError): | ||||||
|                     logging.debug('Interrupt received, exiting') |                     logging.debug('Interrupt received, exiting') | ||||||
| @@ -167,7 +177,7 @@ class BadWitch: | |||||||
|             print('Loaded library ' + lib.file) |             print('Loaded library ' + lib.file) | ||||||
|             try: |             try: | ||||||
|                 while True: |                 while True: | ||||||
|                     in_album = input('\tAlbum: ') |                     in_album = input('\t*Album: ') | ||||||
|                     auto_artist = input('\tArtist (leave blank to assign per song): ') |                     auto_artist = input('\tArtist (leave blank to assign per song): ') | ||||||
|                     auto_track = int(input('\tStarting track number (leave blank to assign per song): ') or -1) |                     auto_track = int(input('\tStarting track number (leave blank to assign per song): ') or -1) | ||||||
|                     if in_album not in lib.albums: |                     if in_album not in lib.albums: | ||||||
| @@ -180,8 +190,10 @@ class BadWitch: | |||||||
|                         if 'meta' not in album: |                         if 'meta' not in album: | ||||||
|                             album['meta'] = {} |                             album['meta'] = {} | ||||||
|                         metadata = album['meta'] |                         metadata = album['meta'] | ||||||
|                         meta_releaseyear = input('\tRelease year: ') |                         # Metadata fields sorted in order of popularity... ish | ||||||
|                         if meta_releaseyear is not '': metadata['releaseyear'] = meta_releaseyear |                         for field in ['genre', 'publisher', 'release_date', 'composer']: | ||||||
|  |                             in_value = input('\t' + field + ': ') | ||||||
|  |                             if in_value is not '': metadata[field] = in_value | ||||||
|                         # Input songs |                         # Input songs | ||||||
|                         while True: |                         while True: | ||||||
|                             in_song = input('\t\t*Song title: ') |                             in_song = input('\t\t*Song title: ') | ||||||
| @@ -227,6 +239,8 @@ class BadWitch: | |||||||
|             print('Closing library') |             print('Closing library') | ||||||
|         elif self.args.action == 'list': |         elif self.args.action == 'list': | ||||||
|             for album, albumcontent in lib.albums.items(): |             for album, albumcontent in lib.albums.items(): | ||||||
|  |                 if album == 'meta': | ||||||
|  |                     continue | ||||||
|                 print(album) |                 print(album) | ||||||
|                 for song, songcontent in albumcontent.items(): |                 for song, songcontent in albumcontent.items(): | ||||||
|                     print(str(songcontent['track']) |                     print(str(songcontent['track']) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user