Skip to content

Commit

Permalink
Merge pull request #76 from Pouleyy/feat/add-getposter
Browse files Browse the repository at this point in the history
Add a get poster method
  • Loading branch information
jensenkd committed Jul 31, 2022
2 parents ced7758 + 5db4ab3 commit 4d6bda0
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Source/Plex.Library/ApiModels/Servers/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -636,5 +636,13 @@ public async Task RefreshSync()
/// <returns>A <see cref="MediaContainer"/> containing the media info.</returns>
public async Task<MediaContainer> Metadata(string ratingKey) =>
await this.plexServerClient.GetMediaMetadataAsync(this.AccessToken, this.Uri.ToString(), ratingKey);

/// <summary>
/// Get poster for a given rating key.
/// </summary>
/// <param name="ratingKey">The rating key to get poster from.</param>
/// <returns>A <see cref="MediaContainer"/> containing the media info.</returns>
public async Task<MediaContainer> Posters(string ratingKey) =>
await this.plexServerClient.GetMediaPosterAsync(this.AccessToken, this.Uri.ToString(), ratingKey);
}
}
9 changes: 9 additions & 0 deletions Source/Plex.ServerApi/Clients/Interfaces/IPlexServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,15 @@ public interface IPlexServerClient
/// <returns>A <see cref="Task"/> representing the asynchronous operation.</returns>
Task<MediaContainer> GetChildrenMetadataAsync(string authToken, string plexServerHost, int id);

/// <summary>
/// Get posters for a given Plex rating key.
/// </summary>
/// <param name="authToken">Authentication Token.</param>
/// <param name="plexServerHost">Plex Host Uri.</param>
/// <param name="key">Rating Key.</param>
/// <returns></returns>
Task<MediaContainer> GetMediaPosterAsync(string authToken, string plexServerHost, string key);

/// <summary>
/// Marks the Item in plex as 'Played'.
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions Source/Plex.ServerApi/Clients/PlexServerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ public async Task<MediaContainer> GetChildrenMetadataAsync(string authToken, str
// return plexMediaContainer;
}

/// <inheritdoc/>
public async Task<MediaContainer> GetMediaPosterAsync(string authToken, string plexServerHost, string key) => await this.FetchWithWrapper<MediaContainer>(plexServerHost, $"library/metadata/{key}/posters", authToken, HttpMethod.Get);

/// <inheritdoc/>
public async Task<PlexServer> GetPlexServerInfo(string authToken, string plexServerHost)
{
Expand Down
6 changes: 6 additions & 0 deletions Source/Plex.ServerApi/PlexModels/Media/Metadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ public class Metadata
[JsonPropertyName("thumb")]
public string Thumb { get; set; }

[JsonPropertyName("selected")]
public bool Selected { get; set; }

[JsonPropertyName("provider")]
public string Provider { get; set; }

[JsonPropertyName("art")]
public string Art { get; set; }

Expand Down

0 comments on commit 4d6bda0

Please sign in to comment.