paths
authorRadek Czajka <rczajka@rczajka.pl>
Tue, 25 Oct 2022 13:49:16 +0000 (15:49 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Tue, 25 Oct 2022 13:49:16 +0000 (15:49 +0200)
src/apiclient/urls.py
src/archive/urls.py
src/archive/views.py
src/youtube/urls.py

index ad3f166..58dec53 100755 (executable)
@@ -1,10 +1,10 @@
-from django.conf.urls import url
+from django.urls import path
 from . import views
 
 
 urlpatterns = [
-    url(r'^oauth/$', views.oauth, name='apiclient_oauth'),
-    url(r'^oauth_callback/$', views.oauth_callback, name='apiclient_oauth_callback'),
-    url(r'^oauth2/$', views.oauth2, name='apiclient_oauth2'),
-    url(r'^oauth2_redirect/$', views.oauth2_redirect, name='apiclient_oauth2_redirect'),
+    path('oauth/', views.oauth, name='apiclient_oauth'),
+    path('auth_callback/', views.oauth_callback, name='apiclient_oauth_callback'),
+    path('oauth2/', views.oauth2, name='apiclient_oauth2'),
+    path('oauth2_redirect/', views.oauth2_redirect, name='apiclient_oauth2_redirect'),
 ]
index 826c0c3..b057df4 100644 (file)
@@ -1,24 +1,23 @@
-from django.conf.urls import url
 from django.urls import path
 from django.views.generic import RedirectView
 from . import views
 
 urlpatterns = [
     path("", views.AudiobookList.as_view(), name="list_managed"),
-    url(r'^new/$', views.list_new, name="list_new"),
-    url(r'^new/(.+)/$', views.file_new, name="file_new"),
-    url(r'^move_to_archive/(.+)/$', views.move_to_archive, name="move_to_archive"),
-    url(r'^publishing/$', views.list_publishing, name="list_publishing"),
+    path('new/', views.list_new, name="list_new"),
+    path('new/<path:filename>/', views.file_new, name="file_new"),
+    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-youtube-volume/<int:aid>/', views.book_youtube_volume, name="book_youtube_volume"),
-    url(r'^file/(\d+)/$', views.file_managed, name="file"),
-    url(r'^publish/(\d+)/$', views.publish, name="publish"),
-    url(r'^convert/(\d+)/$', views.publish, {'publish': False}, name="convert"),
-    url(r'^download/(\d+)/$', views.download, name="download"),
-    url(r'^download/(\d+)\.(mp3|ogg|mkv)$', views.download, name="download"),
-    url(r'^cancel/(\d+)/$', views.cancel_publishing, name="cancel_publishing"),
-    url(r'^remove_to_archive/(\d+)/$', views.remove_to_archive, name="remove_to_archive"),
-    url(r'^unmanaged/$', views.list_unmanaged, name="list_unmanaged"),
-    url(r'^unmanaged/(.+)/$', views.file_unmanaged, name="file_unmanaged"),
-    url(r'^move_to_new/(.+)/$', views.move_to_new, name="move_to_new"),
+    path('file/<int:id>/', views.file_managed, name="file"),
+    path('publish/<int:aid>/', views.publish, name="publish"),
+    path('convert/<int:aid>/', views.publish, {'publish': False}, name="convert"),
+    path('download/<int:aid>/', views.download, name="download"),
+    path('download/<int:aid>.<slug:which>', views.download, name="download"),
+    path('cancel/<int:aid>/', views.cancel_publishing, name="cancel_publishing"),
+    path('remove_to_archive/<int:aid>/', views.remove_to_archive, name="remove_to_archive"),
+    path('unmanaged/', views.list_unmanaged, name="list_unmanaged"),
+    path('unmanaged/<path:filename>/', views.file_unmanaged, name="file_unmanaged"),
+    path('move_to_new/<path:filename>/', views.move_to_new, name="move_to_new"),
 ]
index 4865203..6ae2927 100644 (file)
@@ -70,9 +70,8 @@ def file_new(request, filename):
 def move_to_archive(request, filename):
     """ move a new file to the unmanaged files dir """
 
-    filename_str = filename.encode('utf-8')
-    old_path = os.path.join(settings.NEW_PATH, filename_str)
-    new_path = os.path.join(settings.UNMANAGED_PATH, filename_str)
+    old_path = os.path.join(settings.NEW_PATH, filename)
+    new_path = os.path.join(settings.UNMANAGED_PATH, filename)
     new_dir = os.path.split(new_path)[0]
     if not os.path.isdir(new_dir):
         os.makedirs(new_dir)
@@ -131,9 +130,8 @@ def remove_to_archive(request, aid):
 def move_to_new(request, filename):
     """ move a unmanaged file to new files dir """
 
-    filename_str = filename.encode('utf-8')
-    old_path = os.path.join(settings.UNMANAGED_PATH, filename_str)
-    new_path = os.path.join(settings.NEW_PATH, filename_str)
+    old_path = os.path.join(settings.UNMANAGED_PATH, filename)
+    new_path = os.path.join(settings.NEW_PATH, filename)
     new_dir = os.path.split(new_path)[0]
     if not os.path.isdir(new_dir):
         os.makedirs(new_dir)
@@ -274,7 +272,7 @@ def list_unmanaged(request):
 
 
 def file_unmanaged(request, filename):
-    tags = mutagen.File(os.path.join(settings.UNMANAGED_PATH, filename.encode('utf-8')))
+    tags = mutagen.File(os.path.join(settings.UNMANAGED_PATH, filename))
     if not tags:
         tags = {}
     
index 8a4618b..91dbeb4 100644 (file)
@@ -1,9 +1,8 @@
-from django.conf.urls import url
 from django.urls import path
 from . import views
 
 urlpatterns = [
-    url(r'^publish/(\d+)/$', views.publish, name="youtube_publish"),
+    path('publish/<int:aid>/', views.publish, name="youtube_publish"),
     path('book/<slug:slug>/publish/', views.book_publish, name="youtube_book_publish"),
     path('thumbnail/<int:aid>/', views.thumbnail, name='youtube_thumbnail'),
     path('thumbnail/<int:aid>/<int:thumbnail_id>/', views.thumbnail, name='youtube_thumbnail'),