Implement episode metadata management: add functionality to refresh episode metadata from external sources, including new API endpoints and UI integration. Enhance Show and Episode models to support additional metadata fields, and update database schema accordingly. Update ShowDetail and ShowMetadataCard components to display refreshed episode information and provide user feedback on metadata updates.
This commit is contained in:
@@ -44,6 +44,43 @@ public sealed class MetadataImageStore(MediaPathResolver paths, IHttpClientFacto
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
|
||||
public async Task<string?> DownloadEpisodeStillAsync(
|
||||
Guid episodeId,
|
||||
string url,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = httpFactory.CreateClient("metadata");
|
||||
using var response = await client.GetAsync(url, cancellationToken);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var ext = ExtensionFor(url, response.Content.Headers.ContentType?.MediaType);
|
||||
var dir = paths.MetadataEpisodeDir(episodeId);
|
||||
Directory.CreateDirectory(dir);
|
||||
RemoveExisting(dir, "still");
|
||||
|
||||
var abs = paths.MetadataEpisodeStillPath(episodeId, ext);
|
||||
await using var content = await response.Content.ReadAsStreamAsync(cancellationToken);
|
||||
await using (var fs = File.Create(abs))
|
||||
await content.CopyToAsync(fs, cancellationToken);
|
||||
return paths.MetadataEpisodeStillRelative(episodeId, ext);
|
||||
}
|
||||
catch (Exception ex) when (ex is HttpRequestException or TaskCanceledException or IOException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteEpisodeImages(Guid episodeId)
|
||||
{
|
||||
var dir = paths.MetadataEpisodeDir(episodeId);
|
||||
if (Directory.Exists(dir))
|
||||
Directory.Delete(dir, recursive: true);
|
||||
}
|
||||
|
||||
public string? ResolveAbsolutePath(string relativePath)
|
||||
{
|
||||
var abs = paths.ResolveRelative(relativePath);
|
||||
|
||||
Reference in New Issue
Block a user