radiaSVG/get_padma.py

29 lines
791 B
Python
Raw Normal View History

import json
from pyquery import PyQuery as pq
def do():
data = json.loads(open("radia.json").read())
outfile = "padmaData.js"
ret = {}
for d in data:
# print get_padma_ids(data[d]['link'])
ret[d] = get_padma_ids(data[d]['link'])
2011-06-26 17:41:23 +00:00
print d
print ret[d]
print "\n\n"
f = open(outfile, "w")
f.write("PADMA = " + json.dumps(ret, indent=2))
# f.write(json.dumps(ret, indent=2))
f.close()
print "generated padma.json from radia.json - currently returns empty if link points to a single video. this should be fixed soon"
def get_padma_ids(link):
ids = []
2012-02-14 09:31:11 +00:00
if link.startswith("http://next.pad.ma/"):
jq = pq(url=link)
elems = jq.find('.iconText')
for e in elems:
id = e.get("id").replace("iconText", "")
ids.append(id)
return ids