29 lines
797 B
Python
29 lines
797 B
Python
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://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
|