Ejemplo n.º 1
0
 public EmbyEpisodeSync(ISettingsService <EmbySettings> s, IEmbyApi api, ILogger <EmbyEpisodeSync> l, IEmbyContentRepository repo)
 {
     _api      = api;
     _logger   = l;
     _settings = s;
     _repo     = repo;
 }
Ejemplo n.º 2
0
        public UserManagementModule(ISettingsService <PlexRequestSettings> pr, ICustomUserMapper m, IPlexApi plexApi, ISettingsService <PlexSettings> plex, IRepository <UserLogins> userLogins, IExternalUserRepository <PlexUsers> plexRepo
                                    , ISecurityExtensions security, IRequestService req, IAnalytics ana, ISettingsService <EmbySettings> embyService, IEmbyApi embyApi, IExternalUserRepository <EmbyUsers> embyRepo) : base("usermanagement", pr, security)
        {
#if !DEBUG
            Before += (ctx) => Security.AdminLoginRedirect(Permissions.Administrator, ctx);
#endif
            UserMapper          = m;
            PlexApi             = plexApi;
            PlexSettings        = plex;
            UserLoginsRepo      = userLogins;
            PlexUsersRepository = plexRepo;
            PlexRequestSettings = pr;
            RequestService      = req;
            Analytics           = ana;
            EmbySettings        = embyService;
            EmbyApi             = embyApi;
            EmbyRepository      = embyRepo;

            Get["/"] = x => Load();

            Get["/users", true] = async(x, ct) => await LoadUsers();

            Post["/createuser", true] = async(x, ct) => await CreateUser();

            Get["/local/{id}"]      = x => LocalDetails((Guid)x.id);
            Get["/plex/{id}", true] = async(x, ct) => await PlexDetails(x.id);

            Get["/permissions"]       = x => GetEnum <Permissions>();
            Get["/features"]          = x => GetEnum <Features>();
            Post["/updateuser", true] = async(x, ct) => await UpdateUser();

            Post["/deleteuser"] = x => DeleteUser();
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TesterController" /> class.
 /// </summary>
 public TesterController(INotificationService service, IDiscordNotification notification, IEmailNotification emailN,
                         IPushbulletNotification pushbullet, ISlackNotification slack, IPushoverNotification po, IMattermostNotification mm,
                         IPlexApi plex, IEmbyApi emby, IRadarrApi radarr, ISonarrApi sonarr, ILogger <TesterController> log, IEmailProvider provider,
                         ICouchPotatoApi cpApi, ITelegramNotification telegram, ISickRageApi srApi, INewsletterJob newsletter, IMobileNotification mobileNotification,
                         ILidarrApi lidarrApi, IGotifyNotification gotifyNotification)
 {
     Service                = service;
     DiscordNotification    = notification;
     EmailNotification      = emailN;
     PushbulletNotification = pushbullet;
     SlackNotification      = slack;
     PushoverNotification   = po;
     MattermostNotification = mm;
     PlexApi                = plex;
     RadarrApi              = radarr;
     EmbyApi                = emby;
     SonarrApi              = sonarr;
     Log                  = log;
     EmailProvider        = provider;
     CouchPotatoApi       = cpApi;
     TelegramNotification = telegram;
     SickRageApi          = srApi;
     Newsletter           = newsletter;
     MobileNotification   = mobileNotification;
     LidarrApi            = lidarrApi;
     GotifyNotification   = gotifyNotification;
 }
Ejemplo n.º 4
0
        public async Task Execute(IJobExecutionContext job)
        {
            var settings = await _settings.GetSettingsAsync();

            Api = _apiFactory.CreateClient(settings);
            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Started");

            foreach (var server in settings.Servers)
            {
                if (server.EmbySelectedLibraries.Any() && server.EmbySelectedLibraries.Any(x => x.Enabled))
                {
                    var tvLibsToFilter = server.EmbySelectedLibraries.Where(x => x.Enabled && x.CollectionType == "tvshows");
                    foreach (var tvParentIdFilter in tvLibsToFilter)
                    {
                        _logger.LogInformation($"Scanning Lib for episodes '{tvParentIdFilter.Title}'");
                        await CacheEpisodes(server, tvParentIdFilter.Key);
                    }
                }
                else
                {
                    await CacheEpisodes(server, string.Empty);
                }
            }

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Finished");

            _logger.LogInformation("Emby Episode Sync Finished - Triggering Metadata refresh");
            await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
        }
Ejemplo n.º 5
0
    public async Task <Either <BaseError, List <EmbyCollection> > > GetCollectionLibraryItems(string address, string apiKey)
    {
        try
        {
            // TODO: should we enumerate collection libraries here?

            if (_memoryCache.TryGetValue("emby_collections_library_item_id", out string itemId))
            {
                IEmbyApi service = RestService.For <IEmbyApi>(address);
                EmbyLibraryItemsResponse items = await service.GetCollectionLibraryItems(apiKey, itemId);

                return(items.Items
                       .Map(ProjectToCollection)
                       .Somes()
                       .ToList());
            }

            return(BaseError.New("Emby collection item id is not available"));
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error getting Emby collection library items");
            return(BaseError.New(ex.Message));
        }
    }
Ejemplo n.º 6
0
        public ApplicationTesterModule(ICouchPotatoApi cpApi, ISonarrApi sonarrApi, IPlexApi plexApi,
                                       ISickRageApi srApi, IHeadphonesApi hpApi, ISettingsService <PlexRequestSettings> pr, ISecurityExtensions security,
                                       IWatcherApi watcherApi, IRadarrApi radarrApi, IEmbyApi emby) : base("test", pr, security)
        {
            this.RequiresAuthentication();

            CpApi         = cpApi;
            SonarrApi     = sonarrApi;
            PlexApi       = plexApi;
            SickRageApi   = srApi;
            HeadphonesApi = hpApi;
            WatcherApi    = watcherApi;
            RadarrApi     = radarrApi;
            Emby          = emby;

            Post["/cp"]         = _ => CouchPotatoTest();
            Post["/sonarr"]     = _ => SonarrTest();
            Post["/radarr"]     = _ => RadarrTest();
            Post["/plex"]       = _ => PlexTest();
            Post["/sickrage"]   = _ => SickRageTest();
            Post["/headphones"] = _ => HeadphonesTest();
            Post["/plexdb"]     = _ => TestPlexDb();
            Post["/watcher"]    = _ => WatcherTest();
            Post["/emby"]       = _ => EmbyTest();
        }
Ejemplo n.º 7
0
 public EmbyContentSync(ISettingsService <EmbySettings> settings, IEmbyApi api, ILogger <EmbyContentSync> logger,
                        IEmbyContentRepository repo)
 {
     _logger   = logger;
     _settings = settings;
     _api      = api;
     _repo     = repo;
 }
Ejemplo n.º 8
0
 public LandingPageController(ISettingsService <PlexSettings> plex, ISettingsService <EmbySettings> emby,
                              IPlexApi plexApi, IEmbyApi embyApi)
 {
     _plexSettings = plex;
     _embySettings = emby;
     _plexApi      = plexApi;
     _embyApi      = embyApi;
 }
Ejemplo n.º 9
0
 public EmbyNotificationEngine(IEmbyApi p, IRepository <UsersToNotify> repo, ISettingsService <EmbySettings> embySettings, INotificationService service, IUserHelper userHelper, IExternalUserRepository <EmbyUsers> embyUsers)
 {
     EmbyApi        = p;
     UserNotifyRepo = repo;
     Notification   = service;
     UserHelper     = userHelper;
     EmbySettings   = embySettings;
     EmbyUserRepo   = embyUsers;
 }
Ejemplo n.º 10
0
 public EmbyEpisodeSync(ISettingsService <EmbySettings> s, IEmbyApi api, ILogger <EmbyEpisodeSync> l, IEmbyContentRepository repo,
                        IEmbyAvaliabilityChecker checker)
 {
     _api                 = api;
     _logger              = l;
     _settings            = s;
     _repo                = repo;
     _avaliabilityChecker = checker;
 }
Ejemplo n.º 11
0
 public EmbyUserImporter(IEmbyApi api, UserManager <OmbiUser> um, ILogger <EmbyUserImporter> log,
                         ISettingsService <EmbySettings> embySettings, ISettingsService <UserManagementSettings> ums)
 {
     _api                    = api;
     _userManager            = um;
     _log                    = log;
     _embySettings           = embySettings;
     _userManagementSettings = ums;
 }
Ejemplo n.º 12
0
 public EmbyContentSync(ISettingsService <EmbySettings> settings, IEmbyApi api, ILogger <EmbyContentSync> logger,
                        IEmbyContentRepository repo, IEmbyEpisodeSync epSync)
 {
     _logger      = logger;
     _settings    = settings;
     _api         = api;
     _repo        = repo;
     _episodeSync = epSync;
     _settings.ClearCache();
 }
Ejemplo n.º 13
0
 public EmbyContentSync(ISettingsService <EmbySettings> settings, IEmbyApi api, ILogger <EmbyContentSync> logger,
                        IEmbyContentRepository repo, IEmbyEpisodeSync epSync, IRefreshMetadata metadata)
 {
     _logger      = logger;
     _settings    = settings;
     _api         = api;
     _repo        = repo;
     _episodeSync = epSync;
     _metadata    = metadata;
 }
Ejemplo n.º 14
0
 public EmbyEpisodeCacher(ISettingsService <EmbySettings> embySettings, IEmbyApi emby, ICacheProvider cache,
                          IJobRecord rec, IRepository <EmbyEpisodes> repo, ISettingsService <ScheduledJobsSettings> jobs)
 {
     Emby    = embySettings;
     EmbyApi = emby;
     Cache   = cache;
     Job     = rec;
     Repo    = repo;
     Jobs    = jobs;
 }
Ejemplo n.º 15
0
 public EmbyContentCacher(ISettingsService <EmbySettings> embySettings, IRequestService request, IEmbyApi emby, ICacheProvider cache,
                          IJobRecord rec, IRepository <EmbyEpisodes> repo, IRepository <EmbyContent> content)
 {
     Emby           = embySettings;
     RequestService = request;
     EmbyApi        = emby;
     Cache          = cache;
     Job            = rec;
     EpisodeRepo    = repo;
     EmbyContent    = content;
 }
Ejemplo n.º 16
0
 public EmbyUserChecker(IExternalUserRepository <EmbyUsers> plexUsers, IEmbyApi embyApi, IJobRecord rec, ISettingsService <EmbySettings> embyS, ISettingsService <PlexRequestSettings> prSettings, ISettingsService <UserManagementSettings> umSettings,
                        IRequestService requestService, IUserRepository localUser)
 {
     Repo                   = plexUsers;
     JobRecord              = rec;
     EmbyApi                = embyApi;
     EmbySettings           = embyS;
     PlexRequestSettings    = prSettings;
     UserManagementSettings = umSettings;
     RequestService         = requestService;
     LocalUserRepository    = localUser;
 }
Ejemplo n.º 17
0
 public OmbiUserManager(IUserStore <OmbiUser> store, IOptions <IdentityOptions> optionsAccessor,
                        IPasswordHasher <OmbiUser> passwordHasher, IEnumerable <IUserValidator <OmbiUser> > userValidators,
                        IEnumerable <IPasswordValidator <OmbiUser> > passwordValidators, ILookupNormalizer keyNormalizer,
                        IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager <OmbiUser> > logger, IPlexApi plexApi,
                        IEmbyApi embyApi, ISettingsService <EmbySettings> embySettings, ISettingsService <AuthenticationSettings> auth)
     : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
 {
     _plexApi      = plexApi;
     _embyApi      = embyApi;
     _embySettings = embySettings;
     _authSettings = auth;
 }
Ejemplo n.º 18
0
 public RefreshMetadata(IPlexContentRepository plexRepo, IEmbyContentRepository embyRepo,
                        ILogger <RefreshMetadata> log, ITvMazeApi tvApi, ISettingsService <PlexSettings> plexSettings,
                        IMovieDbApi movieApi, ISettingsService <EmbySettings> embySettings, IEmbyApi embyApi)
 {
     _plexRepo     = plexRepo;
     _embyRepo     = embyRepo;
     _log          = log;
     _movieApi     = movieApi;
     _tvApi        = tvApi;
     _plexSettings = plexSettings;
     _embySettings = embySettings;
     _embyApi      = embyApi;
 }
Ejemplo n.º 19
0
 public EmbyAvailabilityChecker(ISettingsService <EmbySettings> embySettings, IRequestService request, IEmbyApi emby, ICacheProvider cache,
                                INotificationService notify, IJobRecord rec, IRepository <UsersToNotify> users, IRepository <EmbyEpisodes> repo, IEmbyNotificationEngine e, IRepository <EmbyContent> content)
 {
     Emby               = embySettings;
     RequestService     = request;
     EmbyApi            = emby;
     Cache              = cache;
     Notification       = notify;
     Job                = rec;
     UserNotifyRepo     = users;
     EpisodeRepo        = repo;
     NotificationEngine = e;
     EmbyContent        = content;
 }
Ejemplo n.º 20
0
 public EmbyAddedNewsletter(IEmbyApi api, ISettingsService <EmbySettings> embySettings,
                            ISettingsService <EmailNotificationSettings> email,
                            ISettingsService <NewletterSettings> newsletter, IRepository <RecentlyAddedLog> log,
                            IRepository <EmbyContent> embyContent, IRepository <EmbyEpisodes> episodes)
 {
     Api                = api;
     EmbySettings       = embySettings;
     EmailSettings      = email;
     NewsletterSettings = newsletter;
     Content            = embyContent;
     MovieApi           = new TheMovieDbApi();
     TvApi              = new TvMazeApi();
     Episodes           = episodes;
     RecentlyAddedLog   = log;
 }
Ejemplo n.º 21
0
 public SettingsController(ISettingsResolver resolver,
                           IMapper mapper,
                           INotificationTemplatesRepository templateRepo,
                           IEmbyApi embyApi,
                           ICacheService memCache,
                           IGithubApi githubApi,
                           IRecentlyAddedEngine engine)
 {
     SettingsResolver   = resolver;
     Mapper             = mapper;
     TemplateRepository = templateRepo;
     _embyApi           = embyApi;
     _cache             = memCache;
     _githubApi         = githubApi;
     _recentlyAdded     = engine;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SettingsController" /> class.
 /// </summary>
 /// <param name="resolver">The resolver.</param>
 /// <param name="mapper">The mapper.</param>
 /// <param name="templateRepo">The templateRepo.</param>
 /// <param name="embyApi">The embyApi.</param>
 /// <param name="radarrSync">The radarrCacher.</param>
 /// <param name="memCache">The memory cache.</param>
 /// <param name="githubApi">The memory cache.</param>
 public SettingsController(ISettingsResolver resolver,
                           IMapper mapper,
                           INotificationTemplatesRepository templateRepo,
                           IEmbyApi embyApi,
                           IRadarrSync radarrSync,
                           ICacheService memCache,
                           IGithubApi githubApi)
 {
     SettingsResolver   = resolver;
     Mapper             = mapper;
     TemplateRepository = templateRepo;
     _embyApi           = embyApi;
     _radarrSync        = radarrSync;
     _cache             = memCache;
     _githubApi         = githubApi;
 }
Ejemplo n.º 23
0
        public async Task Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap             = context.JobDetail.JobDataMap;
            var        recentlyAddedSearch = false;

            if (dataMap.TryGetValue(JobDataKeys.EmbyRecentlyAddedSearch, out var recentlyAddedObj))
            {
                recentlyAddedSearch = Convert.ToBoolean(recentlyAddedObj);
            }

            var embySettings = await _settings.GetSettingsAsync();

            if (!embySettings.Enable)
            {
                return;
            }

            Api = _apiFactory.CreateClient(embySettings);

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, recentlyAddedSearch ? "Emby Recently Added Started" : "Emby Content Sync Started");

            foreach (var server in embySettings.Servers)
            {
                try
                {
                    await StartServerCache(server, recentlyAddedSearch);
                }
                catch (Exception e)
                {
                    await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
                    .SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Failed");

                    _logger.LogError(e, "Exception when caching Emby for server {0}", server.Name);
                }
            }

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Content Sync Finished");

            // Episodes


            await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyEpisodeSync), "Emby"), new JobDataMap(new Dictionary <string, string> {
                { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAddedSearch.ToString() }
            }));
        }
Ejemplo n.º 24
0
    public async Task <Either <BaseError, List <EmbyLibrary> > > GetLibraries(string address, string apiKey)
    {
        try
        {
            IEmbyApi service = RestService.For <IEmbyApi>(address);
            List <EmbyLibraryResponse> libraries = await service.GetLibraries(apiKey);

            return(libraries
                   .Map(Project)
                   .Somes()
                   .ToList());
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error getting emby libraries");
            return(BaseError.New(ex.Message));
        }
    }
Ejemplo n.º 25
0
        public async Task Execute(IJobExecutionContext job)
        {
            var settings = await _settings.GetSettingsAsync();

            Api = _apiFactory.CreateClient(settings);
            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Started");

            foreach (var server in settings.Servers)
            {
                await CacheEpisodes(server);
            }

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Finished");

            _logger.LogInformation("Emby Episode Sync Finished - Triggering Metadata refresh");
            await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
        }
Ejemplo n.º 26
0
    public async Task <Either <BaseError, List <MediaItem> > > GetCollectionItems(
        string address,
        string apiKey,
        string collectionId)
    {
        try
        {
            IEmbyApi service = RestService.For <IEmbyApi>(address);
            EmbyLibraryItemsResponse items = await service.GetCollectionItems(apiKey, collectionId);

            return(items.Items
                   .Map(ProjectToCollectionMediaItem)
                   .Somes()
                   .ToList());
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error getting Emby collection items");
            return(BaseError.New(ex.Message));
        }
    }
Ejemplo n.º 27
0
    public async Task <Either <BaseError, List <EmbyShow> > > GetShowLibraryItems(
        string address,
        string apiKey,
        string libraryId)
    {
        try
        {
            IEmbyApi service = RestService.For <IEmbyApi>(address);
            EmbyLibraryItemsResponse items = await service.GetShowLibraryItems(apiKey, libraryId);

            return(items.Items
                   .Map(ProjectToShow)
                   .Somes()
                   .ToList());
        }
        catch (Exception ex)
        {
            _logger.LogError(ex, "Error getting emby show library items");
            return(BaseError.New(ex.Message));
        }
    }
Ejemplo n.º 28
0
        public UserWizardModule(ISettingsService <PlexRequestSettings> pr, ISettingsService <PlexSettings> plex,
                                IPlexApi plexApi,
                                ISettingsService <AuthenticationSettings> auth, ICustomUserMapper m, IAnalytics a,
                                ISecurityExtensions security, IEmbyApi embyApi,
                                ISettingsService <EmbySettings> embySettings) : base("wizard", pr, security)
        {
            PlexSettings        = plex;
            PlexApi             = plexApi;
            PlexRequestSettings = pr;
            Auth         = auth;
            Mapper       = m;
            Analytics    = a;
            EmbySettings = embySettings;
            EmbyApi      = embyApi;

            Get["/", true] = async(x, ct) =>
            {
                a.TrackEventAsync(Category.Wizard, Action.Start, "Started the wizard", Username,
                                  CookieHelper.GetAnalyticClientId(Cookies));

                var settings = await PlexRequestSettings.GetSettingsAsync();

                if (settings.Wizard)
                {
                    return(Context.GetRedirect("~/search"));
                }
                return(View["Index"]);
            };
            Post["/plexAuth"]   = x => PlexAuth();
            Post["/plex", true] = async(x, ct) => await Plex();

            Post["/plexrequest", true] = async(x, ct) => await PlexRequest();

            Post["/auth", true] = async(x, ct) => await Authentication();

            Post["/createuser", true] = async(x, ct) => await CreateUser();


            Post["/embyauth", true] = async(x, ct) => await EmbyAuth();
        }
Ejemplo n.º 29
0
        public async Task Execute(IJobExecutionContext context)
        {
            JobDataMap dataMap             = context.MergedJobDataMap;
            var        recentlyAddedSearch = false;

            if (dataMap.TryGetValue(JobDataKeys.EmbyRecentlyAddedSearch, out var recentlyAddedObj))
            {
                recentlyAddedSearch = Convert.ToBoolean(recentlyAddedObj);
            }

            var settings = await _settings.GetSettingsAsync();

            Api = _apiFactory.CreateClient(settings);
            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Started");

            foreach (var server in settings.Servers)
            {
                if (server.EmbySelectedLibraries.Any() && server.EmbySelectedLibraries.Any(x => x.Enabled))
                {
                    var tvLibsToFilter = server.EmbySelectedLibraries.Where(x => x.Enabled && x.CollectionType == "tvshows");
                    foreach (var tvParentIdFilter in tvLibsToFilter)
                    {
                        _logger.LogInformation($"Scanning Lib for episodes '{tvParentIdFilter.Title}'");
                        await CacheEpisodes(server, recentlyAddedSearch, tvParentIdFilter.Key);
                    }
                }
                else
                {
                    await CacheEpisodes(server, recentlyAddedSearch, string.Empty);
                }
            }

            await _notification.Clients.Clients(NotificationHub.AdminConnectionIds)
            .SendAsync(NotificationHub.NotificationEvent, "Emby Episode Sync Finished");

            _logger.LogInformation("Emby Episode Sync Finished - Triggering Metadata refresh");
            await OmbiQuartz.TriggerJob(nameof(IRefreshMetadata), "System");
        }
Ejemplo n.º 30
0
 public async Task <Either <BaseError, EmbyServerInformation> > GetServerInformation(
     string address,
     string apiKey)
 {
     try
     {
         IEmbyApi service = RestService.For <IEmbyApi>(address);
         var      cts     = new CancellationTokenSource();
         cts.CancelAfter(TimeSpan.FromSeconds(5));
         return(await service.GetSystemInformation(apiKey, cts.Token)
                .Map(response => new EmbyServerInformation(response.ServerName, response.OperatingSystem)));
     }
     catch (OperationCanceledException ex)
     {
         _logger.LogError(ex, "Timeout getting emby server name");
         return(BaseError.New("Emby did not respond in time"));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Error getting emby server name");
         return(BaseError.New(ex.Message));
     }
 }