Techywarrior 12 years ago
commit 419d851167

@ -110,9 +110,14 @@ namespace MediaBrowser.Api
if (auth != null && auth.ContainsKey("UserId"))
{
var user = UserManager.GetUserById(new Guid(auth["UserId"]));
var userId = auth["UserId"];
UserManager.LogUserActivity(user, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
if (!string.IsNullOrEmpty(userId))
{
var user = UserManager.GetUserById(new Guid(userId));
UserManager.LogUserActivity(user, auth["Client"], auth["DeviceId"], auth["Device"] ?? string.Empty);
}
}
}

@ -70,9 +70,13 @@ namespace MediaBrowser.Api.UserLibrary
items = FilterItems(request, items, user);
var extractedItems = GetAllItems(request, items, user);
var ibnItemsArray = SortItems(request, extractedItems).ToArray();
IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> ibnItems = ibnItemsArray;
extractedItems = FilterItems(request, extractedItems, user);
extractedItems = SortItems(request, extractedItems);
var ibnItemsArray = extractedItems.ToArray();
IEnumerable<IbnStub<TItemType>> ibnItems = ibnItemsArray;
var result = new ItemsResult
{
@ -104,23 +108,74 @@ namespace MediaBrowser.Api.UserLibrary
return result;
}
/// <summary>
/// Filters the items.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{IbnStub}.</returns>
private IEnumerable<IbnStub<TItemType>> FilterItems(GetItemsByName request, IEnumerable<IbnStub<TItemType>> items, User user)
{
var filters = request.GetFilters().ToList();
if (filters.Count == 0)
{
return items;
}
items = items.AsParallel();
if (filters.Contains(ItemFilter.Dislikes))
{
items = items.Where(i =>
{
var userdata = i.GetUserItemData(UserDataRepository, user.Id).Result;
return userdata != null && userdata.Likes.HasValue && !userdata.Likes.Value;
});
}
if (filters.Contains(ItemFilter.Likes))
{
items = items.Where(i =>
{
var userdata = i.GetUserItemData(UserDataRepository, user.Id).Result;
return userdata != null && userdata.Likes.HasValue && userdata.Likes.Value;
});
}
if (filters.Contains(ItemFilter.IsFavorite))
{
items = items.Where(i =>
{
var userdata = i.GetUserItemData(UserDataRepository, user.Id).Result;
return userdata != null && userdata.Likes.HasValue && userdata.IsFavorite;
});
}
return items.AsEnumerable();
}
/// <summary>
/// Sorts the items.
/// </summary>
/// <param name="request">The request.</param>
/// <param name="items">The items.</param>
/// <returns>IEnumerable{BaseItem}.</returns>
private IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> SortItems(GetItemsByName request, IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> items)
private IEnumerable<IbnStub<TItemType>> SortItems(GetItemsByName request, IEnumerable<IbnStub<TItemType>> items)
{
if (string.Equals(request.SortBy, "SortName", StringComparison.OrdinalIgnoreCase))
{
if (request.SortOrder.HasValue && request.SortOrder.Value == Model.Entities.SortOrder.Descending)
{
items = items.OrderByDescending(i => i.Item1);
items = items.OrderByDescending(i => i.Name);
}
else
{
items = items.OrderBy(i => i.Item1);
items = items.OrderBy(i => i.Name);
}
}
@ -160,14 +215,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
protected abstract IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user);
/// <summary>
/// Gets the entity.
/// </summary>
/// <param name="name">The name.</param>
/// <returns>Task{BaseItem}.</returns>
protected abstract Task<TItemType> GetEntity(string name);
protected abstract IEnumerable<IbnStub<TItemType>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user);
/// <summary>
/// Gets the dto.
@ -176,17 +224,17 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="user">The user.</param>
/// <param name="fields">The fields.</param>
/// <returns>Task{DtoBaseItem}.</returns>
private async Task<BaseItemDto> GetDto(Tuple<string, Func<IEnumerable<BaseItem>>> stub, User user, List<ItemFields> fields)
private async Task<BaseItemDto> GetDto(IbnStub<TItemType> stub, User user, List<ItemFields> fields)
{
BaseItem item;
try
{
item = await GetEntity(stub.Item1).ConfigureAwait(false);
item = await stub.GetItem().ConfigureAwait(false);
}
catch (IOException ex)
{
Logger.ErrorException("Error getting IBN item {0}", ex, stub.Item1);
Logger.ErrorException("Error getting IBN item {0}", ex, stub.Name);
return null;
}
@ -194,7 +242,7 @@ namespace MediaBrowser.Api.UserLibrary
if (fields.Contains(ItemFields.ItemCounts))
{
var items = stub.Item2().ToList();
var items = stub.Items;
dto.ChildCount = items.Count;
dto.RecentlyAddedItemCount = items.Count(i => i.IsRecentlyAdded(user));
@ -216,4 +264,48 @@ namespace MediaBrowser.Api.UserLibrary
[ApiMember(Name = "SortBy", Description = "Optional. Options: SortName", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)]
public string SortBy { get; set; }
}
public class IbnStub<T>
where T : BaseItem
{
private readonly Func<IEnumerable<BaseItem>> _childItemsFunction;
private List<BaseItem> _childItems;
private readonly Func<string,Task<T>> _itemFunction;
private Task<T> _itemTask;
public string Name;
public BaseItem Item;
private Task<UserItemData> _userData;
public List<BaseItem> Items
{
get { return _childItems ?? (_childItems = _childItemsFunction().ToList()); }
}
public Task<T> GetItem()
{
return _itemTask ?? (_itemTask = _itemFunction(Name));
}
public async Task<UserItemData> GetUserItemData(IUserDataRepository repo, Guid userId)
{
var item = await GetItem().ConfigureAwait(false);
if (_userData == null)
{
_userData = repo.GetUserData(userId, item.GetUserDataKey());
}
return await _userData.ConfigureAwait(false);
}
public IbnStub(string name, Func<IEnumerable<BaseItem>> childItems, Func<string,Task<T>> item)
{
Name = name;
_childItemsFunction = childItems;
_itemFunction = item;
}
}
}

