Merge pull request #1715 from MediaBrowser/dev

Dev
This commit is contained in:
Luke 2016-05-07 14:59:07 -04:00
commit 75a1f74f94
22 changed files with 139 additions and 121 deletions

View File

@ -17,7 +17,12 @@ namespace MediaBrowser.Controller.Entities.Audio
/// </summary> /// </summary>
public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasProductionLocations, IHasLookupInfo<ArtistInfo> public class MusicArtist : Folder, IMetadataContainer, IItemByName, IHasMusicGenres, IHasDualAccess, IHasProductionLocations, IHasLookupInfo<ArtistInfo>
{ {
public bool IsAccessedByName { get; set; } [IgnoreDataMember]
public bool IsAccessedByName
{
get { return ParentId == Guid.Empty; }
}
public List<string> ProductionLocations { get; set; } public List<string> ProductionLocations { get; set; }
[IgnoreDataMember] [IgnoreDataMember]
@ -40,6 +45,20 @@ namespace MediaBrowser.Controller.Entities.Audio
return !IsAccessedByName; return !IsAccessedByName;
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
var itemByNameFilter = GetItemFilter();
if (query.User != null)
{
return query.User.RootFolder
.GetRecursiveChildren(query.User, i => !i.IsFolder && itemByNameFilter(i));
}
return LibraryManager.RootFolder
.GetRecursiveChildren(i => !i.IsFolder && itemByNameFilter(i));
}
protected override IEnumerable<BaseItem> ActualChildren protected override IEnumerable<BaseItem> ActualChildren
{ {
get get

View File

@ -79,5 +79,13 @@ namespace MediaBrowser.Controller.Entities.Audio
return false; return false;
} }
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
query.Genres = new[] { Name };
query.ExcludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
return LibraryManager.GetItemList(query);
}
} }
} }

View File

@ -62,6 +62,14 @@ namespace MediaBrowser.Controller.Entities
return i => i is Game && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); return i => i is Game && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase);
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
query.Genres = new[] { Name };
query.IncludeItemTypes = new[] { typeof(Game).Name };
return LibraryManager.GetItemList(query);
}
[IgnoreDataMember] [IgnoreDataMember]
public override bool SupportsPeople public override bool SupportsPeople
{ {

View File

@ -66,6 +66,14 @@ namespace MediaBrowser.Controller.Entities
return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase); return i => !(i is Game) && !(i is IHasMusicGenres) && i.Genres.Contains(Name, StringComparer.OrdinalIgnoreCase);
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
query.Genres = new[] { Name };
query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name };
return LibraryManager.GetItemList(query);
}
[IgnoreDataMember] [IgnoreDataMember]
public override bool SupportsPeople public override bool SupportsPeople
{ {

View File

@ -20,6 +20,8 @@ namespace MediaBrowser.Controller.Entities
/// </summary> /// </summary>
/// <returns>Func&lt;BaseItem, System.Boolean&gt;.</returns> /// <returns>Func&lt;BaseItem, System.Boolean&gt;.</returns>
Func<BaseItem, bool> GetItemFilter(); Func<BaseItem, bool> GetItemFilter();
IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query);
} }
public interface IHasDualAccess : IItemByName public interface IHasDualAccess : IItemByName

View File

@ -134,6 +134,7 @@ namespace MediaBrowser.Controller.Entities
public string[] AlbumNames { get; set; } public string[] AlbumNames { get; set; }
public string[] ArtistNames { get; set; } public string[] ArtistNames { get; set; }
public string AncestorWithPresentationUniqueKey { get; set; }
public bool GroupByPresentationUniqueKey { get; set; } public bool GroupByPresentationUniqueKey { get; set; }

View File

@ -31,6 +31,13 @@ namespace MediaBrowser.Controller.Entities
return GetItemLookupInfo<PersonLookupInfo>(); return GetItemLookupInfo<PersonLookupInfo>();
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
query.Person = Name;
return LibraryManager.GetItemList(query);
}
/// <summary> /// <summary>
/// Returns the folder containing the item. /// Returns the folder containing the item.
/// If the item is a folder, it returns the folder itself /// If the item is a folder, it returns the folder itself

View File

