Skip to content
This repository was archived by the owner on Aug 29, 2023. It is now read-only.

Commit a60c00a

Browse files
Working on the zolovideos component
1 parent f199473 commit a60c00a

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed
7 Bytes
Binary file not shown.

Profile/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ def post(self, request):
625625

626626
if userProfile.new_user:
627627
if userWallet.points >= userAmount:
628-
if userAmount >= 4500:
628+
if userAmount >= 4550:
629629
userWallet.points -= userAmount
630630
# Set new user to false
631631
userProfile.new_user = False
@@ -719,7 +719,7 @@ def get(self, request, *args, **kwargs):
719719

720720
class GetReferralInfoAPI(APIView):
721721
# Getting the list of Referrals for the User
722-
email = "apptesta61@gmail.com"
722+
email = "Usmansuperstar233@gmail.com"
723723
user = User.objects.get(email=email)
724724

725725
def get(self, request, format=None):
550 Bytes
Binary file not shown.

rewards/views.py

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from django.utils import timezone as django_timezone
1414
from .serializers import QuestionSerializer, QuizApiSerializer, QuizSerializer, MonsterHunterSerializer
1515
from .models import Subject, Quiz, Questions
16+
import yt_dlp as youtube_dl
1617

1718
User = get_user_model()
1819

@@ -429,11 +430,32 @@ class GetZoloVideos(APIView):
429430
authentication_classes = [TokenAuthentication]
430431

431432
def get(self, request):
432-
# Current user
433-
user = request.user
433+
# Retrieve ZoloVideos instance for the current user
434+
zolo_videos = ZoloVideos.objects.get(user=request.user)
435+
436+
# Get the unwatched video URLs based on the user's country
437+
unwatched_urls = zolo_videos.get_videos_by_country()
438+
439+
# Get the streaming URL for each video URL
440+
stream_urls = [get_stream_url(url) for url in unwatched_urls]
441+
442+
# Return your response or render the template with the stream URLs
443+
return Response({"urls": stream_urls}, status=status.HTTP_200_OK)
444+
445+
446+
def get_stream_url(video_url):
447+
# Create youtube_dl options dictionary
448+
ydl_opts = {
449+
'format': 'best',
450+
'quiet': True
451+
}
452+
453+
# Create youtube_dl extractor
454+
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
455+
info_dict = ydl.extract_info(video_url, download=False)
456+
stream_url = info_dict['url']
434457

435-
userZoloVideos = ZoloVideos.objects.get(user=user)
436-
return Response({"videos": userZoloVideos.get_videos_by_country()})
458+
return stream_url
437459

438460

439461
class ZoloVideoApi(APIView):

0 commit comments

Comments
 (0)