@ -48,14 +48,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
protected override IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
protected override IEnumerable<IbnStub<Genre>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
{
var itemsList = items.Where(i => i.Genres != null).ToList();
return itemsList
.SelectMany(i => i.Genres)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(name => new Tuple<string, Func<IEnumerable<BaseItem>>>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase))));
.Select(name => new IbnStub<Genre>(name, () => itemsList.Where(i => i.Genres.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
}
/// <summary>
@ -63,7 +63,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="name">The name.</param>
/// <returns>Task{Genre}.</returns>
protected override Task<Genre> GetEntity(string name)
protected Task<Genre> GetEntity(string name)
{
return LibraryManager.GetGenre(name);
}

@ -38,8 +38,8 @@ namespace MediaBrowser.Api.UserLibrary
/// If the Person filter is used, this can also be used to restrict to a specific person type
/// </summary>
/// <value>The type of the person.</value>
[ApiMember(Name = "PersonType", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string PersonType { get; set; }
[ApiMember(Name = "PersonTypes", Description = "Optional. If specified, along with Person, results will be filtered to include only those containing the specified person and PersonType. Allows multiple, comma-delimited", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string PersonTypes { get; set; }
/// <summary>
/// Search characters used to find items
@ -357,6 +357,20 @@ namespace MediaBrowser.Api.UserLibrary
/// <returns>IEnumerable{BaseItem}.</returns>
internal static IEnumerable<BaseItem> ApplyAdditionalFilters(GetItems request, IEnumerable<BaseItem> items)
{
// Exclude item types
if (!string.IsNullOrEmpty(request.ExcludeItemTypes))
{
var vals = request.ExcludeItemTypes.Split(',');
items = items.Where(f => !vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase));
}
// Include item types
if (!string.IsNullOrEmpty(request.IncludeItemTypes))
{
var vals = request.IncludeItemTypes.Split(',');
items = items.Where(f => vals.Contains(f.GetType().Name, StringComparer.OrdinalIgnoreCase));
}
// Filter by Series Status
if (!string.IsNullOrEmpty(request.SeriesStatus))
{
@ -434,11 +448,21 @@ namespace MediaBrowser.Api.UserLibrary
// Apply person filter
if (!string.IsNullOrEmpty(personName))
{
var personType = request.PersonType;
var personTypes = request.PersonTypes;
items = !string.IsNullOrEmpty(personType)
? items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && p.Type.Equals(personType, StringComparison.OrdinalIgnoreCase)))
: items.Where(item => item.People != null && item.People.Any(p => p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase)));
if (string.IsNullOrEmpty(personTypes))
{
items = items.Where(item => item.People != null && item.People.Any(p => string.Equals(p.Name, personName, StringComparison.OrdinalIgnoreCase)));
}
else
{
var types = personTypes.Split(',');
items = items.Where(item =>
item.People != null &&
item.People.Any(p =>
p.Name.Equals(personName, StringComparison.OrdinalIgnoreCase) && types.Contains(p.Type, StringComparer.OrdinalIgnoreCase)));
}
}
return items;

@ -53,7 +53,7 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
protected override IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
protected override IEnumerable<IbnStub<Person>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
{
var inputPersonTypes = ((GetPersons) request).PersonTypes;
var personTypes = string.IsNullOrEmpty(inputPersonTypes) ? new string[] { } : inputPersonTypes.Split(',');
@ -67,7 +67,7 @@ namespace MediaBrowser.Api.UserLibrary
.Select(i => i.Name)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(name => new Tuple<string, Func<IEnumerable<BaseItem>>>(name, () =>
.Select(name => new IbnStub<Person>(name, () =>
{
if (personTypes.Length == 0)
{
@ -75,7 +75,7 @@ namespace MediaBrowser.Api.UserLibrary
}
return itemsList.Where(i => i.People.Any(p => p.Name.Equals(name, StringComparison.OrdinalIgnoreCase) && personTypes.Contains(p.Type ?? string.Empty, StringComparer.OrdinalIgnoreCase)));
})
}, GetEntity)
);
}
@ -89,7 +89,6 @@ namespace MediaBrowser.Api.UserLibrary
{
var people = itemsList.SelectMany(i => i.People.OrderBy(p => p.Type));
return personTypes.Length == 0 ?
people :
@ -102,7 +101,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="name">The name.</param>
/// <returns>Task{Genre}.</returns>
protected override Task<Person> GetEntity(string name)
protected Task<Person> GetEntity(string name)
{
return LibraryManager.GetPerson(name);
}

@ -48,14 +48,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
protected override IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
protected override IEnumerable<IbnStub<Studio>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
{
var itemsList = items.Where(i => i.Studios != null).ToList();
return itemsList
.SelectMany(i => i.Studios)
.Distinct(StringComparer.OrdinalIgnoreCase)
.Select(name => new Tuple<string, Func<IEnumerable<BaseItem>>>(name, () => itemsList.Where(i => i.Studios.Contains(name, StringComparer.OrdinalIgnoreCase))));
.Select(name => new IbnStub<Studio>(name, () => itemsList.Where(i => i.Studios.Contains(name, StringComparer.OrdinalIgnoreCase)), GetEntity));
}
/// <summary>
@ -63,7 +63,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="name">The name.</param>
/// <returns>Task{Studio}.</returns>
protected override Task<Studio> GetEntity(string name)
protected Task<Studio> GetEntity(string name)
{
return LibraryManager.GetStudio(name);
}

@ -54,14 +54,14 @@ namespace MediaBrowser.Api.UserLibrary
/// <param name="items">The items.</param>
/// <param name="user">The user.</param>
/// <returns>IEnumerable{Tuple{System.StringFunc{System.Int32}}}.</returns>
protected override IEnumerable<Tuple<string, Func<IEnumerable<BaseItem>>>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
protected override IEnumerable<IbnStub<Year>> GetAllItems(GetItemsByName request, IEnumerable<BaseItem> items, User user)
{
var itemsList = items.Where(i => i.ProductionYear != null).ToList();
return itemsList
.Select(i => i.ProductionYear.Value)
.Distinct()
.Select(year => new Tuple<string, Func<IEnumerable<BaseItem>>>(year.ToString(UsCulture), () => itemsList.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year)));
.Select(year => new IbnStub<Year>(year.ToString(UsCulture), () => itemsList.Where(i => i.ProductionYear.HasValue && i.ProductionYear.Value == year), GetEntity));
}
/// <summary>
@ -69,7 +69,7 @@ namespace MediaBrowser.Api.UserLibrary
/// </summary>
/// <param name="name">The name.</param>
/// <returns>Task{Studio}.</returns>
protected override Task<Year> GetEntity(string name)
protected Task<Year> GetEntity(string name)
{
return LibraryManager.GetYear(int.Parse(name, UsCulture));
}

@ -35,9 +35,6 @@
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mediabrowser.PluginSecurity">
<HintPath>..\ThirdParty\PluginSecurity\Mediabrowser.PluginSecurity.dll</HintPath>
</Reference>
<Reference Include="NLog">
<HintPath>..\packages\NLog.2.0.0.2000\lib\net40\NLog.dll</HintPath>
</Reference>
@ -79,6 +76,8 @@
<Compile Include="ScheduledTasks\Tasks\DeleteLogFileTask.cs" />
<Compile Include="ScheduledTasks\Tasks\ReloadLoggerTask.cs" />
<Compile Include="ScheduledTasks\Tasks\SystemUpdateTask.cs" />
<Compile Include="Security\MBLicenseFile.cs" />
<Compile Include="Security\MBRegistration.cs" />
<Compile Include="Security\PluginSecurityManager.cs" />
<Compile Include="Serialization\JsonSerializer.cs" />
<Compile Include="Serialization\XmlSerializer.cs" />
@ -104,7 +103,6 @@
<PropertyGroup>
<PostBuildEvent>if $(ConfigurationName) == Release (
xcopy "$(TargetPath)" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
xcopy "$(TargetDir)Mediabrowser.PluginSecurity.dll" "$(SolutionDir)\Nuget\dlls\" /y /d /r /i
)</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

@ -0,0 +1,106 @@
using MediaBrowser.Common.Configuration;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Mediabrowser.Common.Implementations.Security
{
internal class MBLicenseFile
{
private readonly IApplicationPaths _appPaths;
private readonly string _filename;
public string RegKey
{
get { return _regKey; }
set
{
if (value != _regKey)
{
//if key is changed - clear out our saved validations
UpdateRecords.Clear();
_regKey = value;
}
}
}
public string LegacyKey { get; set; }
private Dictionary<Guid, DateTime> UpdateRecords { get; set; }
private readonly object _lck = new object();
private string _regKey;
public MBLicenseFile(IApplicationPaths appPaths)
{
_appPaths = appPaths;
_filename = Path.Combine(_appPaths.ConfigurationDirectoryPath, "mb.lic");
UpdateRecords = new Dictionary<Guid, DateTime>();
Load();
}
public void AddRegCheck(string featureId)
{
using (var provider = new MD5CryptoServiceProvider())
{
UpdateRecords[new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(featureId)))] = DateTime.UtcNow;
Save();
}
}
public DateTime LastChecked(string featureId)
{
using (var provider = new MD5CryptoServiceProvider())
{
DateTime last;
lock(_lck) UpdateRecords.TryGetValue(new Guid(provider.ComputeHash(Encoding.Unicode.GetBytes(featureId))), out last);
return last < DateTime.UtcNow ? last : DateTime.MinValue; // guard agains people just putting a large number in the file
}
}
private void Load()
{
string[] contents = null;
lock (_lck)
{
try
{
contents = File.ReadAllLines(_filename);
}
catch (FileNotFoundException)
{
(File.Create(_filename)).Close();
}
}
if (contents != null && contents.Length > 0)
{
//first line is reg key
RegKey = contents[0];
//next is legacy key
if (contents.Length > 1) LegacyKey = contents[1];
//the rest of the lines should be pairs of features and timestamps
for (var i = 2; i < contents.Length; i = i + 2)
{
var feat = Guid.Parse(contents[i]);
UpdateRecords[feat] = new DateTime(Convert.ToInt64(contents[i + 1]));
}
}
}
public void Save()
{
//build our array
var lines = new List<string> {RegKey, LegacyKey};
foreach (var pair in UpdateRecords)
{
lines.Add(pair.Key.ToString());
lines.Add(pair.Value.Ticks.ToString());
}
lock(_lck) File.WriteAllLines(_filename, lines);
}
}
}

@ -0,0 +1,109 @@
using Mediabrowser.Model.Entities;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using MediaBrowser.Model.Serialization;
using System;
using System.Collections.Generic;
using System.Management;
using System.Threading;
using System.Threading.Tasks;
namespace Mediabrowser.Common.Implementations.Security
{
public static class MBRegistration
{
private static MBLicenseFile _licenseFile;
private const string MBValidateUrl = "http://mb3admin.com/admin/service/registration/validate";
private static IApplicationPaths _appPaths;
private static MBLicenseFile LicenseFile
{
get { return _licenseFile ?? (_licenseFile = new MBLicenseFile(_appPaths)); }
}
public static string SupporterKey
{
get { return LicenseFile.RegKey; }
set { LicenseFile.RegKey = value; LicenseFile.Save(); }
}
public static string LegacyKey
{
get { return LicenseFile.LegacyKey; }
set { LicenseFile.LegacyKey = value; LicenseFile.Save(); }
}
public static void Init(IApplicationPaths appPaths)
{
// Ugly alert (static init)
_appPaths = appPaths;
}
public static async Task<MBRegistrationRecord> GetRegistrationStatus(IHttpClient httpClient, IJsonSerializer jsonSerializer, string feature, string mb2Equivalent = null)
{
var mac = GetMacAddress();
var data = new Dictionary<string, string> {{"feature", feature}, {"key",SupporterKey}, {"mac",mac}, {"mb2equiv",mb2Equivalent}, {"legacykey", LegacyKey} };
var reg = new RegRecord();
try
{
using (var json = await httpClient.Post(MBValidateUrl, data, CancellationToken.None).ConfigureAwait(false))
{
reg = jsonSerializer.DeserializeFromStream<RegRecord>(json);
}
if (reg.registered)
{
LicenseFile.AddRegCheck(feature);
}
}
catch (Exception)
{
//if we have trouble obtaining from web - allow it if we've validated in the past 30 days
reg.registered = LicenseFile.LastChecked(feature) > DateTime.UtcNow.AddDays(-30);
}
return new MBRegistrationRecord {IsRegistered = reg.registered, ExpirationDate = reg.expDate, RegChecked = true};
}
/// <summary>
/// Returns MAC Address from first Network Card in Computer
/// </summary>
/// <returns>[string] MAC Address</returns>
public static string GetMacAddress()
{
var mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
var moc = mc.GetInstances();
var macAddress = String.Empty;
foreach (ManagementObject mo in moc)
{
if (macAddress == String.Empty) // only return MAC Address from first card
{
try
{
if ((bool)mo["IPEnabled"]) macAddress = mo["MacAddress"].ToString();
}
catch
{
mo.Dispose();
return "";
}
}
mo.Dispose();
}
return macAddress.Replace(":", "");
}
}
class RegRecord
{
public string featId { get; set; }
public bool registered { get; set; }
public DateTime expDate { get; set; }
}
}

@ -2,8 +2,8 @@
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Security;
using MediaBrowser.Model.Serialization;
using Mediabrowser.Common.Implementations.Security;
using Mediabrowser.Model.Entities;
using Mediabrowser.PluginSecurity;
using MediaBrowser.Common.Net;
using System;
using System.Threading;

@ -1,5 +1,4 @@
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.IO;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;
@ -33,7 +32,7 @@ namespace MediaBrowser.Controller.Entities
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public virtual string Name { get; set; }
public string Name { get; set; }
/// <summary>
/// Gets or sets the id.
@ -478,7 +477,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The end date.</value>
public DateTime? EndDate { get; set; }
/// <summary>
/// Gets or sets the display type of the media.
/// </summary>
@ -570,7 +569,7 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <value>The production locations.</value>
public List<string> ProductionLocations { get; set; }
/// <summary>
/// Gets or sets the community rating.
/// </summary>

@ -127,7 +127,7 @@ namespace MediaBrowser.Controller.Entities
/// <returns>IEnumerable{BaseItem}.</returns>
protected IEnumerable<BaseItem> GetIndexByPerformer(User user)
{
return GetIndexByPerson(user, new List<string> { PersonType.Actor, PersonType.MusicArtist }, LocalizedStrings.Instance.GetString("PerformerDispPref"));
return GetIndexByPerson(user, new List<string> { PersonType.Actor, PersonType.MusicArtist, PersonType.GuestStar }, LocalizedStrings.Instance.GetString("PerformerDispPref"));
}
/// <summary>

@ -242,7 +242,6 @@ namespace MediaBrowser.Controller.Providers
}
case "Actors":
case "GuestStars":
{
foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.Actor }))
{
@ -255,6 +254,19 @@ namespace MediaBrowser.Controller.Providers
break;
}
case "GuestStars":
{
foreach (var p in SplitNames(reader.ReadElementContentAsString()).Select(v => new PersonInfo { Name = v.Trim(), Type = PersonType.GuestStar }))
{
if (string.IsNullOrWhiteSpace(p.Name))
{
continue;
}
item.AddPerson(p);
}
break;
}
case "Trailer":
{
var val = reader.ReadElementContentAsString();

@ -63,7 +63,20 @@ namespace MediaBrowser.Controller.Providers
{
// If the IBN location exists return the last modified date of any file in it
var location = GetLocation(item);
return Directory.Exists(location) ? FileSystem.GetFiles(location).Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max() : DateTime.MinValue;
if (!Directory.Exists(location))
{
return DateTime.MinValue;
}
var files = FileSystem.GetFiles(location).ToList();
if (files.Count == 0)
{
return DateTime.MinValue;
}
return files.Select(f => f.CreationTimeUtc > f.LastWriteTimeUtc ? f.CreationTimeUtc : f.LastWriteTimeUtc).Max();
}
/// <summary>

@ -263,21 +263,21 @@ namespace MediaBrowser.Controller.Providers.TV
var actors = doc.SafeGetString("//GuestStars");
if (actors != null)
{
episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Actor", Name = str }));
episode.AddPeople(actors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.GuestStar, Name = str }));
}
var directors = doc.SafeGetString("//Director");
if (directors != null)
{
episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Director", Name = str }));
episode.AddPeople(directors.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Director, Name = str }));
}
var writers = doc.SafeGetString("//Writer");
if (writers != null)
{
episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = "Writer", Name = str }));
episode.AddPeople(writers.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(str => new PersonInfo { Type = PersonType.Writer, Name = str }));
}
if (ConfigurationManager.Configuration.SaveLocalMeta)

