fixes for python3
This commit is contained in:
parent
79fa8402a5
commit
81517ae18d
14
utils.py
14
utils.py
|
@ -2,13 +2,13 @@ from settings import username, password, url
|
||||||
import ox
|
import ox
|
||||||
import json
|
import json
|
||||||
import codecs
|
import codecs
|
||||||
import urllib2
|
from urllib.request import urlopen
|
||||||
|
|
||||||
api = ox.api.API(url)
|
api = ox.api.API(url)
|
||||||
user = api.signin({'username': username, 'password': password})
|
user = api.signin({'username': username, 'password': password})
|
||||||
|
|
||||||
if user['data'].has_key("errors"):
|
if 'errors' in user['data']:
|
||||||
print "Authentication Failed!"
|
print("Authentication Failed!")
|
||||||
|
|
||||||
def titleContains(string):
|
def titleContains(string):
|
||||||
return api.find({
|
return api.find({
|
||||||
|
@ -117,7 +117,7 @@ def replacePlaceNames(old, new, operator="", start=0, end=100):
|
||||||
if new_value == '':
|
if new_value == '':
|
||||||
log = "EMPTY VALUE: %s" % m['id']
|
log = "EMPTY VALUE: %s" % m['id']
|
||||||
logFile.write(log)
|
logFile.write(log)
|
||||||
print log
|
print(log)
|
||||||
continue
|
continue
|
||||||
ret.append(api.editAnnotation({
|
ret.append(api.editAnnotation({
|
||||||
'id': m['id'],
|
'id': m['id'],
|
||||||
|
@ -127,7 +127,7 @@ def replacePlaceNames(old, new, operator="", start=0, end=100):
|
||||||
}))
|
}))
|
||||||
log = "%s| %s| %s" % (m['id'], value, new_value,)
|
log = "%s| %s| %s" % (m['id'], value, new_value,)
|
||||||
logFile.write(log + "\n")
|
logFile.write(log + "\n")
|
||||||
print log
|
print(log)
|
||||||
logFile.close()
|
logFile.close()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -219,10 +219,10 @@ def getTranscriptsForList(listId='sanj:spaces of theatre'):
|
||||||
items = [{'id': item['id'], 'title': item['title']} for item in result['data']['items']]
|
items = [{'id': item['id'], 'title': item['title']} for item in result['data']['items']]
|
||||||
outfolder = "out"
|
outfolder = "out"
|
||||||
for i in items:
|
for i in items:
|
||||||
print i['title']
|
print(i['title'])
|
||||||
savePath = "%s/%s_%s.txt" % (outfolder, i['id'], i['title'])
|
savePath = "%s/%s_%s.txt" % (outfolder, i['id'], i['title'])
|
||||||
transcript_url = 'http://pad.ma/%s/transcripts.srt' % i['id']
|
transcript_url = 'http://pad.ma/%s/transcripts.srt' % i['id']
|
||||||
txt = urllib2.urlopen(transcript_url).read()
|
txt = urlopen(transcript_url).read()
|
||||||
outfile = open(savePath, "w")
|
outfile = open(savePath, "w")
|
||||||
outfile.write(txt)
|
outfile.write(txt)
|
||||||
outfile.close()
|
outfile.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user