예제 #1
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));
        }
    }
예제 #2
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));
        }
    }
예제 #3
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));
        }
    }