Api endpoint for video search with querying implemented

This commit is contained in:
david
2023-05-19 01:06:50 +02:00
parent 468fb338f1
commit 95d5aa6992
17 changed files with 8 additions and 5 deletions
+2 -1
View File
@@ -2,4 +2,5 @@ db.sqlite3
videos/
channel_archiver/yt-dlp-archive.txt
channel_archiver/UnusualVideos*
*__pycache__*
*__pycache__*
*.pyc
+1 -1
View File
@@ -2,5 +2,5 @@ from django.urls import path
from . import views
urlpatterns = [
path('', views.query)
path('', views.videoAPI),
]
+5 -3
View File
@@ -2,9 +2,11 @@ from rest_framework.response import Response
from rest_framework.decorators import api_view
from core.models import Video
from core.serializers import VideoSerializer
from django.db.models import Q
@api_view(['GET'])
def query(request):
videos = Video.objects.all()
def videoAPI(request):
q = request.GET.get('q', '')
videos = Video.objects.filter(Q(id__contains=q) | Q(name__contains=q))
serializer = VideoSerializer(videos, many=True)
return Response(serializer.data)
return Response(serializer.data)
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.