@ -7,15 +7,6 @@ namespace MediaBrowser.Controller.Entities
{ {
public class PhotoAlbum : Folder public class PhotoAlbum : Folder
{ {
[IgnoreDataMember]
public override bool SupportsLocalMetadata
{
get
{
return false;
}
}
[IgnoreDataMember] [IgnoreDataMember]
public override bool AlwaysScanInternalMetadataPath public override bool AlwaysScanInternalMetadataPath
{ {

View File

@ -65,6 +65,13 @@ namespace MediaBrowser.Controller.Entities
return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase); return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase);
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
query.Studios = new[] { Name };
return LibraryManager.GetItemList(query);
}
[IgnoreDataMember] [IgnoreDataMember]
public override bool SupportsPeople public override bool SupportsPeople
{ {

View File

@ -9,6 +9,7 @@ using System.Linq;
using System.Runtime.Serialization; using System.Runtime.Serialization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MoreLinq;
namespace MediaBrowser.Controller.Entities.TV namespace MediaBrowser.Controller.Entities.TV
{ {
@ -180,7 +181,7 @@ namespace MediaBrowser.Controller.Entities.TV
else else
{ {
items = query.Recursive items = query.Recursive
? GetRecursiveChildren(user, filter) ? GetSeasons(user).Cast<BaseItem>().Concat(GetEpisodes(user)).Where(filter)
: GetSeasons(user).Where(filter); : GetSeasons(user).Where(filter);
} }
@ -211,7 +212,7 @@ namespace MediaBrowser.Controller.Entities.TV
} }
else else
{ {
seasons = base.GetChildren(user, true).OfType<Season>(); seasons = LibraryManager.Sort(base.GetChildren(user, true), user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).OfType<Season>();
} }
if (!includeMissingSeasons && !includeVirtualUnaired) if (!includeMissingSeasons && !includeVirtualUnaired)
@ -250,17 +251,8 @@ namespace MediaBrowser.Controller.Entities.TV
// Specials could appear twice based on above - once in season 0, once in the aired season // Specials could appear twice based on above - once in season 0, once in the aired season
// This depends on settings for that series // This depends on settings for that series
// When this happens, remove the duplicate from season 0 // When this happens, remove the duplicate from season 0
var returnList = new List<Episode>();
foreach (var episode in allEpisodes) return allEpisodes.DistinctBy(i => i.Id).Reverse();
{
if (!returnList.Contains(episode))
{
returnList.Insert(0, episode);
}
}
return returnList;
} }
public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken) public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken)

View File

@ -70,6 +70,22 @@ namespace MediaBrowser.Controller.Entities
return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year); return inputItems.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year);
} }
public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query)
{
int year;
var usCulture = new CultureInfo("en-US");
if (!int.TryParse(Name, NumberStyles.Integer, usCulture, out year))
{
return new List<BaseItem>();
}
query.Years = new[] { year };
return LibraryManager.GetItemList(query);
}
public int? GetYearValue() public int? GetYearValue()
{ {
int i; int i;

View File

@ -99,11 +99,12 @@ namespace MediaBrowser.Controller.Playlists
var musicGenre = item as MusicGenre; var musicGenre = item as MusicGenre;
if (musicGenre != null) if (musicGenre != null)
{ {
Func<BaseItem, bool> filter = i => i is Audio && i.Genres.Contains(musicGenre.Name, StringComparer.OrdinalIgnoreCase); var items = LibraryManager.GetItemList(new InternalItemsQuery(user)
{
var items = user == null Recursive = true,
? LibraryManager.RootFolder.GetRecursiveChildren(filter) IncludeItemTypes = new[] { typeof(Audio).Name },
: user.RootFolder.GetRecursiveChildren(user, filter); Genres = new[] { musicGenre.Name }
});
return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending);
} }

View File

@ -662,9 +662,6 @@
<Compile Include="..\MediaBrowser.Model\FileOrganization\TvFileOrganizationOptions.cs"> <Compile Include="..\MediaBrowser.Model\FileOrganization\TvFileOrganizationOptions.cs">
<Link>FileOrganization\TvFileOrganizationOptions.cs</Link> <Link>FileOrganization\TvFileOrganizationOptions.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">
<Link>Games\GameSystem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs"> <Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs">
<Link>Globalization\CountryInfo.cs</Link> <Link>Globalization\CountryInfo.cs</Link>
</Compile> </Compile>

View File

@ -636,9 +636,6 @@
<Compile Include="..\MediaBrowser.Model\FileOrganization\TvFileOrganizationOptions.cs"> <Compile Include="..\MediaBrowser.Model\FileOrganization\TvFileOrganizationOptions.cs">
<Link>FileOrganization\TvFileOrganizationOptions.cs</Link> <Link>FileOrganization\TvFileOrganizationOptions.cs</Link>
</Compile> </Compile>
<Compile Include="..\MediaBrowser.Model\Games\GameSystem.cs">
<Link>Games\GameSystem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs"> <Compile Include="..\MediaBrowser.Model\Globalization\CountryInfo.cs">
<Link>Globalization\CountryInfo.cs</Link> <Link>Globalization\CountryInfo.cs</Link>
</Compile> </Compile>

View File

@ -1,48 +0,0 @@

namespace MediaBrowser.Model.Games
{
public class GameSystem
{
public const string Nintendo = "Nintendo";
public const string SuperNintendo = "Super Nintendo";
public const string Panasonic3DO = "3DO";
public const string Amiga = "Amiga";
public const string Arcade = "Arcade";
public const string Atari2600 = "Atari 2600";
public const string Atari5200 = "Atari 5200";
public const string Atari7800 = "Atari 7800";
public const string AtariXE = "Atari XE";
public const string AtariJaguar = "Atari Jaguar";
public const string AtariJaguarCD = "Atari Jaguar CD";
public const string Colecovision = "Colecovision";
public const string Commodore64 = "Commodore 64";
public const string CommodoreVic20 = "Commodore Vic-20";
public const string Intellivision = "Intellivision";
public const string MicrosoftXBox = "Xbox";
public const string NeoGeo = "Neo Geo";
public const string Nintendo64 = "Nintendo 64";
public const string NintendoDS = "Nintendo DS";
public const string NintendoGameBoy = "Game Boy";
public const string NintendoGameBoyAdvance = "Game Boy Advance";
public const string NintendoGameBoyColor = "Game Boy Color";
public const string NintendoGameCube = "Gamecube";
public const string VirtualBoy = "Virtual Boy";
public const string Wii = "Nintendo Wii";
public const string DOS = "DOS";
public const string Windows = "Windows";
public const string Sega32X = "Sega 32X";
public const string SegaCD = "Sega CD";
public const string SegaDreamcast = "Dreamcast";
public const string SegaGameGear = "Game Gear";
public const string SegaGenesis = "Sega Genesis";
public const string SegaMasterSystem = "Sega Master System";
public const string SegaMegaDrive = "Sega Mega Drive";
public const string SegaSaturn = "Sega Saturn";
public const string SonyPlaystation = "Sony Playstation";
public const string SonyPlaystation2 = "PS2";
public const string SonyPSP = "PSP";
public const string TurboGrafx16 = "TurboGrafx 16";
public const string TurboGrafxCD = "TurboGrafx CD";
public const string ZxSpectrum = "ZX Spectrum";
}
}

View File

@ -287,7 +287,6 @@
<Compile Include="Entities\MetadataFields.cs" /> <Compile Include="Entities\MetadataFields.cs" />
<Compile Include="Entities\UserDataSaveReason.cs" /> <Compile Include="Entities\UserDataSaveReason.cs" />
<Compile Include="Entities\Video3DFormat.cs" /> <Compile Include="Entities\Video3DFormat.cs" />
<Compile Include="Games\GameSystem.cs" />
<Compile Include="IO\IIsoManager.cs" /> <Compile Include="IO\IIsoManager.cs" />
<Compile Include="IO\IIsoMount.cs" /> <Compile Include="IO\IIsoMount.cs" />
<Compile Include="IO\IIsoMounter.cs" /> <Compile Include="IO\IIsoMounter.cs" />

View File

@ -961,7 +961,7 @@ namespace MediaBrowser.Server.Implementations.Library
Name = name Name = name
}).Cast<MusicArtist>() }).Cast<MusicArtist>()
.Where(i => !i.IsAccessedByName) .OrderBy(i => i.IsAccessedByName ? 1 : 0)
.Cast<T>() .Cast<T>()
.FirstOrDefault(); .FirstOrDefault();
@ -984,11 +984,6 @@ namespace MediaBrowser.Server.Implementations.Library
Path = path Path = path
}; };
if (isArtist)
{
(item as MusicArtist).IsAccessedByName = true;
}
var task = CreateItem(item, CancellationToken.None); var task = CreateItem(item, CancellationToken.None);
Task.WaitAll(task); Task.WaitAll(task);
} }
@ -2574,7 +2569,7 @@ namespace MediaBrowser.Server.Implementations.Library
throw new ArgumentNullException("name"); throw new ArgumentNullException("name");
} }
name = _fileSystem.GetValidFilename(name); name = _fileSystem.GetValidFilename(name);
var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath; var rootFolderPath = ConfigurationManager.ApplicationPaths.DefaultUserViewsPath;

