2009-06-14 14:51:10 +00:00
|
|
|
import urllib
|
|
|
|
from django.utils import simplejson
|
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.shortcuts import render_to_response
|
2010-07-12 19:09:02 +00:00
|
|
|
from settings import PADMA_URL
|
2009-06-14 14:51:10 +00:00
|
|
|
|
|
|
|
def getHtmlFromUrl(url):
|
|
|
|
try:
|
|
|
|
u = urllib.urlopen(url)
|
|
|
|
t = u.read()
|
|
|
|
u.close
|
|
|
|
except:
|
|
|
|
return False
|
|
|
|
return t
|
|
|
|
|
|
|
|
def fetchJson(request):
|
|
|
|
if request.GET['url']:
|
|
|
|
u = request.GET['url']
|
|
|
|
json = getHtmlFromUrl(u)
|
|
|
|
return HttpResponse(json, mimetype="application/javascript")
|
|
|
|
else:
|
|
|
|
return HttpResponse("{'error': True}", mimetype="application/javascript")
|
|
|
|
|
2010-07-17 15:18:44 +00:00
|
|
|
def translate(request):
|
|
|
|
return render_to_response("translate.html", {'padma_url': PADMA_URL})
|
|
|
|
|
2010-07-17 20:26:05 +00:00
|
|
|
|
|
|
|
|
2010-07-12 19:09:02 +00:00
|
|
|
def fetchSrt(request):
|
|
|
|
if request.GET['id']:
|
|
|
|
padmaId = request.GET['id']
|
2010-07-17 15:18:44 +00:00
|
|
|
if 'track' in request.GET:
|
|
|
|
track = request.GET['track']
|
|
|
|
else:
|
|
|
|
track = 'transcripts'
|
2010-07-13 12:08:50 +00:00
|
|
|
url = "%s/%s/export/%s.srt" % (PADMA_URL, padmaId, track,)
|
2010-07-17 15:18:44 +00:00
|
|
|
print url
|
2010-07-12 19:09:02 +00:00
|
|
|
srt = getHtmlFromUrl(url)
|
|
|
|
return HttpResponse(srt)
|
|
|
|
else:
|
|
|
|
return HttpResponse("{'error': True}", mimetype="application/javascript")
|
|
|
|
|
2009-06-14 14:51:10 +00:00
|
|
|
def index(request):
|
2010-07-15 00:02:35 +00:00
|
|
|
return render_to_response("index.html", {
|
|
|
|
'padma_url': PADMA_URL
|
|
|
|
})
|
2009-06-14 14:51:10 +00:00
|
|
|
|
|
|
|
def listDetail(request):
|
|
|
|
if request.GET:
|
2010-07-13 12:08:50 +00:00
|
|
|
rDict = {
|
2010-07-15 00:02:35 +00:00
|
|
|
'listId': request.GET['id'],
|
2010-07-13 12:08:50 +00:00
|
|
|
'padma_url': PADMA_URL,
|
|
|
|
}
|
2009-06-14 14:51:10 +00:00
|
|
|
return render_to_response("list.html", rDict)
|
|
|
|
else:
|
2010-07-12 19:09:02 +00:00
|
|
|
return HttpResponse("Please pass me a list id")
|
|
|
|
|
|
|
|
|