@ -322,7 +322,7 @@ namespace MediaBrowser.Controller.Providers.TV
personNode.AppendChild(doc.ImportNode(subNode, true));
//need to add the type
var typeNode = doc.CreateNode(XmlNodeType.Element, "Type", null);
typeNode.InnerText = "Actor";
typeNode.InnerText = PersonType.Actor;
personNode.AppendChild(typeNode);
actorsNode.AppendChild(personNode);
}

@ -4,10 +4,10 @@ namespace Mediabrowser.Model.Entities
{
public class MBRegistrationRecord
{
public DateTime ExpirationDate = DateTime.MinValue;
public bool IsRegistered = false;
public bool RegChecked = false;
public bool RegError = false;
public DateTime ExpirationDate { get; set; }
public bool IsRegistered { get; set;}
public bool RegChecked { get; set; }
public bool RegError { get; set; }
private bool? _isInTrial;
public bool TrialVersion
{

@ -26,5 +26,9 @@ namespace MediaBrowser.Model.Entities
/// The music artist
/// </summary>
public const string MusicArtist = "MusicArtist";
/// <summary>
/// The guest star
/// </summary>
public const string GuestStar = "GuestStar";
}
}

@ -120,7 +120,7 @@ namespace MediaBrowser.Model.Querying
/// If the Person filter is used, this can also be used to restrict to a specific person type
/// </summary>
/// <value>The type of the person.</value>
public string PersonType { get; set; }
public string[] PersonTypes { get; set; }
/// <summary>
/// Search characters used to find items

@ -105,6 +105,8 @@ namespace MediaBrowser.Server.Implementations.HttpServer
DefaultRedirectPath = defaultRedirectpath;
_logger = logger;
ServiceStack.Logging.LogManager.LogFactory = new NLogFactory();
EndpointHostConfig.Instance.ServiceStackHandlerFactoryPath = null;
EndpointHostConfig.Instance.MetadataRedirectPath = "metadata";
@ -136,58 +138,56 @@ namespace MediaBrowser.Server.Implementations.HttpServer
Plugins.Add(new SwaggerFeature());
Plugins.Add(new CorsFeature());
ServiceStack.Logging.LogManager.LogFactory = new NLogFactory();
ResponseFilters.Add((req, res, dto) =>
{
var exception = dto as Exception;
if (exception != null)
{
var exception = dto as Exception;
_logger.ErrorException("Error processing request for {0}", exception, req.RawUrl);
if (exception != null)
if (!string.IsNullOrEmpty(exception.Message))
{
_logger.ErrorException("Error processing request for {0}", exception, req.RawUrl);
if (!string.IsNullOrEmpty(exception.Message))
{
var error = exception.Message.Replace(Environment.NewLine, " ");
error = RemoveControlCharacters(error);
var error = exception.Message.Replace(Environment.NewLine, " ");
error = RemoveControlCharacters(error);
res.AddHeader("X-Application-Error-Code", error);
}
res.AddHeader("X-Application-Error-Code", error);
}
}
if (dto is CompressedResult)
{
// Per Google PageSpeed
// This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
// The correct version of the resource is delivered based on the client request header.
// This is a good choice for applications that are singly homed and depend on public proxies for user locality.
res.AddHeader("Vary", "Accept-Encoding");
}
if (dto is CompressedResult)
{
// Per Google PageSpeed
// This instructs the proxies to cache two versions of the resource: one compressed, and one uncompressed.
// The correct version of the resource is delivered based on the client request header.
// This is a good choice for applications that are singly homed and depend on public proxies for user locality.
res.AddHeader("Vary", "Accept-Encoding");
}
var hasOptions = dto as IHasOptions;
var hasOptions = dto as IHasOptions;
if (hasOptions != null)
if (hasOptions != null)
{
// Content length has to be explicitly set on on HttpListenerResponse or it won't be happy
string contentLength;
if (hasOptions.Options.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength))
{
// Content length has to be explicitly set on on HttpListenerResponse or it won't be happy
string contentLength;
var length = long.Parse(contentLength, UsCulture);
if (hasOptions.Options.TryGetValue("Content-Length", out contentLength) && !string.IsNullOrEmpty(contentLength))
if (length > 0)
{
var length = long.Parse(contentLength, UsCulture);
if (length > 0)
{
var response = (HttpListenerResponse) res.OriginalResponse;
var response = (HttpListenerResponse)res.OriginalResponse;
response.ContentLength64 = length;
response.ContentLength64 = length;
// Disable chunked encoding. Technically this is only needed when using Content-Range, but
// anytime we know the content length there's no need for it
response.SendChunked = false;
}
// Disable chunked encoding. Technically this is only needed when using Content-Range, but
// anytime we know the content length there's no need for it
response.SendChunked = false;
}
}
});
}
});
}
/// <summary>

