radiaSVG/get_padma.py

25 lines
698 B
Python
Raw Normal View History

import json
from pyquery import PyQuery as pq
def do():
data = json.loads(open("radia.json").read())
outfile = "padma.json"
ret = {}
for d in data:
# print get_padma_ids(data[d]['link'])
ret[d] = get_padma_ids(data[d]['link'])
f = open(outfile, "w")
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 = []
if link.startswith("http://powertapes.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