Switch to python3
This commit is contained in:
parent
531041e89a
commit
9ba4b6a91a
5286 changed files with 677347 additions and 576888 deletions
26
Shared/lib/python3.4/site-packages/ox/web/archive.py
Normal file
26
Shared/lib/python3.4/site-packages/ox/web/archive.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# vi:si:et:sw=4:sts=4:ts=4
|
||||
from .. import cache
|
||||
from ..utils import json
|
||||
|
||||
def get_id(url):
|
||||
return url.split("/")[-1]
|
||||
|
||||
def get_url(id):
|
||||
return "http://www.archive.org/details/%s" % id
|
||||
|
||||
def get_data(id):
|
||||
data = {}
|
||||
url = get_url(id)
|
||||
details = cache.read_url('%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…
Add table
Add a link
Reference in a new issue