forked from jellyfin/TMDbLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request jellyfin#406 from TheUltimateC0der/feature/watchpr…
…oviders Implemented Watch Providers endpoints
- Loading branch information
Showing
7 changed files
with
5,477 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using TMDbLib.Objects.General; | ||
using TMDbLib.Rest; | ||
|
||
namespace TMDbLib.Client | ||
{ | ||
public partial class TMDbClient | ||
{ | ||
/// <summary> | ||
/// Returns a list of all of the countries TMDb has watch provider (OTT/streaming) data for. | ||
/// </summary> | ||
/// <param name="cancellationToken">A cancellation token</param> | ||
/// <remarks>Uses <see cref="DefaultLanguage"/> to translate data</remarks> | ||
public async Task<ResultContainer<WatchProviderRegion>> GetWatchProviderRegionsAsync(CancellationToken cancellationToken = default) | ||
{ | ||
RestRequest req = _client.Create("watch/providers/regions"); | ||
if (DefaultLanguage != null) | ||
req.AddParameter("language", DefaultLanguage); | ||
|
||
ResultContainer<WatchProviderRegion> response = await req.GetOfT<ResultContainer<WatchProviderRegion>>(cancellationToken).ConfigureAwait(false); | ||
|
||
return response; | ||
} | ||
|
||
/// <summary> | ||
/// Returns a list of the watch provider (OTT/streaming) data TMDb has available for movies. | ||
/// </summary> | ||
/// <param name="cancellationToken">A cancellation token</param> | ||
/// <remarks>Uses <see cref="DefaultCountry"/> and <see cref="DefaultLanguage"/> to filter or translate data</remarks> | ||
public async Task<ResultContainer<WatchProviderItem>> GetMovieWatchProvidersAsync(CancellationToken cancellationToken = default) | ||
{ | ||
RestRequest req = _client.Create("watch/providers/movie"); | ||
if (DefaultLanguage != null) | ||
req.AddParameter("language", DefaultLanguage); | ||
|
||
if (DefaultCountry != null) | ||
req.AddParameter("watch_region", DefaultCountry); | ||
|
||
ResultContainer<WatchProviderItem> response = await req.GetOfT<ResultContainer<WatchProviderItem>>(cancellationToken).ConfigureAwait(false); | ||
|
||
return response; | ||
} | ||
|
||
/// <summary> | ||
/// Returns a list of the watch provider (OTT/streaming) data TMDb has available for shows. | ||
/// </summary> | ||
/// <param name="cancellationToken">A cancellation token</param> | ||
/// <remarks>Uses <see cref="DefaultCountry"/> and <see cref="DefaultLanguage"/> to filter or translate data</remarks> | ||
public async Task<ResultContainer<WatchProviderItem>> GetTvWatchProvidersAsync(CancellationToken cancellationToken = default) | ||
{ | ||
RestRequest req = _client.Create("watch/providers/tv"); | ||
if (DefaultLanguage != null) | ||
req.AddParameter("language", DefaultLanguage); | ||
|
||
if (DefaultCountry != null) | ||
req.AddParameter("watch_region", DefaultCountry); | ||
|
||
ResultContainer<WatchProviderItem> response = await req.GetOfT<ResultContainer<WatchProviderItem>>(cancellationToken).ConfigureAwait(false); | ||
|
||
return response; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace TMDbLib.Objects.General | ||
{ | ||
public class WatchProviderRegion | ||
{ | ||
/// <summary> | ||
/// A country code, e.g. US | ||
/// </summary> | ||
[JsonProperty("iso_3166_1")] | ||
public string Iso_3166_1 { get; set; } | ||
|
||
[JsonProperty("english_name")] | ||
public string EnglishName { get; set; } | ||
|
||
[JsonProperty("native_name")] | ||
public string NativeName { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System.Threading.Tasks; | ||
using TMDbLib.Objects.General; | ||
using TMDbLibTests.JsonHelpers; | ||
using Xunit; | ||
|
||
namespace TMDbLibTests | ||
{ | ||
public class ClientWatchProvidersTests : TestBase | ||
{ | ||
[Fact] | ||
public async Task TestGetRegions() | ||
{ | ||
ResultContainer<WatchProviderRegion> watchProviderRegions = await TMDbClient.GetWatchProviderRegionsAsync(); | ||
|
||
await Verify(watchProviderRegions); | ||
} | ||
|
||
[Fact] | ||
public async Task TestGetMovieWatchProviders() | ||
{ | ||
ResultContainer<WatchProviderItem> watchProviders = await TMDbClient.GetMovieWatchProvidersAsync(); | ||
|
||
await Verify(watchProviders); | ||
} | ||
|
||
[Fact] | ||
public async Task TestGetTvWatchProviders() | ||
{ | ||
ResultContainer<WatchProviderItem> watchProviders = await TMDbClient.GetTvWatchProvidersAsync(); | ||
|
||
await Verify(watchProviders); | ||
} | ||
} | ||
} |
Oops, something went wrong.