Compare commits
3 Commits
0ac29fd7d5
...
19dc4b5b64
| Author | SHA1 | Date | |
|---|---|---|---|
| 19dc4b5b64 | |||
| 95d5aa6992 | |||
| 468fb338f1 |
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,3 +2,5 @@ db.sqlite3
|
||||||
videos/
|
videos/
|
||||||
channel_archiver/yt-dlp-archive.txt
|
channel_archiver/yt-dlp-archive.txt
|
||||||
channel_archiver/UnusualVideos*
|
channel_archiver/UnusualVideos*
|
||||||
|
*__pycache__*
|
||||||
|
*.pyc
|
||||||
0
api/__init__.py
Normal file
0
api/__init__.py
Normal file
6
api/urls.py
Normal file
6
api/urls.py
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.videoAPI),
|
||||||
|
]
|
||||||
12
api/views.py
Normal file
12
api/views.py
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
from django.db.models import Q
|
||||||
|
from rest_framework.response import Response
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
from core.models import Video
|
||||||
|
from core.serializers import VideoSerializer
|
||||||
|
|
||||||
|
@api_view(['GET'])
|
||||||
|
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)
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,6 +1,4 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
|
|
||||||
from .models import Video
|
from .models import Video
|
||||||
|
|
||||||
@admin.register(Video)
|
@admin.register(Video)
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
7
core/serializers.py
Normal file
7
core/serializers.py
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
from rest_framework import serializers
|
||||||
|
from .models import Video
|
||||||
|
|
||||||
|
class VideoSerializer(serializers.ModelSerializer):
|
||||||
|
class Meta:
|
||||||
|
model = Video
|
||||||
|
fields = ['id', 'name']
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.core, name='core'),
|
path('', views.core, name='core'),
|
||||||
path('status/', views.status, name='status'),
|
path('status/', views.status, name='status'),
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.contrib.auth.decorators import login_required
|
|
||||||
from django.http import HttpResponse
|
|
||||||
from django.shortcuts import redirect
|
from django.shortcuts import redirect
|
||||||
from core.models import Video
|
from core.models import Video
|
||||||
import random
|
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
@ -11,10 +8,9 @@ def core(request):
|
||||||
videos = Video.objects.all()
|
videos = Video.objects.all()
|
||||||
return render(request, 'base.html', {'videos': videos[::-1]})
|
return render(request, 'base.html', {'videos': videos[::-1]})
|
||||||
|
|
||||||
|
|
||||||
def random(request):
|
def random(request):
|
||||||
videos = Video.objects.all().order_by("?")
|
videos = Video.objects.all().order_by("?")
|
||||||
ran = videos.first();
|
ran = videos.first()
|
||||||
return redirect('/view/'+str(ran.id))
|
return redirect('/view/'+str(ran.id))
|
||||||
|
|
||||||
def status(request):
|
def status(request):
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -40,7 +40,7 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'rest_framework',
|
'rest_framework',
|
||||||
'sage_stream',
|
#'sage_stream',
|
||||||
'core'
|
'core'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,7 @@ urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls),
|
||||||
path('auth/', include('django.contrib.auth.urls')),
|
path('auth/', include('django.contrib.auth.urls')),
|
||||||
path('', include('core.urls')),
|
path('', include('core.urls')),
|
||||||
path('/', include('core.urls')),
|
path('api/', include('api.urls')),
|
||||||
path('status/', include('core.urls')),
|
|
||||||
path('api/', include('sage_stream.api.urls')),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user