@ -38,6 +38,11 @@ namespace MediaBrowser.Server.Implementations.IO
/// </summary>
private readonly ConcurrentDictionary<string,string> _tempIgnoredPaths = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Any file name ending in any of these will be ignored by the watchers
/// </summary>
private readonly List<string> _alwaysIgnoreFiles = new List<string> {"thumbs.db","small.jpg","albumart.jpg"};
/// <summary>
/// The timer lock
/// </summary>
@ -313,10 +318,18 @@ namespace MediaBrowser.Server.Implementations.IO
/// <param name="e">The <see cref="FileSystemEventArgs" /> instance containing the event data.</param>
void watcher_Changed(object sender, FileSystemEventArgs e)
{
// Ignore when someone manually creates a new folder
if (e.ChangeType == WatcherChangeTypes.Created && e.Name == "New folder")
{
return;
}
// Ignore certain files
if (_alwaysIgnoreFiles.Any(f => e.Name.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
{
return;
}
if (_tempIgnoredPaths.ContainsKey(e.FullPath))
{
Logger.Info("Watcher requested to ignore change to " + e.FullPath);

@ -696,7 +696,7 @@ namespace MediaBrowser.Server.Implementations.Library
var tasks = new List<Task>();
var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director };
var includedPersonTypes = new[] { PersonType.Actor, PersonType.Director, PersonType.GuestStar };
var people = RootFolder.RecursiveChildren
.Where(c => c.People != null)

@ -21,13 +21,13 @@ namespace MediaBrowser.WebDashboard.Api
/// Gets or sets the plugin id.
/// </summary>
/// <value>The plugin id.</value>
public Guid PluginId { get; set; }
public string PluginId { get; set; }
public ConfigurationPageInfo(IPluginConfigurationPage page)
{
Name = page.Name;
ConfigurationPageType = page.ConfigurationPageType;
PluginId = page.Plugin.Id;
PluginId = page.Plugin.Id.ToString();
}
}
}

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.72</version>
<version>3.0.75</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theatre and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.72" />
<dependency id="MediaBrowser.Common" version="3.0.74" />
<dependency id="NLog" version="2.0.0.2000" />
<dependency id="ServiceStack.Text" version="3.9.38" />
<dependency id="protobuf-net" version="2.0.0.621" />

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.72</version>
<version>3.0.75</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.72</version>
<version>3.0.75</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.72" />
<dependency id="MediaBrowser.Common" version="3.0.75" />
</dependencies>
</metadata>
<files>

Loading…
Cancel
Save