add example function to get transcripts for a list
This commit is contained in:
parent
b24387f00b
commit
79fa8402a5
30
utils.py
30
utils.py
|
@ -2,6 +2,7 @@ from settings import username, password, url
|
||||||
import ox
|
import ox
|
||||||
import json
|
import json
|
||||||
import codecs
|
import codecs
|
||||||
|
import urllib2
|
||||||
|
|
||||||
api = ox.api.API(url)
|
api = ox.api.API(url)
|
||||||
user = api.signin({'username': username, 'password': password})
|
user = api.signin({'username': username, 'password': password})
|
||||||
|
@ -197,7 +198,34 @@ def dumpKnownPlaces():
|
||||||
|
|
||||||
#def replaceAnnotation(track, old, new):
|
#def replaceAnnotation(track, old, new):
|
||||||
|
|
||||||
|
def getTranscriptsForList(listId='sanj:spaces of theatre'):
|
||||||
|
result = api.find({
|
||||||
|
'sort': [{
|
||||||
|
'key': 'title',
|
||||||
|
'operator': '+'
|
||||||
|
}],
|
||||||
|
'query': {
|
||||||
|
'conditions': [
|
||||||
|
{
|
||||||
|
'key': 'list',
|
||||||
|
'value': listId,
|
||||||
|
'operator': ''
|
||||||
|
}
|
||||||
|
],
|
||||||
|
'operator': '&'
|
||||||
|
},
|
||||||
|
'keys': ['id', 'title']
|
||||||
|
})
|
||||||
|
items = [{'id': item['id'], 'title': item['title']} for item in result['data']['items']]
|
||||||
|
outfolder = "out"
|
||||||
|
for i in items:
|
||||||
|
print i['title']
|
||||||
|
savePath = "%s/%s_%s.txt" % (outfolder, i['id'], i['title'])
|
||||||
|
transcript_url = 'http://pad.ma/%s/transcripts.srt' % i['id']
|
||||||
|
txt = urllib2.urlopen(transcript_url).read()
|
||||||
|
outfile = open(savePath, "w")
|
||||||
|
outfile.write(txt)
|
||||||
|
outfile.close()
|
||||||
|
|
||||||
|
|
||||||
def getIds(result):
|
def getIds(result):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user