Split scrobble endpoints up
This commit is contained in:
@ -4,5 +4,6 @@ from scrobbles import views
|
|||||||
app_name = 'scrobbles'
|
app_name = 'scrobbles'
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.scrobble_list, name='scrobble-list'),
|
path('', views.scrobble_endpoint, name='scrobble-list'),
|
||||||
|
path('jellyfin/', views.jellyfin_websocket, name='jellyfin-websocket'),
|
||||||
]
|
]
|
||||||
|
|||||||
@ -38,15 +38,17 @@ class RecentScrobbleList(ListView):
|
|||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
@api_view(['GET', 'POST'])
|
@api_view(['GET'])
|
||||||
def scrobble_list(request):
|
def scrobble_endpoint(request):
|
||||||
"""List all Scrobbles, or create a new Scrobble"""
|
"""List all Scrobbles, or create a new Scrobble"""
|
||||||
if request.method == 'GET':
|
|
||||||
scrobble = Scrobble.objects.all()
|
scrobble = Scrobble.objects.all()
|
||||||
serializer = ScrobbleSerializer(scrobble, many=True)
|
serializer = ScrobbleSerializer(scrobble, many=True)
|
||||||
return Response(serializer.data)
|
return Response(serializer.data)
|
||||||
|
|
||||||
elif request.method == 'POST':
|
|
||||||
|
@csrf_exempt
|
||||||
|
@api_view(['POST'])
|
||||||
|
def jellyfin_websocket(request):
|
||||||
data_dict = request.data
|
data_dict = request.data
|
||||||
media_type = data_dict["ItemType"]
|
media_type = data_dict["ItemType"]
|
||||||
# Check if it's a TV Episode
|
# Check if it's a TV Episode
|
||||||
@ -58,9 +60,7 @@ def scrobble_list(request):
|
|||||||
}
|
}
|
||||||
if media_type == 'Episode':
|
if media_type == 'Episode':
|
||||||
series_name = data_dict["SeriesName"]
|
series_name = data_dict["SeriesName"]
|
||||||
series, series_created = Series.objects.get_or_create(
|
series, series_created = Series.objects.get_or_create(name=series_name)
|
||||||
name=series_name
|
|
||||||
)
|
|
||||||
|
|
||||||
video_dict['video_type'] = Video.VideoType.TV_EPISODE
|
video_dict['video_type'] = Video.VideoType.TV_EPISODE
|
||||||
video_dict["tv_series_id"] = series.id
|
video_dict["tv_series_id"] = series.id
|
||||||
|
|||||||
@ -21,10 +21,9 @@ urlpatterns = [
|
|||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("accounts/", include("allauth.urls")),
|
path("accounts/", include("allauth.urls")),
|
||||||
# path("api-auth/", include("rest_framework.urls")),
|
# path("api-auth/", include("rest_framework.urls")),
|
||||||
# path("api/v1/", include(router.urls)),
|
|
||||||
# path("movies/", include(movies, namespace="movies")),
|
# path("movies/", include(movies, namespace="movies")),
|
||||||
# path("shows/", include(shows, namespace="shows")),
|
# path("shows/", include(shows, namespace="shows")),
|
||||||
path("scrobbles/", include(scrobble_urls, namespace="scrobbles")),
|
path("api/v1/scrobbles/", include(scrobble_urls, namespace="scrobbles")),
|
||||||
path("", RecentScrobbleList.as_view(), name="home"),
|
path("", RecentScrobbleList.as_view(), name="home"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user