path('move_to_archive/<path:filename>/', views.move_to_archive, name="move_to_archive"),
path('publishing/', views.list_publishing, name="list_publishing"),
path('book/<slug:slug>/', views.BookView.as_view(), name="book"),
+ path('book/<slug:slug>.json', views.book_json, name="book_json"),
path('book-youtube-volume/<int:aid>/', views.book_youtube_volume, name="book_youtube_volume"),
path('file/<int:id>/', views.file_managed, name="file"),
path('publish/<int:aid>/', views.publish, name="publish"),
root_len = len(root_path)
for path, dirs, files in os.walk(root_path, followlinks=True):
for fname in files:
+ if '\n' in fname: continue
yield os.path.join(path, fname)[root_len:].lstrip("/")
from django.contrib.postgres.search import SearchVector
from django.urls import reverse
from django.db.models import Q, Max
-from django.http import Http404, HttpResponse
+from django.http import Http404, HttpResponse, JsonResponse
from django.shortcuts import render, redirect, get_object_or_404
from django.utils.translation import gettext as _
from django.views.decorators.http import require_POST
b.subtotal = last_vol_sub.total_for_sub
return list(qs)
+def book_json(request, slug):
+ qs = models.Audiobook.objects.filter(slug=slug).order_by(
+ "index"
+ )
+ return JsonResponse({
+ "items": [
+ {
+ "id": item.id,
+ "part": item.part_name,
+ "mp3_status": item.get_mp3_status_display(),
+ "ogg_status": item.get_ogg_status_display(),
+ "youtube_status": item.get_youtube_status_display(),
+ }
+ for item in qs
+ ]
+ })
+
@permission_required('archive.change_audiobook')
def book_youtube_volume(request, aid):