diff --git a/.gitignore b/.gitignore index f0c88a9..1d65383 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ db.sqlite3 videos/ channel_archiver/yt-dlp-archive.txt channel_archiver/UnusualVideos* -*__pycache__* \ No newline at end of file +*__pycache__* +*.pyc \ No newline at end of file diff --git a/api/urls.py b/api/urls.py index 1e2d1e6..951aa81 100644 --- a/api/urls.py +++ b/api/urls.py @@ -2,5 +2,5 @@ from django.urls import path from . import views urlpatterns = [ - path('', views.query) + path('', views.videoAPI), ] \ No newline at end of file diff --git a/api/views.py b/api/views.py index 9ddaf6e..d3ecbec 100644 --- a/api/views.py +++ b/api/views.py @@ -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) \ No newline at end of file + return Response(serializer.data) diff --git a/core/__pycache__/__init__.cpython-38.pyc b/core/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 79d0b5f..0000000 Binary files a/core/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/admin.cpython-38.pyc b/core/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index 8f8ad87..0000000 Binary files a/core/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/apps.cpython-38.pyc b/core/__pycache__/apps.cpython-38.pyc deleted file mode 100644 index 1939d17..0000000 Binary files a/core/__pycache__/apps.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/models.cpython-38.pyc b/core/__pycache__/models.cpython-38.pyc deleted file mode 100644 index 2f41b94..0000000 Binary files a/core/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/urls.cpython-38.pyc b/core/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 835d60f..0000000 Binary files a/core/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/core/__pycache__/views.cpython-38.pyc b/core/__pycache__/views.cpython-38.pyc deleted file mode 100644 index 1437c5f..0000000 Binary files a/core/__pycache__/views.cpython-38.pyc and /dev/null differ diff --git a/core/migrations/__pycache__/0001_initial.cpython-38.pyc b/core/migrations/__pycache__/0001_initial.cpython-38.pyc deleted file mode 100644 index 0c1200a..0000000 Binary files a/core/migrations/__pycache__/0001_initial.cpython-38.pyc and /dev/null differ diff --git a/core/migrations/__pycache__/0002_video_thumbnail_alter_video_created_at.cpython-38.pyc b/core/migrations/__pycache__/0002_video_thumbnail_alter_video_created_at.cpython-38.pyc deleted file mode 100644 index 3f6408b..0000000 Binary files a/core/migrations/__pycache__/0002_video_thumbnail_alter_video_created_at.cpython-38.pyc and /dev/null differ diff --git a/core/migrations/__pycache__/0003_alter_video_file_alter_video_thumbnail.cpython-38.pyc b/core/migrations/__pycache__/0003_alter_video_file_alter_video_thumbnail.cpython-38.pyc deleted file mode 100644 index 2554846..0000000 Binary files a/core/migrations/__pycache__/0003_alter_video_file_alter_video_thumbnail.cpython-38.pyc and /dev/null differ diff --git a/core/migrations/__pycache__/__init__.cpython-38.pyc b/core/migrations/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index ffc280f..0000000 Binary files a/core/migrations/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/ragnarok/__pycache__/__init__.cpython-38.pyc b/ragnarok/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 6600f0e..0000000 Binary files a/ragnarok/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/ragnarok/__pycache__/settings.cpython-38.pyc b/ragnarok/__pycache__/settings.cpython-38.pyc deleted file mode 100644 index d64f6da..0000000 Binary files a/ragnarok/__pycache__/settings.cpython-38.pyc and /dev/null differ diff --git a/ragnarok/__pycache__/urls.cpython-38.pyc b/ragnarok/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 8307fc3..0000000 Binary files a/ragnarok/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/ragnarok/__pycache__/wsgi.cpython-38.pyc b/ragnarok/__pycache__/wsgi.cpython-38.pyc deleted file mode 100644 index ca63f3b..0000000 Binary files a/ragnarok/__pycache__/wsgi.cpython-38.pyc and /dev/null differ