mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-22 06:13:22 -07:00
Add a toggle to activate played sync
This commit is contained in:
parent
77ce52e68a
commit
925fcd12c7
6 changed files with 72 additions and 12 deletions
|
@ -8,10 +8,12 @@ using Ombi.Api.Emby;
|
||||||
using Ombi.Api.Emby.Models;
|
using Ombi.Api.Emby.Models;
|
||||||
using Ombi.Api.Emby.Models.Media.Tv;
|
using Ombi.Api.Emby.Models.Media.Tv;
|
||||||
using Ombi.Api.Emby.Models.Movie;
|
using Ombi.Api.Emby.Models.Movie;
|
||||||
|
using Ombi.Core.Services;
|
||||||
using Ombi.Core.Settings;
|
using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Helpers;
|
using Ombi.Helpers;
|
||||||
using Ombi.Hubs;
|
using Ombi.Hubs;
|
||||||
|
using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
using Quartz;
|
using Quartz;
|
||||||
|
@ -21,14 +23,20 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
{
|
{
|
||||||
public class EmbyContentSync : EmbyLibrarySync, IEmbyContentSync
|
public class EmbyContentSync : EmbyLibrarySync, IEmbyContentSync
|
||||||
{
|
{
|
||||||
public EmbyContentSync(ISettingsService<EmbySettings> settings, IEmbyApiFactory api, ILogger<EmbyContentSync> logger,
|
public EmbyContentSync(
|
||||||
IEmbyContentRepository repo, INotificationHubService notification):
|
ISettingsService<EmbySettings> settings,
|
||||||
|
IEmbyApiFactory api,
|
||||||
|
ILogger<EmbyContentSync> logger,
|
||||||
|
IEmbyContentRepository repo,
|
||||||
|
INotificationHubService notification,
|
||||||
|
IFeatureService feature):
|
||||||
base(settings, api, logger, notification)
|
base(settings, api, logger, notification)
|
||||||
{
|
{
|
||||||
_repo = repo;
|
_repo = repo;
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly IEmbyContentRepository _repo;
|
private readonly IEmbyContentRepository _repo;
|
||||||
|
private readonly IFeatureService _feature;
|
||||||
|
|
||||||
|
|
||||||
public async override Task Execute(IJobExecutionContext context)
|
public async override Task Execute(IJobExecutionContext context)
|
||||||
|
@ -38,6 +46,13 @@ namespace Ombi.Schedule.Jobs.Emby
|
||||||
|
|
||||||
// Episodes
|
// Episodes
|
||||||
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyEpisodeSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAdded.ToString() } }));
|
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyEpisodeSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAdded.ToString() } }));
|
||||||
|
|
||||||
|
// Played state
|
||||||
|
var isPlayedSyncEnabled = await _feature.FeatureEnabled(FeatureNames.PlayedSync);
|
||||||
|
if(isPlayedSyncEnabled)
|
||||||
|
{
|
||||||
|
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyPlayedSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAdded.ToString() } }));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,15 +15,22 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
public class MediaDatabaseRefresh : IMediaDatabaseRefresh
|
public class MediaDatabaseRefresh : IMediaDatabaseRefresh
|
||||||
{
|
{
|
||||||
public MediaDatabaseRefresh(ISettingsService<PlexSettings> s, ILogger<MediaDatabaseRefresh> log,
|
public MediaDatabaseRefresh(
|
||||||
IPlexContentRepository plexRepo, IEmbyContentRepository embyRepo, IJellyfinContentRepository jellyfinRepo,
|
ISettingsService<PlexSettings> s,
|
||||||
ISettingsService<EmbySettings> embySettings, ISettingsService<JellyfinSettings> jellyfinSettings)
|
ILogger<MediaDatabaseRefresh> log,
|
||||||
|
IPlexContentRepository plexRepo,
|
||||||
|
IEmbyContentRepository embyRepo,
|
||||||
|
IJellyfinContentRepository jellyfinRepo,
|
||||||
|
IUserPlayedMovieRepository userPlayedRepo,
|
||||||
|
ISettingsService<EmbySettings> embySettings,
|
||||||
|
ISettingsService<JellyfinSettings> jellyfinSettings)
|
||||||
{
|
{
|
||||||
_plexSettings = s;
|
_plexSettings = s;
|
||||||
_log = log;
|
_log = log;
|
||||||
_plexRepo = plexRepo;
|
_plexRepo = plexRepo;
|
||||||
_embyRepo = embyRepo;
|
_embyRepo = embyRepo;
|
||||||
_jellyfinRepo = jellyfinRepo;
|
_jellyfinRepo = jellyfinRepo;
|
||||||
|
_userPlayedRepo = userPlayedRepo;
|
||||||
_embySettings = embySettings;
|
_embySettings = embySettings;
|
||||||
_jellyfinSettings = jellyfinSettings;
|
_jellyfinSettings = jellyfinSettings;
|
||||||
_plexSettings.ClearCache();
|
_plexSettings.ClearCache();
|
||||||
|
@ -34,6 +41,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
private readonly IPlexContentRepository _plexRepo;
|
private readonly IPlexContentRepository _plexRepo;
|
||||||
private readonly IEmbyContentRepository _embyRepo;
|
private readonly IEmbyContentRepository _embyRepo;
|
||||||
private readonly IJellyfinContentRepository _jellyfinRepo;
|
private readonly IJellyfinContentRepository _jellyfinRepo;
|
||||||
|
private readonly IUserPlayedMovieRepository _userPlayedRepo;
|
||||||
private readonly ISettingsService<EmbySettings> _embySettings;
|
private readonly ISettingsService<EmbySettings> _embySettings;
|
||||||
private readonly ISettingsService<JellyfinSettings> _jellyfinSettings;
|
private readonly ISettingsService<JellyfinSettings> _jellyfinSettings;
|
||||||
|
|
||||||
|
@ -41,6 +49,7 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
await RemovePlayedData();
|
||||||
await RemovePlexData();
|
await RemovePlexData();
|
||||||
await RemoveEmbyData();
|
await RemoveEmbyData();
|
||||||
await RemoveJellyfinData();
|
await RemoveJellyfinData();
|
||||||
|
@ -52,6 +61,20 @@ namespace Ombi.Schedule.Jobs.Ombi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task RemovePlayedData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
const string movieSql = "DELETE FROM UserPlayedMovie";
|
||||||
|
await _userPlayedRepo.ExecuteSql(movieSql);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_log.LogError(LoggingEvents.MediaReferesh, e, "Refreshing Played Data Failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task RemoveEmbyData()
|
private async Task RemoveEmbyData()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
@ -21,5 +21,6 @@ namespace Ombi.Settings.Settings.Models
|
||||||
{
|
{
|
||||||
public const string Movie4KRequests = nameof(Movie4KRequests);
|
public const string Movie4KRequests = nameof(Movie4KRequests);
|
||||||
public const string OldTrendingSource = nameof(OldTrendingSource);
|
public const string OldTrendingSource = nameof(OldTrendingSource);
|
||||||
|
public const string PlayedSync = nameof(PlayedSync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,11 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
public dataSource: MatTableDataSource<IMovieRequests>;
|
public dataSource: MatTableDataSource<IMovieRequests>;
|
||||||
public resultsLength: number;
|
public resultsLength: number;
|
||||||
public isLoadingResults = true;
|
public isLoadingResults = true;
|
||||||
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate', 'watchedByRequestedUser', 'actions'];
|
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate'];
|
||||||
public gridCount: string = "15";
|
public gridCount: string = "15";
|
||||||
public isAdmin: boolean;
|
public isAdmin: boolean;
|
||||||
public is4kEnabled = false;
|
public is4kEnabled = false;
|
||||||
|
public isPlayedSyncEnabled = false;
|
||||||
public manageOwnRequests: boolean;
|
public manageOwnRequests: boolean;
|
||||||
public defaultSort: string = "requestedDate";
|
public defaultSort: string = "requestedDate";
|
||||||
public defaultOrder: string = "desc";
|
public defaultOrder: string = "desc";
|
||||||
|
@ -65,10 +66,9 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.is4kEnabled = this.featureFacade.is4kEnabled();
|
this.is4kEnabled = this.featureFacade.is4kEnabled();
|
||||||
if ((this.isAdmin || this.auth.hasRole("Request4KMovie"))
|
this.isPlayedSyncEnabled = this.featureFacade.isPlayedSyncEnabled();
|
||||||
&& this.is4kEnabled) {
|
|
||||||
this.displayedColumns.splice(4, 0, 'has4kRequest');
|
this.addDynamicColumns();
|
||||||
}
|
|
||||||
|
|
||||||
const defaultCount = this.storageService.get(this.storageKeyGridCount);
|
const defaultCount = this.storageService.get(this.storageKeyGridCount);
|
||||||
const defaultSort = this.storageService.get(this.storageKey);
|
const defaultSort = this.storageService.get(this.storageKey);
|
||||||
|
@ -88,6 +88,20 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDynamicColumns() {
|
||||||
|
if ((this.isAdmin || this.auth.hasRole("Request4KMovie"))
|
||||||
|
&& this.is4kEnabled) {
|
||||||
|
this.displayedColumns.splice(4, 0, 'has4kRequest');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isPlayedSyncEnabled) {
|
||||||
|
this.displayedColumns.push('watchedByRequestedUser');
|
||||||
|
}
|
||||||
|
|
||||||
|
// always put the actions column at the end
|
||||||
|
this.displayedColumns.push('actions');
|
||||||
|
}
|
||||||
|
|
||||||
public async ngAfterViewInit() {
|
public async ngAfterViewInit() {
|
||||||
|
|
||||||
this.storageService.save(this.storageKeyGridCount, this.gridCount);
|
this.storageService.save(this.storageKeyGridCount, this.gridCount);
|
||||||
|
|
|
@ -23,4 +23,6 @@ export class FeaturesFacade {
|
||||||
|
|
||||||
public is4kEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.is4kEnabled);
|
public is4kEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.is4kEnabled);
|
||||||
|
|
||||||
|
public isPlayedSyncEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.isPlayedSyncEnabled);
|
||||||
|
|
||||||
}
|
}
|
|
@ -15,4 +15,9 @@ export class FeaturesSelectors {
|
||||||
return features.filter(x => x.name === "Movie4KRequests")[0].enabled;
|
return features.filter(x => x.name === "Movie4KRequests")[0].enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Selector([FeaturesSelectors.features])
|
||||||
|
public static isPlayedSyncEnabled(features: IFeatureEnablement[]): boolean {
|
||||||
|
return features.filter(x => x.name === "PlayedSync")[0].enabled;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue