diff --git a/youtube/watch.py b/youtube/watch.py index cfe827b..ea9ef4c 100644 --- a/youtube/watch.py +++ b/youtube/watch.py @@ -351,20 +351,33 @@ def get_watch_page(query_string): if len(music_list) == 0: music_list_html = '' else: + # get the set of attributes which are used by atleast 1 track + # so there isn't an empty, extraneous album column which no tracks use, for example + used_attributes = set() + for track in music_list: + used_attributes = used_attributes | track.keys() + + # now put them in the right order + ordered_attributes = [] + for attribute in ('Artist', 'Title', 'Album'): + if attribute.lower() in used_attributes: + ordered_attributes.append(attribute) + music_list_html = '''
Artist | -Title | -Album | -" + attribute + " | \n" + music_list_html += '''\n''' + for track in music_list: music_list_html += '''
---|---|---|
''' else: |