Skip to content

Commit

Permalink
🩹(hyeon/feature/random_playlist_error_handling2/ILGOB#14) 플리 생성시 none…
Browse files Browse the repository at this point in the history
…타입생성 오류 해결 및 자잘한 픽스
  • Loading branch information
hyeon0697 committed Sep 6, 2022
1 parent bdb2b71 commit fa86690
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion backend/plinic/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __str__(self):


class Playlist(TimeStampedModel):
title = models.CharField(max_length=150, default="tempList")
title = models.CharField(max_length=150)
total_url = models.URLField()
thumbnail = models.ImageField(blank=True, upload_to="thumbnails/%Y/%m/%d")
profile = models.ForeignKey("accounts.Profile", on_delete=models.CASCADE, related_name="playlist_profile_set")
Expand Down
2 changes: 1 addition & 1 deletion backend/plinic/utils/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
'''


DEVELOPER_KEY = "AIzaSyDfAxX1QZdRgBp5KUGpHXOjeYe8u9JX0hg"
DEVELOPER_KEY = "AIzaSyCbSm4vQcnvyL1uWHY7dHa95M0TJeiHGPg"
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"

Expand Down
2 changes: 1 addition & 1 deletion backend/plinic/utils/youtube_duration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def find_duration(video_id):
# video_id = "3Y0eUYVjhQM" # 10H9M11S
# video_id = "1IlTeOMCNJU" # 4M31S

api_key = "AIzaSyDfAxX1QZdRgBp5KUGpHXOjeYe8u9JX0hg"
api_key = "AIzaSyCbSm4vQcnvyL1uWHY7dHa95M0TJeiHGPg"
searchUrl = "https://www.googleapis.com/youtube/v3/videos?id="+video_id+"&key="+api_key+"&part=contentDetails"
response = urllib.request.urlopen(searchUrl).read()
data = json.loads(response)
Expand Down
34 changes: 19 additions & 15 deletions backend/plinic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

from .models import Post
from .models import Playlist
from .models import Genre
from .serializers import PostSerializer
from .serializers import PlaylistSerializer


global total_urls
total_urls = ""


class PostViewSet(ModelViewSet):
queryset = Post.objects.all()
serializer_class = PostSerializer
Expand All @@ -31,20 +31,6 @@ def perform_create(self, serializer):
serializer.save(profile=self.request.user.profile)
return super().perform_create(serializer)

#임시
class RandomPlayListSet(generics.ListCreateAPIView):

queryset = Playlist.objects.all()
serializer_class = PlaylistSerializer

def perform_create(self, serializer):
#serializer.save(user=self.request.user)
title = "tempList"
total_url = total_urls
profile = 1
genre = "k-pop"

serializer.save()

class RandomPlayListView(APIView):

Expand All @@ -70,6 +56,24 @@ def get(self, request):

total_urls = json_val["Total_urls"]
print(total_urls)

print(type(request.user.profile))
#개선이 매우 매우 매우 필요함!!!!!!
PlaylistGenre = list(Genre.objects.all())

for listgenre in PlaylistGenre:
if "<Genre : "+genre+">" == str(listgenre):
indexGenre = PlaylistGenre.index(listgenre)

RandomPlayList = Playlist()
RandomPlayList.title = "tempList"
RandomPlayList.total_url = json_val["Total_urls"]
RandomPlayList.profile = request.user.profile
RandomPlayList.genre = PlaylistGenre[indexGenre]


RandomPlayList.save()

return ResponseData
# watch_videos?video_ids=

Expand Down

0 comments on commit fa86690

Please sign in to comment.