You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
791 B

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'])
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 = []
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