Skip to content

Instantly share code, notes, and snippets.

@pilotmoon
Created October 16, 2016 20:53
Show Gist options
  • Save pilotmoon/a439f5e2ecaf8923e9b4b7cbdc8a5528 to your computer and use it in GitHub Desktop.
Save pilotmoon/a439f5e2ecaf8923e9b4b7cbdc8a5528 to your computer and use it in GitHub Desktop.
Get the url of the latest A State Of Trance mp3 file listed at archive.org
#! /usr/bin/python
import urllib, json
data = json.load(urllib.urlopen('https://archive.org/metadata/asotarchive'))
mp3files=filter(lambda x: x.get('name','').endswith('.mp3'), data.get('files', []))
mp3files.sort(cmp=lambda x,y: cmp(int(x.get('mtime',0)), int(y.get('mtime',0))))
mp3name = mp3files.pop().get('name', '')
mp3url = 'https://' + data.get('d1', '') + data.get('dir', '') + '/' + mp3name
print mp3url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment