add library folder option to home page

This commit is contained in:
Luke Pulverenti 2014-06-14 19:13:09 -04:00
parent 0b60e7ca67
commit f72b1f531a
10 changed files with 155 additions and 8 deletions

View File

@ -160,6 +160,13 @@ namespace MediaBrowser.Api
{
var folder = (Folder) libraryManager.GetItemById(new Guid(parentId));
if (userId.HasValue)
{
var user = userManager.GetUserById(userId.Value);
return folder.GetRecursiveChildren(user).ToList();
}
return folder.GetRecursiveChildren();
}
if (userId.HasValue)

View File

@ -11,5 +11,10 @@ namespace MediaBrowser.Controller.Entities
{
DisplayMediaType = "CollectionFolder";
}
public string CollectionType
{
get { return Model.Entities.CollectionType.BoxSets; }
}
}
}

View File

@ -6,5 +6,6 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
public interface ICollectionFolder
{
string CollectionType { get; }
}
}

View File

@ -423,7 +423,7 @@ namespace MediaBrowser.Dlna.Didl
else if (item is Series || item is Season || item is BoxSet)
{
classType = "object.container.album.videoAlbum";
}
}
}
objectClass.InnerText = classType ?? "object.container.storageFolder";
@ -441,7 +441,7 @@ namespace MediaBrowser.Dlna.Didl
if (!_profile.RequiresPlainVideoItems && item is Movie)
{
objectClass.InnerText = "object.item.videoItem.movie";
}
}
else
{
objectClass.InnerText = "object.item.videoItem";

View File

@ -463,7 +463,8 @@ namespace MediaBrowser.Dlna.PlayTo
ItemId = item.Id.ToString("N"),
MediaSources = mediaSources,
Profile = profile,
DeviceId = deviceId
DeviceId = deviceId,
MaxBitrate = profile.MaxBitrate
}),
Profile = profile
@ -481,7 +482,8 @@ namespace MediaBrowser.Dlna.PlayTo
ItemId = item.Id.ToString("N"),
MediaSources = mediaSources,
Profile = profile,
DeviceId = deviceId
DeviceId = deviceId,
MaxBitrate = profile.MaxBitrate
}),
Profile = profile

View File

@ -22,5 +22,7 @@ namespace MediaBrowser.Model.Entities
public const string Books = "books";
public const string Photos = "photos";
public const string Games = "games";
public const string Channels = "channels";
public const string LiveTv = "livetv";
}
}

View File

@ -0,0 +1,127 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Providers;
using MediaBrowser.Providers.Genres;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Providers.FolderImages
{
public class DefaultImageProvider : IRemoteImageProvider
{
private readonly IHttpClient _httpClient;
public DefaultImageProvider(IHttpClient httpClient)
{
_httpClient = httpClient;
}
public IEnumerable<ImageType> GetSupportedImages(IHasImages item)
{
return new List<ImageType>
{
ImageType.Primary,
ImageType.Thumb
};
}
public Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken)
{
var view = item as UserView;
if (view != null)
{
return GetImages(view.ViewType, cancellationToken);
}
var folder = (ICollectionFolder)item;
return GetImages(folder.CollectionType, cancellationToken);
}
private Task<IEnumerable<RemoteImageInfo>> GetImages(string viewType, CancellationToken cancellationToken)
{
var url = GetImageUrl(viewType);
return Task.FromResult<IEnumerable<RemoteImageInfo>>(new List<RemoteImageInfo>
{
new RemoteImageInfo
{
ProviderName = Name,
Url = url,
Type = ImageType.Primary
},
new RemoteImageInfo
{
ProviderName = Name,
Url = url,
Type = ImageType.Thumb
}
});
}
private string GetImageUrl(string viewType)
{
const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/MediaBrowser.Resources/master/images/folders/";
if (string.Equals(viewType, CollectionType.Books, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "books.jpg";
}
if (string.Equals(viewType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "games.jpg";
}
if (string.Equals(viewType, CollectionType.Music, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "music.jpg";
}
if (string.Equals(viewType, CollectionType.Photos, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "photos.jpg";
}
if (string.Equals(viewType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "tv.jpg";
}
if (string.Equals(viewType, CollectionType.Channels, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "channels.jpg";
}
if (string.Equals(viewType, CollectionType.LiveTv, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "livetv.jpg";
}
if (string.Equals(viewType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase))
{
return urlPrefix + "movies.jpg";
}
return urlPrefix + "generic.jpg";
}
public string Name
{
get { return "Default Image Provider"; }
}
public bool Supports(IHasImages item)
{
return item is UserView || item is CollectionFolder;
}
public Task<HttpResponseInfo> GetImageResponse(string url, CancellationToken cancellationToken)
{
return _httpClient.GetResponse(new HttpRequestOptions
{
CancellationToken = cancellationToken,
Url = url,
ResourcePool = GenreImageProvider.ImageDownloadResourcePool
});
}
}
}

View File

@ -80,6 +80,7 @@
<Compile Include="BoxSets\MovieDbBoxSetProvider.cs" />
<Compile Include="Channels\ChannelMetadataService.cs" />
<Compile Include="Chapters\ChapterManager.cs" />
<Compile Include="FolderImages\DefaultImageProvider.cs" />
<Compile Include="Folders\CollectionFolderImageProvider.cs" />
<Compile Include="Folders\FolderMetadataService.cs" />
<Compile Include="Folders\ImagesByNameImageProvider.cs" />

View File

@ -122,6 +122,7 @@
"MessageConfirmItemGrouping": "Media Browser clients will automatically choose the optimal version to play based on device and network performance. Are you sure you wish to continue?",
"HeaderResume": "Resume",
"HeaderMyLibrary": "My Library",
"HeaderLibraryFolders": "Folder View"
"HeaderLatestMedia": "Latest Media",
"ButtonMore": "More...",
"HeaderFavoriteMovies": "Favorite Movies",

View File

@ -785,9 +785,9 @@
"LabelHomePageSection1": "Home page section one:",
"LabelHomePageSection2": "Home page section two:",
"LabelHomePageSection3": "Home page section three:",
"OptionLibraryButtons": "Library buttons",
"OptionLibraryTiles": "Library tiles (large)",
"OptionSmallLibraryTiles": "Library tiles (small)",
"OptionMyLibraryButtons": "My library (buttons)",
"OptionMyLibrary": "My library",
"OptionMyLibrarySmall": "My library (small)",
"OptionResumablemedia": "Resume",
"OptionLatestMedia": "Latest media",
"OptionNone": "None",
@ -828,5 +828,6 @@
"HeaderLibraryViews": "Library Views",
"LabelSelectFolderGroups": "Automatically group content from the following folders into views such as Movies, Music and TV:",
"LabelSelectFolderGroupsHelp": "Folders that are unchecked will be displayed by themselves in their own view.",
"OptionDisplayAdultContent": "Display adult content"
"OptionDisplayAdultContent": "Display adult content",
"OptionLibraryFolders": "Folder view"
}