Skip to content

Instantly share code, notes, and snippets.

@grimpy
Last active March 2, 2020 17:14
Show Gist options
  • Save grimpy/3d9f2554f1e9b083c1dd189d33190347 to your computer and use it in GitHub Desktop.
Save grimpy/3d9f2554f1e9b083c1dd189d33190347 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import mpd
def sorter(song):
return (int(song['date']), song['album'], int(song['disc']), int(song['track']))
def main():
client = mpd.MPDClient()
client.connect('127.0.0.1', 6600)
playlist = client.playlistinfo()
playlist.sort(key=sorter)
for idx, song in enumerate(playlist):
client.moveid(song['id'], idx)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment