добавил метод ретрив для плеера
This commit is contained in:
parent
de9d018f16
commit
c2d3013459
|
|
@ -29,8 +29,8 @@ class FetchAndServeFile(ViewSet):
|
|||
except requests.RequestException as e:
|
||||
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)
|
||||
|
||||
""" def get(self, request, station, song_id, *args, **kwargs):
|
||||
file_url = f"http://82.97.242.49:10084/api/station/{station}/file/{song_id}/play"
|
||||
def retrieve(self, request, pk=None):
|
||||
file_url = f"http://82.97.242.49:10084/api/station/it-radio/file/{pk}/play"
|
||||
api_key = "49226d3488aac3f5:18d88659c6c1c5e131a0ce0a94d55235"
|
||||
|
||||
headers = {
|
||||
|
|
@ -44,30 +44,7 @@ class FetchAndServeFile(ViewSet):
|
|||
# Create a response with the appropriate content type and headers
|
||||
file_response = HttpResponse(response.content, content_type='audio/mpeg')
|
||||
file_response['Content-Disposition'] = 'attachment; filename="output.mp3"'
|
||||
|
||||
return file_response
|
||||
|
||||
except requests.RequestException as e:
|
||||
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST) """
|
||||
|
||||
""" class FetchAndServeFile(APIView):
|
||||
permission_classes = [AllowAny]
|
||||
|
||||
def get(self, request, station, song_id, *args, **kwargs):
|
||||
file_url = f"http://82.97.242.49:10084/api/station/{station}/file/{song_id}/play"
|
||||
api_key = "49226d3488aac3f5:18d88659c6c1c5e131a0ce0a94d55235"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {api_key}"
|
||||
}
|
||||
|
||||
try:
|
||||
response = requests.get(file_url, headers=headers)
|
||||
response.raise_for_status()
|
||||
|
||||
# Create a response with the appropriate content type and headers
|
||||
file_response = HttpResponse(response.content, content_type='audio/mpeg')
|
||||
file_response['Content-Disposition'] = 'attachment; filename="output.mp3"'
|
||||
|
||||
return file_response
|
||||
except requests.RequestException as e:
|
||||
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST) """
|
||||
return Response({'error': str(e)}, status=status.HTTP_400_BAD_REQUEST)
|
||||
Loading…
Reference in New Issue