View File

@ -55,7 +55,7 @@ namespace MediaBrowser.Server.Implementations.Library
public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user) public IEnumerable<Audio> GetInstantMixFromFolder(Folder item, User user)
{ {
var genres = item var genres = item
.GetRecursiveChildren(user, i => i is Audio) .GetRecursiveChildren(user, i => i is Audio)
.Cast<Audio>() .Cast<Audio>()
.SelectMany(i => i.Genres) .SelectMany(i => i.Genres)
.Concat(item.Genres) .Concat(item.Genres)

View File

@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _updateInheritedRatingCommand; private IDbCommand _updateInheritedRatingCommand;
private IDbCommand _updateInheritedTagsCommand; private IDbCommand _updateInheritedTagsCommand;
public const int LatestSchemaVersion = 72; public const int LatestSchemaVersion = 73;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class. /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@ -2334,6 +2334,12 @@ namespace MediaBrowser.Server.Implementations.Persistence
var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + new Guid(i).ToString("N") + "'").ToArray()); var inClause = string.Join(",", query.AncestorIds.Select(i => "'" + new Guid(i).ToString("N") + "'").ToArray());
whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause)); whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorIdText in ({0}))", inClause));
} }
if (!string.IsNullOrWhiteSpace(query.AncestorWithPresentationUniqueKey))
{
var inClause = "select guid from TypedBaseItems where PresentationUniqueKey=@AncestorWithPresentationUniqueKey";
whereClauses.Add(string.Format("Guid in (select itemId from AncestorIds where AncestorId in ({0}))", inClause));
cmd.Parameters.Add(cmd, "@AncestorWithPresentationUniqueKey", DbType.String).Value = query.AncestorWithPresentationUniqueKey;
}
if (query.BlockUnratedItems.Length == 1) if (query.BlockUnratedItems.Length == 1)
{ {

View File

@ -109,6 +109,21 @@ namespace MediaBrowser.Server.Implementations.Photos
protected async Task<ItemUpdateType> FetchAsync(IHasImages item, ImageType imageType, MetadataRefreshOptions options, CancellationToken cancellationToken) protected async Task<ItemUpdateType> FetchAsync(IHasImages item, ImageType imageType, MetadataRefreshOptions options, CancellationToken cancellationToken)
{ {
var image = item.GetImageInfo(imageType, 0);
if (image != null)
{
if (!image.IsLocalFile)
{
return ItemUpdateType.None;
}
if (!FileSystem.ContainsSubPath(item.GetInternalMetadataPath(), image.Path))
{
return ItemUpdateType.None;
}
}
var items = await GetItemsWithImages(item).ConfigureAwait(false); var items = await GetItemsWithImages(item).ConfigureAwait(false);
return await FetchToFileInternal(item, items, imageType, cancellationToken).ConfigureAwait(false); return await FetchToFileInternal(item, items, imageType, cancellationToken).ConfigureAwait(false);

View File

@ -1026,11 +1026,11 @@ namespace MediaBrowser.Server.Implementations.Session
if (byName != null) if (byName != null)
{ {
var itemFilter = byName.GetItemFilter(); var items = byName.GetTaggedItems(new InternalItemsQuery(user)
{
var items = user == null ? IsFolder = false,
_libraryManager.RootFolder.GetRecursiveChildren(i => !i.IsFolder && itemFilter(i)) : Recursive = true
user.RootFolder.GetRecursiveChildren(user, i => !i.IsFolder && itemFilter(i)); });
return FilterToSingleMediaType(items) return FilterToSingleMediaType(items)
.OrderBy(i => i.SortName); .OrderBy(i => i.SortName);
@ -1040,9 +1040,12 @@ namespace MediaBrowser.Server.Implementations.Session
{ {
var folder = (Folder)item; var folder = (Folder)item;
var items = user == null ? var items = folder.GetItems(new InternalItemsQuery(user)
folder.GetRecursiveChildren(i => !i.IsFolder) : {
folder.GetRecursiveChildren(user, i => !i.IsFolder); Recursive = true,
IsFolder = false
}).Result.Items;
return FilterToSingleMediaType(items) return FilterToSingleMediaType(items)
.OrderBy(i => i.SortName); .OrderBy(i => i.SortName);

View File

@ -326,32 +326,26 @@ namespace MediaBrowser.Server.Implementations.Sync
var itemByName = item as IItemByName; var itemByName = item as IItemByName;
if (itemByName != null) if (itemByName != null)
{ {
var itemByNameFilter = itemByName.GetItemFilter(); return itemByName.GetTaggedItems(new InternalItemsQuery(user)
{
return user.RootFolder IsFolder = false,
.GetRecursiveChildren(user, i => !i.IsFolder && itemByNameFilter(i)); Recursive = true
} });
var series = item as Series;
if (series != null)
{
return series.GetEpisodes(user, false, false);
}
var season = item as Season;
if (season != null)
{
return season.GetEpisodes(user, false, false);
} }
if (item.IsFolder) if (item.IsFolder)
{ {
var folder = (Folder)item; var folder = (Folder)item;
var items = folder.GetRecursiveChildren(user, i => !i.IsFolder); var items = folder.GetItems(new InternalItemsQuery(user)
{
Recursive = true,
IsFolder = false
}).Result.Items;
if (!folder.IsPreSorted) if (!folder.IsPreSorted)
{ {
items = items.OrderBy(i => i.SortName); items = items.OrderBy(i => i.SortName).ToArray();
} }
return items; return items;