diff --git a/play/api/urls.py b/play/api/urls.py index 6716c55..b9bca9c 100644 --- a/play/api/urls.py +++ b/play/api/urls.py @@ -9,4 +9,6 @@ path('get-watch-history/', views.getWatchHistory, name='get-watch-history'), path('update-views/', views.updateViews, name='update-views'), path('logo/', views.logo, name='logo'), + path('get-video-thumbnail/', views.getVideoThumbnail, name='get-video-thumbnail'), + path('get-channel-banner/', views.getChannelBanner, name='get-channel-banner'), ] \ No newline at end of file diff --git a/play/api/views.py b/play/api/views.py index f3db2a6..a16c21e 100644 --- a/play/api/views.py +++ b/play/api/views.py @@ -1,6 +1,6 @@ from rest_framework.decorators import api_view, authentication_classes from rest_framework.response import Response -from play.models import Video, History +from play.models import Video, History, Channel from django.http import FileResponse from .serializers import HistorySerializer from django.contrib.auth.models import User @@ -42,6 +42,17 @@ def getVideoStream(request, video_id, file): return response +@api_view(['GET']) +def getVideoThumbnail(request, video_id): + video = Video.objects.get(video_id=video_id) + try: + file = open(video.thumbnail.path, 'rb') + except: + file = open('play/static/play/images/PlayTube.png', 'rb') + response = FileResponse(file) + return response + + @api_view(['GET']) def getPreviewThumbnails(request, video_id, number): video = Video.objects.get(video_id=video_id) @@ -56,6 +67,17 @@ def getPreviewThumbnails(request, video_id, number): return response +@api_view(['GET']) +def getChannelBanner(request, channel_id): + channel = Channel.objects.get(channel_id=channel_id) + try: + file = open(channel.banner.path, 'rb') + except: + file = open('play/static/play/images/PlayTube.png', 'rb') + response = FileResponse(file) + return response + + @api_view(['GET']) @authentication_classes([SessionAuthentication, BasicAuthentication]) def getWatchHistory(request, user): diff --git a/play/templates/play/base.html b/play/templates/play/base.html index a2d3d87..de256d4 100644 --- a/play/templates/play/base.html +++ b/play/templates/play/base.html @@ -5,6 +5,35 @@ + + + {% block open_graph %} + + + + + + + + {% endblock %} + + + {% block twitter_card %} + + + + + + + {% endblock %} + + + + + + + {% block title %}{% endblock %} + - {% block title %}{% endblock %} {% block html_head %}{% endblock %} {% block css %}{% endblock %} diff --git a/play/templates/play/login_register.html b/play/templates/play/login_register.html index 0209cad..718e7cb 100644 --- a/play/templates/play/login_register.html +++ b/play/templates/play/login_register.html @@ -1,7 +1,21 @@ {% extends 'play/base.html' %} {% load static %} -{% block content %} +{% block title %} Login - PlayTube {% endblock %} + +{% block open_graph %} + + + +{% endblock %} + +{% block twitter_card %} + + + + + +{% endblock %} {% block css %} {% endblock %} +{% block content %} +