parse archive.org
This commit is contained in:
parent
4316c68c6c
commit
c1d0fc6242
1 changed files with 17 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from .. import cache
|
||||||
|
from ..utils import json
|
||||||
|
|
||||||
def getId(url):
|
def getId(url):
|
||||||
return url.split("/")[-1]
|
return url.split("/")[-1]
|
||||||
|
@ -8,3 +9,18 @@ def getId(url):
|
||||||
def getUrl(id):
|
def getUrl(id):
|
||||||
return "http://www.archive.org/details/%s" % id
|
return "http://www.archive.org/details/%s" % id
|
||||||
|
|
||||||
|
def getData(id):
|
||||||
|
data = {}
|
||||||
|
url = getUrl(id)
|
||||||
|
details = cache.readUrl('%s?output=json' % url)
|
||||||
|
details = json.loads(details)
|
||||||
|
for key in ('title', 'description', 'runtime'):
|
||||||
|
data[key] = details['metadata'][key]
|
||||||
|
if isinstance(data[key], list):
|
||||||
|
data[key] = data[key][0]
|
||||||
|
data['url'] = url
|
||||||
|
data['image'] = 'http://archive.org/download/%s/format=thumbnail' % id
|
||||||
|
data['ogg'] = 'http://archive.org/download/%s/format=Ogg+video' % id
|
||||||
|
data['mp4'] = 'http://archive.org/download/%s/format=512Kb+MPEG4' % id
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue