You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

43 lines
2.3 KiB

from django.urls import include, path, re_path
from rest_framework.routers import SimpleRouter
from utils.cache import smart_cached_view
from .views import *
from .views_admin import *
# Helper function to cache public views with smart invalidation and force-refresh support
cached_view = smart_cached_view(60 * 60 * 2, key_prefix='video_api')
conditional_cached_view = smart_cached_view
app_name = 'video'
admin_router = SimpleRouter()
admin_router.register(r'videos', AdminVideoViewSet, basename='admin-video')
admin_router.register(r'playlists', AdminVideoPlaylistViewSet, basename='admin-video-playlist')
admin_router.register(r'categories', AdminVideoCategoryViewSet, basename='admin-video-category')
admin_router.register(r'collections', AdminVideoCollectionViewSet, basename='admin-video-collection')
# Hide all admin viewsets from swagger
for prefix, viewset, basename in admin_router.registry:
viewset.swagger_schema = None
dovodi_router = SimpleRouter()
dovodi_router.register(r'categories', DovodiVideoCategoryViewSet, basename='dovodi-video-category')
dovodi_router.register(r'collections', DovodiVideoCollectionViewSet, basename='dovodi-video-collection')
dovodi_router.register(r'items', DovodiVideoItemViewSet, basename='dovodi-video-item')
urlpatterns = [
path('admin/', include(admin_router.urls)),
path('dovodi/', include(dovodi_router.urls)),
path('categories/', cached_view(VideoCategoryListAPIView.as_view()), name='category-list'),
path('pinned-collections/', cached_view(PinnedVideoCollectionListView.as_view()), name='pinned-collection-list'),
path('collections/', cached_view(MiddleVideoCollectionListView.as_view()), name='collection-list'),
path('playlists/', conditional_cached_view(60 * 30, 'video_playlists')(VideoPlaylistListAPIView.as_view()), name='playlist-list'),
re_path(r'playlists/(?P<slug>[\w-]+)/$', VideoPlaylistDetailAPIView.as_view(), name='playlist-detail'),
# Keep old video endpoints for backward compatibility if needed
path('list/', conditional_cached_view(60 * 30, 'video_list')(VideoListAPIView.as_view()), name='video-list'),
re_path(r'detail/(?P<slug>[\w-]+)/$', VideoDetailAPIView.as_view(), name='video-detail'),
path('resolve-youtube/', ResolveYouTubeStreamURLAPIView.as_view(), name='resolve-youtube'),
]