Skip to content

Commit

Permalink
updated tmdb client to support the "Watch providers" which includes R…
Browse files Browse the repository at this point in the history
…egions, add new api endpoint
  • Loading branch information
lardbit committed Sep 3, 2024
1 parent 25ca2d5 commit 1aa42d4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/nefarious/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
path('discover/rotten-tomatoes/media/<str:media_type>/', views.DiscoverRottenTomatoesMediaView.as_view()),
path('import/media/<str:media_type>/', views.ImportMediaLibraryView.as_view()),
path('genres/<str:media_type>/', views.GenresView.as_view()),
path('regions/', views.RegionsView.as_view()),
path('media-categories/', views.MediaCategoriesView.as_view()),
path('qualities/', views.QualitiesView.as_view()),
path('auth/', views.ObtainAuthTokenView.as_view()), # authenticates user and returns token
Expand Down
18 changes: 18 additions & 0 deletions src/nefarious/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,24 @@ def get(self, request, media_type, media_id):
return Response(result.videos())


@method_decorator(gzip_page, name='dispatch')
class RegionsView(views.APIView):

@method_decorator(cache_page(CACHE_DAY))
def get(self, request):

nefarious_settings = NefariousSettings.get()

# prepare query
tmdb = get_tmdb_client(nefarious_settings)
watch_providers = tmdb.WatchProviders()

# fetch regions
results = watch_providers.watch_providers_available_regions()

return Response(results)


@method_decorator(gzip_page, name='dispatch')
class DiscoverRottenTomatoesMediaView(views.APIView):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jsonfield2==3.1.0
redis==3.3.11
regex==2022.4.24
requests==2.22.0
# tmdbsimple - forked version including languages
git+https://github.com/lardbit/tmdbsimple.git
# tmdbsimple - forked version including "watch providers" (e.g. regions)
git+https://github.com/lardbit/tmdbsimple.git@watch-providers
transmissionrpc==0.11
uvicorn[standard]==0.18.1
whitenoise==5.0.1
Expand Down

0 comments on commit 1aa42d4

Please sign in to comment.