aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Library
diff options
context:
space:
mode:
author7illusions <z@7illusions.com>2014-08-30 19:06:58 +0200
committer7illusions <z@7illusions.com>2014-08-30 19:06:58 +0200
commit66ad1699e22029b605e17735e8d9450285d8748a (patch)
treeffc92c88d24850b2f82b6b3a8bdd904a2ccc77a5 /MediaBrowser.Controller/Library
parent34bc54263e886aae777a3537dc50a6535b51330a (diff)
parent9d36f518182bc075c19d78084870f5115fa62d1e (diff)
Merge pull request #1 from MediaBrowser/master
Update to latest
Diffstat (limited to 'MediaBrowser.Controller/Library')
-rw-r--r--MediaBrowser.Controller/Library/IUserDataManager.cs9
-rw-r--r--MediaBrowser.Controller/Library/IUserManager.cs17
-rw-r--r--MediaBrowser.Controller/Library/IUserViewManager.cs2
-rw-r--r--MediaBrowser.Controller/Library/TVUtils.cs131
4 files changed, 139 insertions, 20 deletions
diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs
index 2bec9e3de..9db91e7f2 100644
--- a/MediaBrowser.Controller/Library/IUserDataManager.cs
+++ b/MediaBrowser.Controller/Library/IUserDataManager.cs
@@ -1,4 +1,5 @@
using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Threading;
@@ -34,5 +35,13 @@ namespace MediaBrowser.Controller.Library
/// <param name="key">The key.</param>
/// <returns>Task{UserItemData}.</returns>
UserItemData GetUserData(Guid userId, string key);
+
+ /// <summary>
+ /// Gets the user data dto.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <param name="user">The user.</param>
+ /// <returns>UserItemDataDto.</returns>
+ UserItemDataDto GetUserDataDto(IHasUserData item, User user);
}
}
diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs
index 010caa233..a5d949c8a 100644
--- a/MediaBrowser.Controller/Library/IUserManager.cs
+++ b/MediaBrowser.Controller/Library/IUserManager.cs
@@ -1,5 +1,6 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Events;
using System;
using System.Collections.Generic;
@@ -31,6 +32,7 @@ namespace MediaBrowser.Controller.Library
event EventHandler<GenericEventArgs<User>> UserCreated;
event EventHandler<GenericEventArgs<User>> UserConfigurationUpdated;
+ event EventHandler<GenericEventArgs<User>> UserPasswordChanged;
/// <summary>
/// Updates the configuration.
@@ -50,12 +52,13 @@ namespace MediaBrowser.Controller.Library
/// <summary>
/// Authenticates a User and returns a result indicating whether or not it succeeded
/// </summary>
- /// <param name="user">The user.</param>
+ /// <param name="username">The username.</param>
/// <param name="password">The password.</param>
+ /// <param name="remoteEndPoint">The remote end point.</param>
/// <returns>Task{System.Boolean}.</returns>
/// <exception cref="System.ArgumentNullException">user</exception>
- Task<bool> AuthenticateUser(User user, string password);
-
+ Task<bool> AuthenticateUser(string username, string password, string remoteEndPoint);
+
/// <summary>
/// Refreshes metadata for each user
/// </summary>
@@ -113,5 +116,13 @@ namespace MediaBrowser.Controller.Library
/// <param name="newPassword">The new password.</param>
/// <returns>Task.</returns>
Task ChangePassword(User user, string newPassword);
+
+ /// <summary>
+ /// Gets the user dto.
+ /// </summary>
+ /// <param name="user">The user.</param>
+ /// <param name="remoteEndPoint">The remote end point.</param>
+ /// <returns>UserDto.</returns>
+ UserDto GetUserDto(User user, string remoteEndPoint = null);
}
}
diff --git a/MediaBrowser.Controller/Library/IUserViewManager.cs b/MediaBrowser.Controller/Library/IUserViewManager.cs
index 7c352d97a..908525a2f 100644
--- a/MediaBrowser.Controller/Library/IUserViewManager.cs
+++ b/MediaBrowser.Controller/Library/IUserViewManager.cs
@@ -9,5 +9,7 @@ namespace MediaBrowser.Controller.Library
public interface IUserViewManager
{
Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken);
+
+ Task<UserView> GetUserView(string type, User user, string sortName, CancellationToken cancellationToken);
}
}
diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs
index 64f3a3b4b..34486182b 100644
--- a/MediaBrowser.Controller/Library/TVUtils.cs
+++ b/MediaBrowser.Controller/Library/TVUtils.cs
@@ -1,4 +1,5 @@
-using MediaBrowser.Controller.Entities;
+using MediaBrowser.Common.IO;
+using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Resolvers;
using System;
@@ -7,6 +8,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
+using MediaBrowser.Model.Logging;
namespace MediaBrowser.Controller.Library
{
@@ -98,19 +100,19 @@ namespace MediaBrowser.Controller.Library
private static readonly Regex[] EpisodeExpressionsWithoutSeason =
{
new Regex(
- @".*[\\\/](?<epnumber>\d{1,3})\.\w+$",
+ @".*[\\\/](?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.\w+$",
RegexOptions.Compiled),
// "01.avi"
new Regex(
- @".*(\\|\/)(?<epnumber>\d{1,2})\s?-\s?[^\\\/]*$",
+ @".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\s?-\s?[^\\\/]*$",
RegexOptions.Compiled),
// "01 - blah.avi", "01-blah.avi"
new Regex(
- @".*(\\|\/)(?<epnumber>\d{1,2})\.[^\\\/]+$",
+ @".*(\\|\/)(?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*\.[^\\\/]+$",
RegexOptions.Compiled),
// "01.blah.avi"
new Regex(
- @".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})[^\\\/]*$",
+ @".*[\\\/][^\\\/]* - (?<epnumber>\d{1,3})(-(?<endingepnumber>\d{2,3}))*[^\\\/]*$",
RegexOptions.Compiled),
// "blah - 01.avi", "blah 2 - 01.avi", "blah - 01 blah.avi", "blah 2 - 01 blah", "blah - 01 - blah.avi", "blah 2 - 01 - blah"
};
@@ -124,11 +126,27 @@ namespace MediaBrowser.Controller.Library
{
var filename = Path.GetFileName(path);
- if (string.Equals(path, "specials", StringComparison.OrdinalIgnoreCase))
+ if (string.Equals(filename, "specials", StringComparison.OrdinalIgnoreCase))
{
return 0;
}
+ int val;
+ if (int.TryParse(filename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
+ {
+ return val;
+ }
+
+ if (filename.StartsWith("s", StringComparison.OrdinalIgnoreCase))
+ {
+ var testFilename = filename.Substring(1);
+
+ if (int.TryParse(testFilename, NumberStyles.Integer, CultureInfo.InvariantCulture, out val))
+ {
+ return val;
+ }
+ }
+
// Look for one of the season folder names
foreach (var name in SeasonFolderNames)
{
@@ -175,7 +193,7 @@ namespace MediaBrowser.Controller.Library
return null;
}
- return int.Parse(path.Substring(numericStart, length));
+ return int.Parse(path.Substring(numericStart, length), CultureInfo.InvariantCulture);
}
/// <summary>
@@ -183,20 +201,64 @@ namespace MediaBrowser.Controller.Library
/// </summary>
/// <param name="path">The path.</param>
/// <param name="directoryService">The directory service.</param>
+ /// <param name="fileSystem">The file system.</param>
/// <returns><c>true</c> if [is season folder] [the specified path]; otherwise, <c>false</c>.</returns>
- private static bool IsSeasonFolder(string path, IDirectoryService directoryService)
+ private static bool IsSeasonFolder(string path, IDirectoryService directoryService, IFileSystem fileSystem)
{
+ var seasonNumber = GetSeasonNumberFromPath(path);
+ var hasSeasonNumber = seasonNumber != null;
+
+ if (!hasSeasonNumber)
+ {
+ return false;
+ }
+
// It's a season folder if it's named as such and does not contain any audio files, apart from theme.mp3
- return GetSeasonNumberFromPath(path) != null && !directoryService.GetFiles(path).Any(i => EntityResolutionHelper.IsAudioFile(i.FullName) && !string.Equals(Path.GetFileNameWithoutExtension(i.FullName), BaseItem.ThemeSongFilename));
+ foreach (var fileSystemInfo in directoryService.GetFileSystemEntries(path))
+ {
+ var attributes = fileSystemInfo.Attributes;
+
+ if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
+ {
+ continue;
+ }
+
+ // Can't enforce this because files saved by Bitcasa are always marked System
+ //if ((attributes & FileAttributes.System) == FileAttributes.System)
+ //{
+ // continue;
+ //}
+
+ if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
+ {
+ //if (IsBadFolder(fileSystemInfo.Name))
+ //{
+ // return false;
+ //}
+ }
+ else
+ {
+ if (EntityResolutionHelper.IsAudioFile(fileSystemInfo.FullName) &&
+ !string.Equals(fileSystem.GetFileNameWithoutExtension(fileSystemInfo), BaseItem.ThemeSongFilename))
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
}
/// <summary>
/// Determines whether [is series folder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
+ /// <param name="considerSeasonlessEntries">if set to <c>true</c> [consider seasonless entries].</param>
/// <param name="fileSystemChildren">The file system children.</param>
+ /// <param name="directoryService">The directory service.</param>
+ /// <param name="fileSystem">The file system.</param>
/// <returns><c>true</c> if [is series folder] [the specified path]; otherwise, <c>false</c>.</returns>
- public static bool IsSeriesFolder(string path, bool considerSeasonlessSeries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService)
+ public static bool IsSeriesFolder(string path, bool considerSeasonlessEntries, IEnumerable<FileSystemInfo> fileSystemChildren, IDirectoryService directoryService, IFileSystem fileSystem, ILogger logger)
{
// A folder with more than 3 non-season folders in will not becounted as a series
var nonSeriesFolders = 0;
@@ -207,25 +269,35 @@ namespace MediaBrowser.Controller.Library
if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
{
+ //logger.Debug("Igoring series file or folder marked hidden: {0}", child.FullName);
continue;
}
- if ((attributes & FileAttributes.System) == FileAttributes.System)
- {
- continue;
- }
+ // Can't enforce this because files saved by Bitcasa are always marked System
+ //if ((attributes & FileAttributes.System) == FileAttributes.System)
+ //{
+ // logger.Debug("Igoring series subfolder marked system: {0}", child.FullName);
+ // continue;
+ //}
if ((attributes & FileAttributes.Directory) == FileAttributes.Directory)
{
- if (IsSeasonFolder(child.FullName, directoryService))
+ if (IsSeasonFolder(child.FullName, directoryService, fileSystem))
{
+ logger.Debug("{0} is a series because of season folder {1}.", path, child.FullName);
return true;
}
- nonSeriesFolders++;
+ if (IsBadFolder(child.Name))
+ {
+ logger.Debug("Invalid folder under series: {0}", child.FullName);
+
+ nonSeriesFolders++;
+ }
if (nonSeriesFolders >= 3)
{
+ logger.Debug("{0} not a series due to 3 or more invalid folders.", path);
return false;
}
}
@@ -235,7 +307,7 @@ namespace MediaBrowser.Controller.Library
if (EntityResolutionHelper.IsVideoFile(fullName) || EntityResolutionHelper.IsVideoPlaceHolder(fullName))
{
- if (GetEpisodeNumberFromFile(fullName, considerSeasonlessSeries).HasValue)
+ if (GetEpisodeNumberFromFile(fullName, considerSeasonlessEntries).HasValue)
{
return true;
}
@@ -243,9 +315,28 @@ namespace MediaBrowser.Controller.Library
}
}
+ logger.Debug("{0} is not a series folder.", path);
return false;
}
+ private static bool IsBadFolder(string name)
+ {
+ if (string.Equals(name, BaseItem.ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (string.Equals(name, BaseItem.ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+ if (string.Equals(name, BaseItem.TrailerFolderName, StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ return !EntityResolutionHelper.IgnoreFolders.Contains(name, StringComparer.OrdinalIgnoreCase);
+ }
+
/// <summary>
/// Episodes the number from file.
/// </summary>
@@ -284,6 +375,12 @@ namespace MediaBrowser.Controller.Library
if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
}
+ foreach (var r in EpisodeExpressionsWithoutSeason)
+ {
+ var m = r.Match(fl);
+ if (m.Success && !string.IsNullOrEmpty(m.Groups["endingepnumber"].Value))
+ return ParseEpisodeNumber(m.Groups["endingepnumber"].Value);
+ }
return null;
}