Created
December 12, 2017 20:50
-
-
Save jachin/b9398cc4c0fa8f4eb973a7aeddf0b407 to your computer and use it in GitHub Desktop.
This little script takes a XML iTunes playlist file and makes an reStructuredText list out of the playlist. There's more features to add, but this is a start.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python3 | |
import argparse | |
import plistlib | |
if (__name__ == "__main__"): | |
parser = argparse.ArgumentParser() | |
parser.add_argument("playlist_file") | |
args = parser.parse_args() | |
with open(args.playlist_file, 'rb') as fp: | |
pl = plistlib.load(fp) | |
tracks = pl['Tracks'] | |
albums = [] | |
for item in pl['Playlists'][0]['Playlist Items']: | |
track_id = str(item['Track ID']) | |
track = tracks[track_id] | |
print("#. *{}* - **{}** - `{}`_\n".format( | |
track['Name'], | |
track['Artist'], | |
track['Album']) | |
) | |
if track['Album'] not in albums: | |
albums.append(track['Album']) | |
for album in albums: | |
# TODO Look uplink to the album. | |
print(".. _{}: https://blablabla.com\n".format(album)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment