summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-12-17 23:52:22 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2009-12-17 23:52:22 +0100
commita9a0ab594e4ea05532ff089b8eee7bf20ea571be (patch)
tree485937ee65c55ff4074fc9ca5b54152994567885 /module
parentRemoved prints (diff)
downloadpyload-a9a0ab594e4ea05532ff089b8eee7bf20ea571be.tar.xz
new web JSON functions
Diffstat (limited to 'module')
-rw-r--r--module/web/ajax/urls.py5
-rw-r--r--module/web/ajax/views.py39
2 files changed, 43 insertions, 1 deletions
diff --git a/module/web/ajax/urls.py b/module/web/ajax/urls.py
index d1c90aa21..9849004d1 100644
--- a/module/web/ajax/urls.py
+++ b/module/web/ajax/urls.py
@@ -14,8 +14,11 @@ urlpatterns = patterns('ajax',
# Uncomment the next line to enable the admin:
(r'^add_package$', 'views.add_package'),
(r'^status$', 'views.status'),
- (r'^links$', 'views.links'),
+ (r'^links$', 'views.links'), #currently active links
(r'^queue$', 'views.queue'),
(r'^pause$', 'views.pause'),
(r'^unpause$', 'views.unpause'),
+ (r'^packages$', 'views.packages'),
+ (r'^package/(\d+)$', 'views.package'),
+ (r'^link/(\d+)$', 'views.link'),
) \ No newline at end of file
diff --git a/module/web/ajax/views.py b/module/web/ajax/views.py
index 05c91597f..584ad1a0e 100644
--- a/module/web/ajax/views.py
+++ b/module/web/ajax/views.py
@@ -78,3 +78,42 @@ def unpause(request):
except:
return HttpResponseServerError()
+
+
+
+@permission('pyload.can_see_dl')
+def packages(request):
+ try:
+ data = settings.PYLOAD.get_queue()
+
+ for package in data:
+ package['links'] = []
+ for file in settings.PYLOAD.get_package_files(package['id']):
+ package['links'].append(settings.PYLOAD.get_file_info(file))
+
+ return JsonResponse(data)
+
+ except:
+ return HttpResponseServerError()
+
+@permission('pyload.can_see_dl')
+def package(request,id):
+ try:
+ data = settings.PYLOAD.get_package_data(int(id))
+ data['links'] = []
+ for file in settings.PYLOAD.get_package_files(data['id']):
+ data['links'].append(settings.PYLOAD.get_file_info(file))
+
+ return JsonResponse(data)
+
+ except:
+ return HttpResponseServerError()
+
+@permission('pyload.can_see_dl')
+def link(request,id):
+ try:
+ data = settings.PYLOAD.get_file_info(int(id))
+ return JsonResponse(data)
+
+ except:
+ return HttpResponseServerError()