mirror of https://github.com/ErsatzTV/ErsatzTV.git
12 changed files with 0 additions and 218 deletions
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
namespace ErsatzTV.Application |
||||
{ |
||||
public interface IMediaCard |
||||
{ |
||||
string Title { get; } |
||||
string SortTitle { get; } |
||||
string Subtitle { get; } |
||||
} |
||||
} |
||||
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
namespace ErsatzTV.Core.AggregateModels |
||||
{ |
||||
public enum AggregateMediaItemType |
||||
{ |
||||
TelevisionShows, |
||||
TelevisionSeasons, |
||||
TelevisionEpisodes, |
||||
Movies |
||||
} |
||||
} |
||||
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
using System; |
||||
using ErsatzTV.Core.Interfaces.FFmpeg; |
||||
|
||||
namespace ErsatzTV.Core.Domain |
||||
{ |
||||
public record MediaMetadata : IDisplaySize |
||||
{ |
||||
public MetadataSource Source { get; set; } |
||||
public DateTime? LastWriteTime { get; set; } |
||||
public TimeSpan Duration { get; set; } |
||||
public string SampleAspectRatio { get; set; } |
||||
public string DisplayAspectRatio { get; set; } |
||||
public string VideoCodec { get; set; } |
||||
public string AudioCodec { get; set; } |
||||
public MediaType MediaType { get; set; } |
||||
public string Title { get; set; } |
||||
public string SortTitle { get; set; } |
||||
public string Subtitle { get; set; } |
||||
public string Description { get; set; } |
||||
public int? SeasonNumber { get; set; } |
||||
public int? EpisodeNumber { get; set; } |
||||
public string ContentRating { get; set; } |
||||
public DateTime? Aired { get; set; } |
||||
public VideoScanType VideoScanType { get; set; } |
||||
public int Width { get; set; } |
||||
public int Height { get; set; } |
||||
} |
||||
} |
||||
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
namespace ErsatzTV.Core.Domain |
||||
{ |
||||
public enum ResolutionKey |
||||
{ |
||||
None = 0, |
||||
W720H480 = 1, |
||||
W1280H720 = 2, |
||||
W1920H1080 = 3, |
||||
W3840H2160 = 4 |
||||
} |
||||
} |
||||
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Interfaces.Metadata |
||||
{ |
||||
public interface ILocalPosterProvider |
||||
{ |
||||
Task RefreshPoster(MediaItem mediaItem); |
||||
Task SavePosterToDisk(MediaItem mediaItem, string posterPath); |
||||
} |
||||
} |
||||
@ -1,10 +0,0 @@
@@ -1,10 +0,0 @@
|
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Interfaces.Metadata |
||||
{ |
||||
public interface ISmartCollectionBuilder |
||||
{ |
||||
Task<bool> RefreshSmartCollections(TelevisionEpisodeMediaItem mediaItem); |
||||
} |
||||
} |
||||
@ -1,93 +0,0 @@
@@ -1,93 +0,0 @@
|
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Linq; |
||||
using System.Threading.Tasks; |
||||
using ErsatzTV.Core.Domain; |
||||
using ErsatzTV.Core.Interfaces.Images; |
||||
using ErsatzTV.Core.Interfaces.Metadata; |
||||
using ErsatzTV.Core.Interfaces.Repositories; |
||||
using LanguageExt; |
||||
using Microsoft.Extensions.Logging; |
||||
using static LanguageExt.Prelude; |
||||
|
||||
namespace ErsatzTV.Core.Metadata |
||||
{ |
||||
public class LocalPosterProvider : ILocalPosterProvider |
||||
{ |
||||
private static readonly string[] SupportedExtensions = { "jpg", "jpeg", "png", "gif", "tbn" }; |
||||
|
||||
private readonly IImageCache _imageCache; |
||||
private readonly ILogger<LocalPosterProvider> _logger; |
||||
private readonly IMediaItemRepository _mediaItemRepository; |
||||
|
||||
public LocalPosterProvider( |
||||
IMediaItemRepository mediaItemRepository, |
||||
IImageCache imageCache, |
||||
ILogger<LocalPosterProvider> logger) |
||||
{ |
||||
_mediaItemRepository = mediaItemRepository; |
||||
_imageCache = imageCache; |
||||
_logger = logger; |
||||
} |
||||
|
||||
public async Task RefreshPoster(MediaItem mediaItem) |
||||
{ |
||||
Option<string> maybePosterPath = mediaItem switch |
||||
{ |
||||
MovieMediaItem m => RefreshMoviePoster(m), |
||||
TelevisionEpisodeMediaItem e => RefreshTelevisionPoster(e), |
||||
_ => None |
||||
}; |
||||
|
||||
await maybePosterPath.Match( |
||||
path => SavePosterToDisk(mediaItem, path), |
||||
Task.CompletedTask); |
||||
} |
||||
|
||||
public async Task SavePosterToDisk(MediaItem mediaItem, string posterPath) |
||||
{ |
||||
byte[] originalBytes = await File.ReadAllBytesAsync(posterPath); |
||||
Either<BaseError, string> maybeHash = await _imageCache.ResizeAndSaveImage(originalBytes, 220, null); |
||||
await maybeHash.Match( |
||||
hash => |
||||
{ |
||||
mediaItem.Poster = hash; |
||||
return _mediaItemRepository.Update(mediaItem); |
||||
}, |
||||
error => |
||||
{ |
||||
_logger.LogWarning("Unable to save poster to disk from {Path}: {Error}", posterPath, error.Value); |
||||
return Task.CompletedTask; |
||||
}); |
||||
} |
||||
|
||||
private static Option<string> RefreshMoviePoster(MediaItem mediaItem) |
||||
{ |
||||
string folder = Path.GetDirectoryName(mediaItem.Path); |
||||
if (folder != null) |
||||
{ |
||||
IEnumerable<string> possiblePaths = SupportedExtensions.Collect( |
||||
e => new[] { $"poster.{e}", Path.GetFileNameWithoutExtension(mediaItem.Path) + $"-poster.{e}" }); |
||||
Option<string> maybePoster = |
||||
possiblePaths.Map(p => Path.Combine(folder, p)).FirstOrDefault(File.Exists); |
||||
return maybePoster; |
||||
} |
||||
|
||||
return None; |
||||
} |
||||
|
||||
private Option<string> RefreshTelevisionPoster(MediaItem mediaItem) |
||||
{ |
||||
string folder = Directory.GetParent(Path.GetDirectoryName(mediaItem.Path) ?? string.Empty)?.FullName; |
||||
if (folder != null) |
||||
{ |
||||
IEnumerable<string> possiblePaths = SupportedExtensions.Collect(e => new[] { $"poster.{e}" }); |
||||
Option<string> maybePoster = |
||||
possiblePaths.Map(p => Path.Combine(folder, p)).FirstOrDefault(File.Exists); |
||||
return maybePoster; |
||||
} |
||||
|
||||
return None; |
||||
} |
||||
} |
||||
} |
||||
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Scheduling |
||||
{ |
||||
public class TelevisionSeasonMediaCollection : MediaCollection |
||||
{ |
||||
public int TelevisionSeasonId { get; set; } |
||||
} |
||||
} |
||||
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
using ErsatzTV.Core.Domain; |
||||
|
||||
namespace ErsatzTV.Core.Scheduling |
||||
{ |
||||
public class TelevisionShowMediaCollection : MediaCollection |
||||
{ |
||||
public int TelevisionShowId { get; set; } |
||||
} |
||||
} |
||||
Loading…
Reference in new issue