split up backend/archive api
This commit is contained in:
parent
f3da10d643
commit
c2f90f7404
2 changed files with 14 additions and 50 deletions
|
@ -242,39 +242,15 @@ def firefogg_upload(request):
|
||||||
response = json_response(status=400, text='this request requires POST')
|
response = json_response(status=400, text='this request requires POST')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
"""
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def list_files(request):
|
def api_editFile(request): #FIXME: should this be file.files. or part of update
|
||||||
'''
|
'''
|
||||||
GET list
|
change file / imdb link
|
||||||
> {
|
|
||||||
"files": {
|
|
||||||
"a41cde31c581e11d": {"path": "E/Example, The/An Example.avi", "size":1646274},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'''
|
'''
|
||||||
response = {}
|
response = json_response(status=501, text='not implemented')
|
||||||
response['files'] = {}
|
|
||||||
qs = models.UserFile.filter(user=request.user)
|
|
||||||
p = Paginator(qs, 1000)
|
|
||||||
for i in p.page_range:
|
|
||||||
page = p.page(i)
|
|
||||||
for f in page.object_list:
|
|
||||||
response['files'][f.movie_file.oshash] = {'path': f.path, 'size': f.movie_file.size}
|
|
||||||
return render_to_json_response(response)
|
|
||||||
|
|
||||||
def find_files(request):
|
|
||||||
response = {}
|
|
||||||
query = _parse_query(request)
|
|
||||||
response['files'] = {}
|
|
||||||
qs = models.UserFile.filter(user=request.user).filter(movie_file__movie__id__in=query['q'])
|
|
||||||
p = Paginator(qs, 1000)
|
|
||||||
for i in p.page_range:
|
|
||||||
page = p.page(i)
|
|
||||||
for f in page.object_list:
|
|
||||||
response['files'][f.movie_file.oshash] = {'path': f.path, 'size': f.movie_file.size}
|
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
|
"""
|
||||||
def api_fileInfo(request):
|
def api_fileInfo(request):
|
||||||
'''
|
'''
|
||||||
param data
|
param data
|
||||||
|
|
|
@ -34,7 +34,7 @@ import tasks
|
||||||
from oxuser.models import getUserJSON
|
from oxuser.models import getUserJSON
|
||||||
from oxuser.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences, api_findUser
|
from oxuser.views import api_login, api_logout, api_register, api_contact, api_recover, api_preferences, api_findUser
|
||||||
|
|
||||||
from archive.views import api_update, api_upload
|
from archive.views import api_update, api_upload, api_editFile
|
||||||
|
|
||||||
from archive.models import File
|
from archive.models import File
|
||||||
from archive import extract
|
from archive import extract
|
||||||
|
@ -358,6 +358,9 @@ def api_editLayer(request):
|
||||||
response = json_response(status=501, text='not implemented')
|
response = json_response(status=501, text='not implemented')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
|
'''
|
||||||
|
List API
|
||||||
|
'''
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def api_addListItem(request):
|
def api_addListItem(request):
|
||||||
'''
|
'''
|
||||||
|
@ -412,24 +415,9 @@ def api_removeList(request):
|
||||||
response = json_response(status=501, text='not implemented')
|
response = json_response(status=501, text='not implemented')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
def api_encodingSettings(request):
|
'''
|
||||||
'''
|
Poster API
|
||||||
returns Firefogg encoding settings as specified by site
|
'''
|
||||||
return {'status': {'code': int, 'text': string},
|
|
||||||
'data': {'options': {'videoQuality':...}}}
|
|
||||||
'''
|
|
||||||
response = json_response({'options': settings.VIDEO_ENCODING[settings.VIDEO_PROFILE]})
|
|
||||||
return render_to_json_response(response)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
|
||||||
def api_editFile(request): #FIXME: should this be file.files. or part of update
|
|
||||||
'''
|
|
||||||
change file / imdb link
|
|
||||||
'''
|
|
||||||
response = json_response(status=501, text='not implemented')
|
|
||||||
return render_to_json_response(response)
|
|
||||||
|
|
||||||
def api_parse(request): #parse path and return info
|
def api_parse(request): #parse path and return info
|
||||||
'''
|
'''
|
||||||
param data
|
param data
|
||||||
|
@ -540,6 +528,9 @@ def apidoc(request):
|
||||||
'sitename': settings.SITENAME,})
|
'sitename': settings.SITENAME,})
|
||||||
return render_to_response('api.html', context)
|
return render_to_response('api.html', context)
|
||||||
|
|
||||||
|
'''
|
||||||
|
media and data delivery
|
||||||
|
'''
|
||||||
def data(request, id, data):
|
def data(request, id, data):
|
||||||
movie = get_object_or_404(models.Movie, movieId=id)
|
movie = get_object_or_404(models.Movie, movieId=id)
|
||||||
response = {}
|
response = {}
|
||||||
|
@ -549,7 +540,6 @@ def data(request, id, data):
|
||||||
response = movie.metadata.get('cuts', {})
|
response = movie.metadata.get('cuts', {})
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
#media delivery
|
|
||||||
def frame(request, id, position, size):
|
def frame(request, id, position, size):
|
||||||
movie = get_object_or_404(models.Movie, movieId=id)
|
movie = get_object_or_404(models.Movie, movieId=id)
|
||||||
position = float(position.replace(',', '.'))
|
position = float(position.replace(',', '.'))
|
||||||
|
@ -574,10 +564,8 @@ def poster(request, id, size=128):
|
||||||
else:
|
else:
|
||||||
poster_path = movie.poster.path
|
poster_path = movie.poster.path
|
||||||
else:
|
else:
|
||||||
'''
|
|
||||||
if not size: size='large'
|
if not size: size='large'
|
||||||
return redirect('http:///0xdb.org/%s/poster.%s.jpg' % (movie.movieId, size))
|
return redirect('http:///0xdb.org/%s/poster.%s.jpg' % (movie.movieId, size))
|
||||||
'''
|
|
||||||
poster_path = os.path.join(settings.STATIC_ROOT, 'png/posterDark.48.png')
|
poster_path = os.path.join(settings.STATIC_ROOT, 'png/posterDark.48.png')
|
||||||
return HttpFileResponse(poster_path, content_type='image/jpeg')
|
return HttpFileResponse(poster_path, content_type='image/jpeg')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue