Exemplo n.º 1
0
 public SmallSyncTask(IApplicationBuilder app)
 {
     _embyClient               = app.ApplicationServices.GetService <IEmbyClient>();
     _embyPluginRepository     = app.ApplicationServices.GetService <IPluginRepository>();
     _embyServerInfoRepository = app.ApplicationServices.GetService <IServerInfoRepository>();
     _configurationRepository  = app.ApplicationServices.GetService <IConfigurationRepository>();
     _embyDriveRepository      = app.ApplicationServices.GetService <IDriveRepository>();
 }
Exemplo n.º 2
0
 public MovieSyncTask(IApplicationBuilder app)
 {
     _embyClient = app.ApplicationServices.GetService <IEmbyClient>();
     _configurationRepository = app.ApplicationServices.GetService <IConfigurationRepository>();
     _movieRepository         = app.ApplicationServices.GetService <IMovieRepository>();
     _genreRepository         = app.ApplicationServices.GetService <IGenreRepository>();
     _personRepository        = app.ApplicationServices.GetService <IPersonRepository>();
     _collectionRepository    = app.ApplicationServices.GetService <ICollectionRepository>();
 }
Exemplo n.º 3
0
 /// <remarks>See
 /// https://github.com/MediaBrowser/Emby/blob/master/MediaBrowser.Api/Movies/CollectionService.cs
 /// for the POST URL.</remarks>
 public async Task AddMovieToCollectionAsync(IEmbyClient client, string movieId, string collectionId)
 {
     var args = new Dictionary <string, string>
     {
         { "Ids", movieId }
     };
     var url = client.GetApiUrl($"Collections/{collectionId}/Items");
     await client.SendAsync <EmptyRequestResult>(url, "POST", args);
 }
Exemplo n.º 4
0
        public async Task UpdateMetadataAsync(IEmbyClient client, IEmbyMovieMetadata movieMetadata, string movieId)
        {
            var baseItemDto = await client.GetItemAsync(movieId, client.CurrentUserId);

            baseItemDto.Name           = movieMetadata.Name;
            baseItemDto.ForcedSortName = movieMetadata.ForcedSortName;

            await client.UpdateItemAsync(movieId, baseItemDto);
        }
Exemplo n.º 5
0
        public async Task SetMovieAsWatchedAsync(IEmbyClient client, DateTime lastPlayedDate, string movieId)
        {
            var args = new Dictionary <string, string>
            {
                { "DatePlayed", lastPlayedDate.ToLocalTime().ToString("yyyyMMddHHmmss") }
            };

            var url = client.GetApiUrl($"Users/{client.CurrentUserId}/PlayedItems/{movieId}");
            await client.SendAsync <EmptyRequestResult>(url, "POST", args);
        }
Exemplo n.º 6
0
        /// <remarks>
        /// There seems to be some issue somewhere, which prevents a image from being reindexed.
        /// See
        /// https://emby.media/community/index.php?/topic/50794-apiclient-server-3230-cannot-reindex-the-backdrop-image-of-a-movie/
        /// </remarks>
        public async Task ReindexImageOfMovieAsync(IEmbyClient client, ImageType imageType, int index, int newIndex, string movieId)
        {
            var args = new Dictionary <string, string>
            {
                { "newIndex", newIndex.ToString() }
            };

            var url = client.GetApiUrl($"Items/{movieId}/Images/{imageType}/{index}/Index");
            await client.SendAsync <EmptyRequestResult>(url, "POST", args);
        }
Exemplo n.º 7
0
        public async Task AddImageToMovieAsync(IEmbyClient client, ImageType imageType, Uri imageUrl, string movieId)
        {
            var args = new Dictionary <string, string>
            {
                { "Type", imageType.ToString() },
                { "ImageUrl", imageUrl.AbsoluteUri }
            };

            var url = client.GetApiUrl($"Items/{movieId}/RemoteImages/Download");
            await client.SendAsync <EmptyRequestResult>(url, "POST", args);
        }
Exemplo n.º 8
0
 public EmbyService(IEmbyClient embyClient,
                    IPluginRepository embyPluginRepository,
                    IConfigurationRepository configurationRepository,
                    IServerInfoRepository embyServerInfoRepository,
                    IDriveRepository embyDriveRepository)
 {
     _embyClient               = embyClient;
     _embyPluginRepository     = embyPluginRepository;
     _configurationRepository  = configurationRepository;
     _embyServerInfoRepository = embyServerInfoRepository;
     _embyDriveRepository      = embyDriveRepository;
 }
Exemplo n.º 9
0
        /// <remarks>Please read
        /// https://emby.media/community/index.php?/topic/50514-apiclient-how-to-check-whether-an-arbitrary-string-matches-an-existing-boxset/
        /// </remarks>
        public async Task <ICollectionIdentifier> CreateCollectionAsync(IEmbyClient client, string collectionName)
        {
            var args = new Dictionary <string, string>
            {
                { "IsLocked", "false" },
                { "Name", collectionName },
                { "ParentId", "" },
                { "Ids", "" }
            };
            var url = client.GetApiUrl("Collections");
            var collectionCreationResult = await client.SendAsync <CollectionCreationResult>(url, "POST", args);

            var baseItemDto = await client.GetItemAsync(collectionCreationResult.Id, client.CurrentUserId);

            return(new CollectionIdentifier
            {
                Path = baseItemDto.Path,
                Id = collectionCreationResult.Id,
                Name = baseItemDto.Name
            });
        }
Exemplo n.º 10
0
 protected EmbyBaseService(IAppLogger logger, IEmbyClient client, IEmbyRepository embyRepository)
 {
     Client     = client;
     Logger     = logger;
     Repository = embyRepository;
 }
Exemplo n.º 11
0
        public async Task <IReadOnlyCollection <ICollectionIdentifier> > GetCollectionIdentifiersAsync(IEmbyClient client)
        {
            var query = new ItemQuery
            {
                UserId = client.CurrentUserId,
                // FYI: Collections are folders.
                Filters          = new[] { ItemFilter.IsFolder },
                IncludeItemTypes = new[] { "Boxset" },
                Fields           = new[] { ItemFields.Path },
                Recursive        = true
            };
            var itemsResult = await client.GetItemsAsync(query);

            return(itemsResult.Items
                   .Select(x => new CollectionIdentifier
            {
                Path = x.Path,
                Id = x.Id,
                Name = x.Name
            })
                   .ToArray());
        }
Exemplo n.º 12
0
 public async Task SetMovieAsUnwatchedAsync(IEmbyClient client, string movieId)
 {
     var url = client.GetApiUrl($"Users/{client.CurrentUserId}/PlayedItems/{movieId}");
     await client.SendAsync <EmptyRequestResult>(url, "DELETE");
 }
Exemplo n.º 13
0
        public async Task <PublicSystemInfo> GetPublicSystemInfoAsync(IEmbyClient client)
        {
            var url = client.GetApiUrl("System/Info/Public");

            return(await client.SendAsync <PublicSystemInfo>(url, "GET"));
        }
Exemplo n.º 14
0
 public async Task DeleteImageFromMovieAsync(IEmbyClient client, ImageType imageType, int index, string movieId)
 {
     var url = client.GetApiUrl($"Items/{movieId}/Images/{imageType}/{index}");
     await client.SendAsync <EmptyRequestResult>(url, "DELETE");
 }
Exemplo n.º 15
0
        public async Task <IReadOnlyCollection <ImageInfo> > GetImageInfosAsync(IEmbyClient client, string movieId)
        {
            var url = client.GetApiUrl($"Items/{movieId}/Images");

            return(await client.SendAsync <List <ImageInfo> >(url, "GET"));
        }
Exemplo n.º 16
0
 public EmbyCollectionService(IAppLogger logger, IEmbyClient client, IEmbyRepository embyRepository)
     : base(logger, client, embyRepository)
 {
 }
Exemplo n.º 17
0
 public EmbyImageService(IAppLogger logger, IEmbyClient client, IEmbyRepository embyRepository)
     : base(logger, client, embyRepository)
 {
 }
Exemplo n.º 18
0
        public async Task <IReadOnlyCollection <ILibraryIdentifier> > GetLibraryIdentifiersAsync(IEmbyClient client)
        {
            var itemsResult = await client.GetUserViews(client.CurrentUserId);

            return(itemsResult.Items
                   .Select(x => new LibraryIdentifier
            {
                Name = x.Name,
                Id = x.Id
            })
                   .ToArray());
        }
Exemplo n.º 19
0
 public PersonService(IPersonRepository personRepository, IConfigurationRepository configurationRepository, IEmbyClient embyClient)
 {
     _personRepository        = personRepository;
     _configurationRepository = configurationRepository;
     _embyClient = embyClient;
 }
Exemplo n.º 20
0
        public async Task <IReadOnlyCollection <IMovieIdentifier> > GetMovieIdentifiersAsync(IEmbyClient client, string libraryId)
        {
            var query = new ItemQuery
            {
                UserId           = client.CurrentUserId,
                ParentId         = libraryId,
                Filters          = new[] { ItemFilter.IsNotFolder },
                IncludeItemTypes = new[] { "Movie" },
                Fields           = new[] { ItemFields.Path },
                Recursive        = true
            };
            var itemsResult = await client.GetItemsAsync(query);

            return(itemsResult.Items
                   .Select(x => new MovieIdentifier
            {
                Filename = Path.GetFileName(x.Path),
                Id = x.Id
            })
                   .ToArray());
        }