aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-14 20:05:09 -0400
committerLuke Pulverenti <luke.pulverenti@gmail.com>2014-10-14 20:05:09 -0400
commitbd1bd5e87e1744b363279577a6550afc5f2229c1 (patch)
treedcee85b1a7e0d3243702a6df6cc422f45609870f /MediaBrowser.Controller
parent52776df0129f73f7d0f87e9c51629241c5c4a7de (diff)
fixes #552 - Add parental control usage limits
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Connect/ConnectUser.cs19
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs23
-rw-r--r--MediaBrowser.Controller/Entities/ItemImageInfo.cs4
-rw-r--r--MediaBrowser.Controller/Entities/User.cs37
-rw-r--r--MediaBrowser.Controller/Entities/Video.cs23
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
6 files changed, 66 insertions, 41 deletions
diff --git a/MediaBrowser.Controller/Connect/ConnectUser.cs b/MediaBrowser.Controller/Connect/ConnectUser.cs
deleted file mode 100644
index c6a9eba552..0000000000
--- a/MediaBrowser.Controller/Connect/ConnectUser.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-
-namespace MediaBrowser.Controller.Connect
-{
- public class ConnectUser
- {
- public string Id { get; set; }
- public string Name { get; set; }
- public string Email { get; set; }
- public bool IsActive { get; set; }
- public string ImageUrl { get; set; }
- }
-
- public class ConnectUserQuery
- {
- public string Id { get; set; }
- public string Name { get; set; }
- public string Email { get; set; }
- }
-}
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index d5296d7dc6..0ecedcdda0 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -564,6 +564,11 @@ namespace MediaBrowser.Controller.Entities
return PlayAccess.None;
}
+ //if (!user.IsParentalScheduleAllowed())
+ //{
+ // return PlayAccess.None;
+ //}
+
return PlayAccess.Full;
}
@@ -1465,8 +1470,6 @@ namespace MediaBrowser.Controller.Entities
image.Path = file.FullName;
image.DateModified = imageInfo.DateModified;
- image.Width = imageInfo.Width;
- image.Height = imageInfo.Height;
}
}
@@ -1639,26 +1642,12 @@ namespace MediaBrowser.Controller.Entities
private ItemImageInfo GetImageInfo(FileSystemInfo file, ImageType type)
{
- var info = new ItemImageInfo
+ return new ItemImageInfo
{
Path = file.FullName,
Type = type,
DateModified = FileSystem.GetLastWriteTimeUtc(file)
};
-
- try
- {
- var size = ImageProcessor.GetImageSize(info.Path);
-
- info.Width = Convert.ToInt32(size.Width);
- info.Height = Convert.ToInt32(size.Height);
- }
- catch
- {
-
- }
-
- return info;
}
/// <summary>
diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs
index fe1f0598a0..80aec64824 100644
--- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs
+++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs
@@ -10,9 +10,5 @@ namespace MediaBrowser.Controller.Entities
public ImageType Type { get; set; }
public DateTime DateModified { get; set; }
-
- public int? Width { get; set; }
-
- public int? Height { get; set; }
}
}
diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs
index 2275cbad42..6ba8701f74 100644
--- a/MediaBrowser.Controller/Entities/User.cs
+++ b/MediaBrowser.Controller/Entities/User.cs
@@ -6,6 +6,7 @@ using MediaBrowser.Model.Connect;
using MediaBrowser.Model.Serialization;
using System;
using System.IO;
+using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
using System.Threading.Tasks;
@@ -259,5 +260,41 @@ namespace MediaBrowser.Controller.Entities
Configuration = config;
UserManager.UpdateConfiguration(this, Configuration);
}
+
+ public bool IsParentalScheduleAllowed()
+ {
+ return IsParentalScheduleAllowed(DateTime.UtcNow);
+ }
+
+ public bool IsParentalScheduleAllowed(DateTime date)
+ {
+ var schedules = Configuration.AccessSchedules;
+
+ if (schedules.Length == 0)
+ {
+ return true;
+ }
+
+ return schedules.Any(i => IsParentalScheduleAllowed(i, date));
+ }
+
+ private bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date)
+ {
+ if (date.Kind != DateTimeKind.Utc)
+ {
+ throw new ArgumentException("Utc date expected");
+ }
+
+ var localTime = date.ToLocalTime();
+
+ return localTime.DayOfWeek == schedule.DayOfWeek && IsWithinTime(schedule, localTime);
+ }
+
+ private bool IsWithinTime(AccessSchedule schedule, DateTime localTime)
+ {
+ var hour = localTime.TimeOfDay.TotalHours;
+
+ return hour >= schedule.StartHour && hour <= schedule.EndHour;
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs
index dc9769d53f..f4104b29d1 100644
--- a/MediaBrowser.Controller/Entities/Video.cs
+++ b/MediaBrowser.Controller/Entities/Video.cs
@@ -129,6 +129,7 @@ namespace MediaBrowser.Controller.Entities
public bool IsPlaceHolder { get; set; }
public bool IsShortcut { get; set; }
+ public string ShortcutPath { get; set; }
/// <summary>
/// Gets or sets the tags.
@@ -578,6 +579,28 @@ namespace MediaBrowser.Controller.Entities
PlayableStreamFileNames = i.PlayableStreamFileNames.ToList()
};
+ if (i.IsShortcut)
+ {
+ info.Path = i.ShortcutPath;
+
+ if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase))
+ {
+ info.Protocol = MediaProtocol.Http;
+ }
+ else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase))
+ {
+ info.Protocol = MediaProtocol.Rtmp;
+ }
+ else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase))
+ {
+ info.Protocol = MediaProtocol.Rtsp;
+ }
+ else
+ {
+ info.Protocol = MediaProtocol.File;
+ }
+ }
+
if (string.IsNullOrEmpty(info.Container))
{
if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso)
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index a49d00e875..8ae605b629 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -99,7 +99,6 @@
<Compile Include="Collections\CollectionCreationOptions.cs" />
<Compile Include="Collections\CollectionEvents.cs" />
<Compile Include="Collections\ICollectionManager.cs" />
- <Compile Include="Connect\ConnectUser.cs" />
<Compile Include="Connect\IConnectManager.cs" />
<Compile Include="Connect\UserLinkResult.cs" />
<Compile Include="Devices\IDeviceManager.cs" />