[videos] Add youtube scrobbling

This commit is contained in:
2024-11-05 23:32:03 -05:00
parent b65ebbe397
commit 1b95706f70
6 changed files with 108 additions and 1 deletions

View File

@ -314,6 +314,29 @@ def lastfm_import(request):
return HttpResponseRedirect(request.META.get("HTTP_REFERER"))
@csrf_exempt
@permission_classes([IsAuthenticated])
@api_view(["POST"])
def web_scrobbler_webhook(request):
post_data = request.data
logger.info(
"[web_scrobbler_webhook] called",
extra={
"post_data": post_data,
"user_id": request.user.id,
},
)
scrobble = web_scrobbler_scrobble_media(post_data, request.user.id)
if not scrobble:
return Response({}, status=status.HTTP_400_BAD_REQUEST)
logger.info(
"[jellyfin_webhook] finished",
extra={"scrobble_id": scrobble.id},
)
return Response({"scrobble_id": scrobble.id}, status=status.HTTP_200_OK)
@csrf_exempt
@permission_classes([IsAuthenticated])