mirror of https://github.com/Ombi-app/Ombi
refactor(newsletter): ♻️ Media servers + newsletter refactoring (#4463)
* Abstract media servers content into interfaces * Media server entities into abstract classes * Abstract media server content repository * First pass at newsletter refactoring * Minor code clean up * Attempt at abstracting repositories (WIP) * Fixed cast issue * Corrected the other properties * A step towards newsletter refactoring * Clean up leftovers * Fix broken episodes db interaction * Save absolute URL for Plex content Let's be consistent with Emby and Jellyfin * Fix broken integration with Plex libraries * Fix error when multiple media servers configured * Fix newsletter being sent if no movies or episodes * Fix broken tests * Remove unneccesary logs * Expose stored media server URL No need to recalculate it + Plex URL was broken due to an earlier change * Remove unused variable * Remove obsolete tests URLs are now fetched from database directly * Retro-compatibility for Plex content URL Solves URL for media synced before absolute URL was saved in PlexServerContent * chore: added some obsoletes * fix: removed the unsub link when not present Co-authored-by: tidusjar <tidusjar@gmail.com>pull/4485/head
parent
32ee4e88ec
commit
0ff0a704ff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public interface IEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public interface IMediaServerContent: IEntity
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public string TvDbId { get; set; }
|
||||
public string TheMovieDbId { get; set; }
|
||||
public MediaType Type { get; set; }
|
||||
public RecentlyAddedType RecentlyAddedType{ get; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public ICollection<IMediaServerEpisode> Episodes { get; set; }
|
||||
|
||||
public DateTime AddedAt { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public bool HasImdb => !string.IsNullOrEmpty(ImdbId);
|
||||
|
||||
[NotMapped]
|
||||
public bool HasTvDb => !string.IsNullOrEmpty(TvDbId);
|
||||
|
||||
[NotMapped]
|
||||
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
|
||||
}
|
||||
|
||||
public interface IMediaServerEpisode
|
||||
{
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// The Season key
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The parent key.
|
||||
/// </value>
|
||||
|
||||
|
||||
public IMediaServerContent Series { get; set; }
|
||||
public IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent> content);
|
||||
public bool IsIn(IMediaServerContent content);
|
||||
}
|
||||
|
||||
public enum MediaType
|
||||
{
|
||||
Movie = 0,
|
||||
Series = 1,
|
||||
Music = 2,
|
||||
Episode = 3
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Ombi.Store.Repository;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
public abstract class MediaServerContent: Entity, IMediaServerContent
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ImdbId { get; set; }
|
||||
public string TvDbId { get; set; }
|
||||
public string TheMovieDbId { get; set; }
|
||||
public MediaType Type { get; set; }
|
||||
|
||||
public string Url { get; set; }
|
||||
|
||||
public ICollection<IMediaServerEpisode> Episodes { get; set; }
|
||||
|
||||
public DateTime AddedAt { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public bool HasImdb => !string.IsNullOrEmpty(ImdbId);
|
||||
|
||||
[NotMapped]
|
||||
public bool HasTvDb => !string.IsNullOrEmpty(TvDbId);
|
||||
|
||||
[NotMapped]
|
||||
public bool HasTheMovieDb => !string.IsNullOrEmpty(TheMovieDbId);
|
||||
|
||||
[NotMapped]
|
||||
public abstract RecentlyAddedType RecentlyAddedType { get; }
|
||||
}
|
||||
|
||||
public abstract class MediaServerEpisode: Entity, IMediaServerEpisode
|
||||
{
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int SeasonNumber { get; set; }
|
||||
public string Title { get; set; }
|
||||
|
||||
public IMediaServerContent Series { get; set; }
|
||||
|
||||
public abstract IMediaServerContent SeriesIsIn(ICollection<IMediaServerContent> content);
|
||||
public abstract bool IsIn(IMediaServerContent content);
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public abstract class MediaServerContentRepository<T> : ExternalRepository<T>, IMediaServerContentRepository<T> where T : MediaServerContent
|
||||
{
|
||||
protected ExternalContext Db { get; }
|
||||
public abstract RecentlyAddedType RecentlyAddedType { get; }
|
||||
|
||||
public MediaServerContentRepository(ExternalContext db) : base(db)
|
||||
{
|
||||
Db = db;
|
||||
}
|
||||
|
||||
public abstract Task Update(IMediaServerContent existingContent);
|
||||
public abstract IQueryable<IMediaServerEpisode> GetAllEpisodes();
|
||||
public abstract Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
|
||||
public abstract Task AddRange(IEnumerable<IMediaServerEpisode> content);
|
||||
public abstract void UpdateWithoutSave(IMediaServerContent existingContent);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue