Skip to content

Commit 1aa42d4

Browse files
committed
updated tmdb client to support the "Watch providers" which includes Regions, add new api endpoint
1 parent 25ca2d5 commit 1aa42d4

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/nefarious/api/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
path('discover/rotten-tomatoes/media/<str:media_type>/', views.DiscoverRottenTomatoesMediaView.as_view()),
3434
path('import/media/<str:media_type>/', views.ImportMediaLibraryView.as_view()),
3535
path('genres/<str:media_type>/', views.GenresView.as_view()),
36+
path('regions/', views.RegionsView.as_view()),
3637
path('media-categories/', views.MediaCategoriesView.as_view()),
3738
path('qualities/', views.QualitiesView.as_view()),
3839
path('auth/', views.ObtainAuthTokenView.as_view()), # authenticates user and returns token

src/nefarious/api/views.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,24 @@ def get(self, request, media_type, media_id):
445445
return Response(result.videos())
446446

447447

448+
@method_decorator(gzip_page, name='dispatch')
449+
class RegionsView(views.APIView):
450+
451+
@method_decorator(cache_page(CACHE_DAY))
452+
def get(self, request):
453+
454+
nefarious_settings = NefariousSettings.get()
455+
456+
# prepare query
457+
tmdb = get_tmdb_client(nefarious_settings)
458+
watch_providers = tmdb.WatchProviders()
459+
460+
# fetch regions
461+
results = watch_providers.watch_providers_available_regions()
462+
463+
return Response(results)
464+
465+
448466
@method_decorator(gzip_page, name='dispatch')
449467
class DiscoverRottenTomatoesMediaView(views.APIView):
450468
"""

src/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ jsonfield2==3.1.0
77
redis==3.3.11
88
regex==2022.4.24
99
requests==2.22.0
10-
# tmdbsimple - forked version including languages
11-
git+https://github.com/lardbit/tmdbsimple.git
10+
# tmdbsimple - forked version including "watch providers" (e.g. regions)
11+
git+https://github.com/lardbit/tmdbsimple.git@watch-providers
1212
transmissionrpc==0.11
1313
uvicorn[standard]==0.18.1
1414
whitenoise==5.0.1

0 commit comments

Comments
 (0)