From c2f90f7404d364859371dc349802bb2ff205bbfb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 13 Sep 2010 15:46:49 +0200 Subject: [PATCH] split up backend/archive api --- pandora/archive/views.py | 32 ++++---------------------------- pandora/backend/views.py | 32 ++++++++++---------------------- 2 files changed, 14 insertions(+), 50 deletions(-) diff --git a/pandora/archive/views.py b/pandora/archive/views.py index 0e6519ea..59ec3743 100644 --- a/pandora/archive/views.py +++ b/pandora/archive/views.py @@ -242,39 +242,15 @@ def firefogg_upload(request): response = json_response(status=400, text='this request requires POST') return render_to_json_response(response) -""" @login_required_json -def list_files(request): +def api_editFile(request): #FIXME: should this be file.files. or part of update ''' - GET list - > { - "files": { - "a41cde31c581e11d": {"path": "E/Example, The/An Example.avi", "size":1646274}, - } - } + change file / imdb link ''' - response = {} - 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} + response = json_response(status=501, text='not implemented') return render_to_json_response(response) +""" def api_fileInfo(request): ''' param data diff --git a/pandora/backend/views.py b/pandora/backend/views.py index eb33ad0d..db65293c 100644 --- a/pandora/backend/views.py +++ b/pandora/backend/views.py @@ -34,7 +34,7 @@ import tasks from oxuser.models import getUserJSON 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 import extract @@ -358,6 +358,9 @@ def api_editLayer(request): response = json_response(status=501, text='not implemented') return render_to_json_response(response) +''' + List API +''' @login_required_json def api_addListItem(request): ''' @@ -412,24 +415,9 @@ def api_removeList(request): response = json_response(status=501, text='not implemented') return render_to_json_response(response) -def api_encodingSettings(request): - ''' - 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) - +''' + Poster API +''' def api_parse(request): #parse path and return info ''' param data @@ -540,6 +528,9 @@ def apidoc(request): 'sitename': settings.SITENAME,}) return render_to_response('api.html', context) +''' + media and data delivery +''' def data(request, id, data): movie = get_object_or_404(models.Movie, movieId=id) response = {} @@ -549,7 +540,6 @@ def data(request, id, data): response = movie.metadata.get('cuts', {}) return render_to_json_response(response) -#media delivery def frame(request, id, position, size): movie = get_object_or_404(models.Movie, movieId=id) position = float(position.replace(',', '.')) @@ -574,10 +564,8 @@ def poster(request, id, size=128): else: poster_path = movie.poster.path else: - ''' if not size: size='large' return redirect('http:///0xdb.org/%s/poster.%s.jpg' % (movie.movieId, size)) - ''' poster_path = os.path.join(settings.STATIC_ROOT, 'png/posterDark.48.png') return HttpFileResponse(poster_path, content_type='image/jpeg')