mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
Added the Emby Cacher, we now cache the Emby data!
This commit is contained in:
parent
6d276a3c3d
commit
012a82ca2d
19 changed files with 441 additions and 20 deletions
|
@ -17,6 +17,7 @@ namespace Ombi.Store.Context
|
|||
DbSet<PlexContent> PlexContent { get; set; }
|
||||
DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
DatabaseFacade Database { get; }
|
||||
EntityEntry<T> Entry<T>(T entry) where T : class;
|
||||
EntityEntry<TEntity> Attach<TEntity>(TEntity entity) where TEntity : class;
|
||||
|
|
|
@ -28,7 +28,8 @@ namespace Ombi.Store.Context
|
|||
public DbSet<PlexContent> PlexContent { get; set; }
|
||||
public DbSet<PlexEpisode> PlexEpisode { get; set; }
|
||||
public DbSet<RadarrCache> RadarrCache { get; set; }
|
||||
|
||||
public DbSet<EmbyContent> EmbyContent { get; set; }
|
||||
|
||||
public DbSet<MovieRequests> MovieRequests { get; set; }
|
||||
public DbSet<TvRequests> TvRequests { get; set; }
|
||||
public DbSet<ChildRequests> ChildRequests { get; set; }
|
||||
|
|
49
src/Ombi.Store/Entities/EmbyContent.cs
Normal file
49
src/Ombi.Store/Entities/EmbyContent.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: EmbyContent.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Ombi.Store.Entities
|
||||
{
|
||||
[Table("EmbyContent")]
|
||||
public class EmbyContent : Entity
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public string EmbyId { get; set; }
|
||||
public EmbyMediaType Type { get; set; }
|
||||
public DateTime AddedAt { get; set; }
|
||||
}
|
||||
|
||||
public enum EmbyMediaType
|
||||
{
|
||||
Movie = 0,
|
||||
Series = 1,
|
||||
Music = 2
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ using Ombi.Helpers;
|
|||
namespace Ombi.Store.Migrations
|
||||
{
|
||||
[DbContext(typeof(OmbiContext))]
|
||||
[Migration("20170825114646_Inital")]
|
||||
[Migration("20170901230032_Inital")]
|
||||
partial class Inital
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
|
@ -159,6 +159,26 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("Audit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EmbyContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
|
@ -67,6 +67,23 @@ namespace Ombi.Store.Migrations
|
|||
table.PrimaryKey("PK_Audit", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmbyContent",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
AddedAt = table.Column<DateTime>(nullable: false),
|
||||
EmbyId = table.Column<string>(nullable: true),
|
||||
ProviderId = table.Column<string>(nullable: true),
|
||||
Title = table.Column<string>(nullable: true),
|
||||
Type = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmbyContent", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GlobalSettings",
|
||||
columns: table => new
|
||||
|
@ -621,6 +638,9 @@ namespace Ombi.Store.Migrations
|
|||
migrationBuilder.DropTable(
|
||||
name: "Audit");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmbyContent");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GlobalSettings");
|
||||
|
|
@ -158,6 +158,26 @@ namespace Ombi.Store.Migrations
|
|||
b.ToTable("Audit");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.EmbyContent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd();
|
||||
|
||||
b.Property<DateTime>("AddedAt");
|
||||
|
||||
b.Property<string>("EmbyId");
|
||||
|
||||
b.Property<string>("ProviderId");
|
||||
|
||||
b.Property<string>("Title");
|
||||
|
||||
b.Property<int>("Type");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("EmbyContent");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Ombi.Store.Entities.GlobalSettings", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
|
|
112
src/Ombi.Store/Repository/EmbyContentRepository.cs
Normal file
112
src/Ombi.Store/Repository/EmbyContentRepository.cs
Normal file
|
@ -0,0 +1,112 @@
|
|||
#region Copyright
|
||||
// /************************************************************************
|
||||
// Copyright (c) 2017 Jamie Rees
|
||||
// File: PlexContentRepository.cs
|
||||
// Created By: Jamie Rees
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining
|
||||
// a copy of this software and associated documentation files (the
|
||||
// "Software"), to deal in the Software without restriction, including
|
||||
// without limitation the rights to use, copy, modify, merge, publish,
|
||||
// distribute, sublicense, and/or sell copies of the Software, and to
|
||||
// permit persons to whom the Software is furnished to do so, subject to
|
||||
// the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
// ************************************************************************/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Ombi.Store.Context;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public class EmbyContentRepository : IEmbyContentRepository
|
||||
{
|
||||
|
||||
public EmbyContentRepository(IOmbiContext db)
|
||||
{
|
||||
Db = db;
|
||||
}
|
||||
|
||||
private IOmbiContext Db { get; }
|
||||
|
||||
public async Task<IEnumerable<EmbyContent>> GetAll()
|
||||
{
|
||||
return await Db.EmbyContent.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task AddRange(IEnumerable<EmbyContent> content)
|
||||
{
|
||||
Db.EmbyContent.AddRange(content);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> ContentExists(string providerId)
|
||||
{
|
||||
return await Db.EmbyContent.AnyAsync(x => x.ProviderId == providerId);
|
||||
}
|
||||
|
||||
public async Task<EmbyContent> Add(EmbyContent content)
|
||||
{
|
||||
await Db.EmbyContent.AddAsync(content);
|
||||
await Db.SaveChangesAsync();
|
||||
return content;
|
||||
}
|
||||
|
||||
public async Task<EmbyContent> Get(string providerId)
|
||||
{
|
||||
return await Db.EmbyContent.FirstOrDefaultAsync(x => x.ProviderId == providerId);
|
||||
}
|
||||
|
||||
public IQueryable<EmbyContent> Get()
|
||||
{
|
||||
return Db.EmbyContent.AsQueryable();
|
||||
}
|
||||
|
||||
public async Task<EmbyContent> GetByEmbyId(string embyId)
|
||||
{
|
||||
return await Db.EmbyContent./*Include(x => x.Seasons).*/FirstOrDefaultAsync(x => x.EmbyId == embyId);
|
||||
}
|
||||
|
||||
public async Task Update(EmbyContent existingContent)
|
||||
{
|
||||
Db.EmbyContent.Update(existingContent);
|
||||
await Db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//public IQueryable<PlexEpisode> GetAllEpisodes()
|
||||
//{
|
||||
// return Db.PlexEpisode.AsQueryable();
|
||||
//}
|
||||
|
||||
//public async Task<PlexEpisode> Add(PlexEpisode content)
|
||||
//{
|
||||
// await Db.PlexEpisode.AddAsync(content);
|
||||
// await Db.SaveChangesAsync();
|
||||
// return content;
|
||||
//}
|
||||
//public async Task<PlexEpisode> GetEpisodeByKey(int key)
|
||||
//{
|
||||
// return await Db.PlexEpisode.FirstOrDefaultAsync(x => x.Key == key);
|
||||
//}
|
||||
//public async Task AddRange(IEnumerable<PlexEpisode> content)
|
||||
//{
|
||||
// Db.PlexEpisode.AddRange(content);
|
||||
// await Db.SaveChangesAsync();
|
||||
//}
|
||||
}
|
||||
}
|
19
src/Ombi.Store/Repository/IEmbyContentRepository.cs
Normal file
19
src/Ombi.Store/Repository/IEmbyContentRepository.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Ombi.Store.Entities;
|
||||
|
||||
namespace Ombi.Store.Repository
|
||||
{
|
||||
public interface IEmbyContentRepository
|
||||
{
|
||||
Task<EmbyContent> Add(EmbyContent content);
|
||||
Task AddRange(IEnumerable<EmbyContent> content);
|
||||
Task<bool> ContentExists(string providerId);
|
||||
IQueryable<EmbyContent> Get();
|
||||
Task<EmbyContent> Get(string providerId);
|
||||
Task<IEnumerable<EmbyContent>> GetAll();
|
||||
Task<EmbyContent> GetByEmbyId(string embyId);
|
||||
Task Update(EmbyContent existingContent);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue