aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-19 16:51:32 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2013-12-19 16:51:32 -0500
commitcd859ac2e6d499ce2cdf531058e64a4c3402910f (patch)
treee453d21e99ef2d6aee7f5e4af668a69147b31dfd /MediaBrowser.Controller
parente1e5d354345008e8d4ddc2dbbb99a68df4133280 (diff)
added IHasImages and IHasUserData
Diffstat (limited to 'MediaBrowser.Controller')
-rw-r--r--MediaBrowser.Controller/Drawing/IImageProcessor.cs8
-rw-r--r--MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs2
-rw-r--r--MediaBrowser.Controller/Entities/BaseItem.cs69
-rw-r--r--MediaBrowser.Controller/Entities/IHasImages.cs97
-rw-r--r--MediaBrowser.Controller/Entities/IHasUserData.cs15
-rw-r--r--MediaBrowser.Controller/Entities/TV/Series.cs4
-rw-r--r--MediaBrowser.Controller/Library/IUserDataManager.cs2
-rw-r--r--MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs2
-rw-r--r--MediaBrowser.Controller/LiveTv/Channel.cs75
-rw-r--r--MediaBrowser.Controller/LiveTv/ChannelInfo.cs12
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvManager.cs10
-rw-r--r--MediaBrowser.Controller/LiveTv/ILiveTvService.cs6
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvChannel.cs57
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvProgram.cs33
-rw-r--r--MediaBrowser.Controller/LiveTv/LiveTvRecording.cs43
-rw-r--r--MediaBrowser.Controller/LiveTv/ProgramInfo.cs20
-rw-r--r--MediaBrowser.Controller/LiveTv/RecordingInfo.cs12
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj6
-rw-r--r--MediaBrowser.Controller/MediaInfo/FFMpegManager.cs26
-rw-r--r--MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs40
-rw-r--r--MediaBrowser.Controller/Providers/IImageEnhancer.cs8
21 files changed, 377 insertions, 170 deletions
diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs
index 1a8583489..2ecf3ec9a 100644
--- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs
+++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs
@@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns>IEnumerable{IImageEnhancer}.</returns>
- IEnumerable<IImageEnhancer> GetSupportedEnhancers(BaseItem item, ImageType imageType);
+ IEnumerable<IImageEnhancer> GetSupportedEnhancers(IHasImages item, ImageType imageType);
/// <summary>
/// Gets the image cache tag.
@@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="imageType">Type of the image.</param>
/// <param name="imagePath">The image path.</param>
/// <returns>Guid.</returns>
- Guid GetImageCacheTag(BaseItem item, ImageType imageType, string imagePath);
+ Guid GetImageCacheTag(IHasImages item, ImageType imageType, string imagePath);
/// <summary>
/// Gets the image cache tag.
@@ -67,7 +67,7 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="dateModified">The date modified.</param>
/// <param name="imageEnhancers">The image enhancers.</param>
/// <returns>Guid.</returns>
- Guid GetImageCacheTag(BaseItem item, ImageType imageType, string originalImagePath, DateTime dateModified,
+ Guid GetImageCacheTag(IHasImages item, ImageType imageType, string originalImagePath, DateTime dateModified,
List<IImageEnhancer> imageEnhancers);
/// <summary>
@@ -85,6 +85,6 @@ namespace MediaBrowser.Controller.Drawing
/// <param name="imageType">Type of the image.</param>
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{System.String}.</returns>
- Task<string> GetEnhancedImage(BaseItem item, ImageType imageType, int imageIndex);
+ Task<string> GetEnhancedImage(IHasImages item, ImageType imageType, int imageIndex);
}
}
diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
index ce4bf6c32..506d6fd3d 100644
--- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
+++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs
@@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Drawing
{
public class ImageProcessingOptions
{
- public BaseItem Item { get; set; }
+ public IHasImages Item { get; set; }
public ImageType ImageType { get; set; }
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs
index 541887598..2aa3e5ecc 100644
--- a/MediaBrowser.Controller/Entities/BaseItem.cs
+++ b/MediaBrowser.Controller/Entities/BaseItem.cs
@@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Class BaseItem
/// </summary>
- public abstract class BaseItem : IHasProviderIds, ILibraryItem
+ public abstract class BaseItem : IHasProviderIds, ILibraryItem, IHasImages, IHasUserData
{
protected BaseItem()
{
@@ -132,8 +132,8 @@ namespace MediaBrowser.Controller.Entities
[IgnoreDataMember]
public string PrimaryImagePath
{
- get { return GetImage(ImageType.Primary); }
- set { SetImage(ImageType.Primary, value); }
+ get { return this.GetImagePath(ImageType.Primary); }
+ set { this.SetImagePath(ImageType.Primary, value); }
}
/// <summary>
@@ -1310,31 +1310,10 @@ namespace MediaBrowser.Controller.Entities
/// Gets an image
/// </summary>
/// <param name="type">The type.</param>
- /// <returns>System.String.</returns>
- /// <exception cref="System.ArgumentException">Backdrops should be accessed using Item.Backdrops</exception>
- public string GetImage(ImageType type)
- {
- if (type == ImageType.Backdrop)
- {
- throw new ArgumentException("Backdrops should be accessed using Item.Backdrops");
- }
- if (type == ImageType.Screenshot)
- {
- throw new ArgumentException("Screenshots should be accessed using Item.Screenshots");
- }
-
- string val;
- Images.TryGetValue(type, out val);
- return val;
- }
-
- /// <summary>
- /// Gets an image
- /// </summary>
- /// <param name="type">The type.</param>
+ /// <param name="imageIndex">Index of the image.</param>
/// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentException">Backdrops should be accessed using Item.Backdrops</exception>
- public bool HasImage(ImageType type)
+ public bool HasImage(ImageType type, int imageIndex)
{
if (type == ImageType.Backdrop)
{
@@ -1345,16 +1324,10 @@ namespace MediaBrowser.Controller.Entities
throw new ArgumentException("Screenshots should be accessed using Item.Screenshots");
}
- return !string.IsNullOrEmpty(GetImage(type));
+ return !string.IsNullOrEmpty(this.GetImagePath(type));
}
- /// <summary>
- /// Sets an image
- /// </summary>
- /// <param name="type">The type.</param>
- /// <param name="path">The path.</param>
- /// <exception cref="System.ArgumentException">Backdrops should be accessed using Item.Backdrops</exception>
- public void SetImage(ImageType type, string path)
+ public void SetImagePath(ImageType type, int index, string path)
{
if (type == ImageType.Backdrop)
{
@@ -1423,10 +1396,10 @@ namespace MediaBrowser.Controller.Entities
else
{
// Delete the source file
- DeleteImagePath(GetImage(type));
+ DeleteImagePath(this.GetImagePath(type));
// Remove it from the item
- SetImage(type, null);
+ this.SetImagePath(type, null);
}
// Refresh metadata
@@ -1597,13 +1570,13 @@ namespace MediaBrowser.Controller.Entities
{
if (imageType == ImageType.Backdrop)
{
- return BackdropImagePaths[imageIndex];
+ return BackdropImagePaths.Count > imageIndex ? BackdropImagePaths[imageIndex] : null;
}
if (imageType == ImageType.Screenshot)
{
var hasScreenshots = (IHasScreenshots)this;
- return hasScreenshots.ScreenshotImagePaths[imageIndex];
+ return hasScreenshots.ScreenshotImagePaths.Count > imageIndex ? hasScreenshots.ScreenshotImagePaths[imageIndex] : null;
}
if (imageType == ImageType.Chapter)
@@ -1611,7 +1584,9 @@ namespace MediaBrowser.Controller.Entities
return ItemRepository.GetChapter(Id, imageIndex).ImagePath;
}
- return GetImage(imageType);
+ string val;
+ Images.TryGetValue(imageType, out val);
+ return val;
}
/// <summary>
@@ -1658,5 +1633,21 @@ namespace MediaBrowser.Controller.Entities
{
return new[] { Path };
}
+
+ public Task SwapImages(ImageType type, int index1, int index2)
+ {
+ if (type != ImageType.Screenshot && type != ImageType.Backdrop)
+ {
+ throw new ArgumentException("The change index operation is only applicable to backdrops and screenshots");
+ }
+
+ var file1 = GetImagePath(type, index1);
+ var file2 = GetImagePath(type, index2);
+
+ FileSystem.SwapFiles(file1, file2);
+
+ // Directory watchers should repeat this, but do a quick refresh first
+ return RefreshMetadata(CancellationToken.None, forceSave: true, allowSlowProviders: false);
+ }
}
}
diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs
new file mode 100644
index 000000000..f8cbfc6ab
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasImages.cs
@@ -0,0 +1,97 @@
+using MediaBrowser.Model.Entities;
+using System;
+using System.Threading.Tasks;
+
+namespace MediaBrowser.Controller.Entities
+{
+ public interface IHasImages
+ {
+ /// <summary>
+ /// Gets the name.
+ /// </summary>
+ /// <value>The name.</value>
+ string Name { get; }
+
+ /// <summary>
+ /// Gets the path.
+ /// </summary>
+ /// <value>The path.</value>
+ string Path { get; }
+
+ /// <summary>
+ /// Gets the identifier.
+ /// </summary>
+ /// <value>The identifier.</value>
+ Guid Id { get; }
+
+ /// <summary>
+ /// Gets the image path.
+ /// </summary>
+ /// <param name="imageType">Type of the image.</param>
+ /// <param name="imageIndex">Index of the image.</param>
+ /// <returns>System.String.</returns>
+ string GetImagePath(ImageType imageType, int imageIndex);
+
+ /// <summary>
+ /// Gets the image date modified.
+ /// </summary>
+ /// <param name="imagePath">The image path.</param>
+ /// <returns>DateTime.</returns>
+ DateTime GetImageDateModified(string imagePath);
+
+ /// <summary>
+ /// Sets the image.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="index">The index.</param>
+ /// <param name="path">The path.</param>
+ void SetImagePath(ImageType type, int index, string path);
+
+ /// <summary>
+ /// Determines whether the specified type has image.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="imageIndex">Index of the image.</param>
+ /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns>
+ bool HasImage(ImageType type, int imageIndex);
+
+ /// <summary>
+ /// Swaps the images.
+ /// </summary>
+ /// <param name="type">The type.</param>
+ /// <param name="index1">The index1.</param>
+ /// <param name="index2">The index2.</param>
+ /// <returns>Task.</returns>
+ Task SwapImages(ImageType type, int index1, int index2);
+ }
+
+ public static class HasImagesExtensions
+ {
+ /// <summary>
+ /// Gets the image path.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <param name="imageType">Type of the image.</param>
+ /// <returns>System.String.</returns>
+ public static string GetImagePath(this IHasImages item, ImageType imageType)
+ {
+ return item.GetImagePath(imageType, 0);
+ }
+
+ public static bool HasImage(this IHasImages item, ImageType imageType)
+ {
+ return item.HasImage(imageType, 0);
+ }
+
+ /// <summary>
+ /// Sets the image path.
+ /// </summary>
+ /// <param name="item">The item.</param>
+ /// <param name="imageType">Type of the image.</param>
+ /// <param name="path">The path.</param>
+ public static void SetImagePath(this IHasImages item, ImageType imageType, string path)
+ {
+ item.SetImagePath(imageType, 0, path);
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/IHasUserData.cs b/MediaBrowser.Controller/Entities/IHasUserData.cs
new file mode 100644
index 000000000..780181a61
--- /dev/null
+++ b/MediaBrowser.Controller/Entities/IHasUserData.cs
@@ -0,0 +1,15 @@
+
+namespace MediaBrowser.Controller.Entities
+{
+ /// <summary>
+ /// Interface IHasUserData
+ /// </summary>
+ public interface IHasUserData
+ {
+ /// <summary>
+ /// Gets the user data key.
+ /// </summary>
+ /// <returns>System.String.</returns>
+ string GetUserDataKey();
+ }
+}
diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs
index 1565de4f8..71785fa7a 100644
--- a/MediaBrowser.Controller/Entities/TV/Series.cs
+++ b/MediaBrowser.Controller/Entities/TV/Series.cs
@@ -183,7 +183,9 @@ namespace MediaBrowser.Controller.Entities.TV
episodes = episodes.Where(i => !i.IsVirtualUnaired);
}
- return LibraryManager.Sort(episodes, user, new[] { ItemSortBy.AiredEpisodeOrder }, SortOrder.Ascending)
+ var sortBy = seasonNumber == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder;
+
+ return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending)
.Cast<Episode>();
}
diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs
index d6d5f99aa..2bec9e3de 100644
--- a/MediaBrowser.Controller/Library/IUserDataManager.cs
+++ b/MediaBrowser.Controller/Library/IUserDataManager.cs
@@ -25,7 +25,7 @@ namespace MediaBrowser.Controller.Library
/// <param name="reason">The reason.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
- Task SaveUserData(Guid userId, BaseItem item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken);
+ Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken);
/// <summary>
/// Gets the user data.
diff --git a/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs b/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs
index 87e7f647a..ba328ff75 100644
--- a/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs
+++ b/MediaBrowser.Controller/Library/UserDataSaveEventArgs.cs
@@ -37,6 +37,6 @@ namespace MediaBrowser.Controller.Library
/// Gets or sets the item.
/// </summary>
/// <value>The item.</value>
- public BaseItem Item { get; set; }
+ public IHasUserData Item { get; set; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/Channel.cs b/MediaBrowser.Controller/LiveTv/Channel.cs
deleted file mode 100644
index 7186cfaf3..000000000
--- a/MediaBrowser.Controller/LiveTv/Channel.cs
+++ /dev/null
@@ -1,75 +0,0 @@
-using MediaBrowser.Controller.Entities;
-using MediaBrowser.Model.Dto;
-using MediaBrowser.Model.LiveTv;
-using System;
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-
-namespace MediaBrowser.Controller.LiveTv
-{
- public class Channel : BaseItem, IItemByName
- {
- public Channel()
- {
- UserItemCountList = new List<ItemByNameCounts>();
- }
-
- /// <summary>
- /// Gets the user data key.
- /// </summary>
- /// <returns>System.String.</returns>
- public override string GetUserDataKey()
- {
- return "Channel-" + Name;
- }
-
- [IgnoreDataMember]
- public List<ItemByNameCounts> UserItemCountList { get; set; }
-
- /// <summary>
- /// Gets or sets the number.
- /// </summary>
- /// <value>The number.</value>
- public string ChannelNumber { get; set; }
-
- /// <summary>
- /// Get or sets the Id.
- /// </summary>
- /// <value>The id of the channel.</value>
- public string ChannelId { get; set; }
-
- /// <summary>
- /// Gets or sets the name of the service.
- /// </summary>
- /// <value>The name of the service.</value>
- public string ServiceName { get; set; }
-
- /// <summary>
- /// Gets or sets the type of the channel.
- /// </summary>
- /// <value>The type of the channel.</value>
- public ChannelType ChannelType { get; set; }
-
- public bool? HasProviderImage { get; set; }
-
- protected override string CreateSortName()
- {
- double number = 0;
-
- if (!string.IsNullOrEmpty(ChannelNumber))
- {
- double.TryParse(ChannelNumber, out number);
- }
-
- return number.ToString("000-") + (Name ?? string.Empty);
- }
-
- public override string MediaType
- {
- get
- {
- return ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
- }
- }
- }
-}
diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs
index bb0636673..9bc37fcc0 100644
--- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs
@@ -32,9 +32,15 @@ namespace MediaBrowser.Controller.LiveTv
public ChannelType ChannelType { get; set; }
/// <summary>
- /// Set this value to true or false if it is known via channel info whether there is an image or not.
- /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+ /// Supply the image path if it can be accessed directly from the file system
/// </summary>
- public bool? HasImage { get; set; }
+ /// <value>The image path.</value>
+ public string ImagePath { get; set; }
+
+ /// <summary>
+ /// Supply the image url if it can be downloaded
+ /// </summary>
+ /// <value>The image URL.</value>
+ public string ImageUrl { get; set; }
}
}
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
index 8e711d28c..e7226e9b5 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs
@@ -144,9 +144,17 @@ namespace MediaBrowser.Controller.LiveTv
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>Channel.</returns>
- Channel GetChannel(string id);
+ LiveTvChannel GetInternalChannel(string id);
/// <summary>
+ /// Gets the recording.
+ /// </summary>
+ /// <param name="id">The identifier.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
+ /// <returns>LiveTvRecording.</returns>
+ Task<LiveTvRecording> GetInternalRecording(string id, CancellationToken cancellationToken);
+
+ /// <summary>
/// Gets the program.
/// </summary>
/// <param name="id">The identifier.</param>
diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
index 2cd768a93..1c88629f0 100644
--- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
+++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs
@@ -79,7 +79,7 @@ namespace MediaBrowser.Controller.LiveTv
Task UpdateSeriesTimerAsync(SeriesTimerInfo info, CancellationToken cancellationToken);
/// <summary>
- /// Gets the channel image asynchronous.
+ /// Gets the channel image asynchronous. This only needs to be implemented if an image path or url cannot be supplied to ChannelInfo
/// </summary>
/// <param name="channelId">The channel identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
@@ -87,7 +87,7 @@ namespace MediaBrowser.Controller.LiveTv
Task<ImageResponseInfo> GetChannelImageAsync(string channelId, CancellationToken cancellationToken);
/// <summary>
- /// Gets the recording image asynchronous.
+ /// Gets the recording image asynchronous. This only needs to be implemented if an image path or url cannot be supplied to RecordingInfo
/// </summary>
/// <param name="recordingId">The recording identifier.</param>
/// <param name="cancellationToken">The cancellation token.</param>
@@ -95,7 +95,7 @@ namespace MediaBrowser.Controller.LiveTv
Task<ImageResponseInfo> GetRecordingImageAsync(string recordingId, CancellationToken cancellationToken);
/// <summary>
- /// Gets the program image asynchronous.
+ /// Gets the program image asynchronous. This only needs to be implemented if an image path or url cannot be supplied to ProgramInfo
/// </summary>
/// <param name="programId">The program identifier.</param>
/// <param name="channelId">The channel identifier.</param>
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
new file mode 100644
index 000000000..1e6d74ce8
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs
@@ -0,0 +1,57 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Dto;
+using MediaBrowser.Model.LiveTv;
+using System.Collections.Generic;
+using System.Runtime.Serialization;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ public class LiveTvChannel : BaseItem, IItemByName
+ {
+ public LiveTvChannel()
+ {
+ UserItemCountList = new List<ItemByNameCounts>();
+ }
+
+ /// <summary>
+ /// Gets the user data key.
+ /// </summary>
+ /// <returns>System.String.</returns>
+ public override string GetUserDataKey()
+ {
+ return GetClientTypeName() + "-" + Name;
+ }
+
+ [IgnoreDataMember]
+ public List<ItemByNameCounts> UserItemCountList { get; set; }
+
+ public ChannelInfo ChannelInfo { get; set; }
+
+ public string ServiceName { get; set; }
+
+ protected override string CreateSortName()
+ {
+ double number = 0;
+
+ if (!string.IsNullOrEmpty(ChannelInfo.Number))
+ {
+ double.TryParse(ChannelInfo.Number, out number);
+ }
+
+ return number.ToString("000-") + (Name ?? string.Empty);
+ }
+
+ public override string MediaType
+ {
+ get
+ {
+ return ChannelInfo.ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
+ }
+ }
+
+ public override string GetClientTypeName()
+ {
+ return "Channel";
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
new file mode 100644
index 000000000..babd9f54c
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs
@@ -0,0 +1,33 @@
+using MediaBrowser.Controller.Entities;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ public class LiveTvProgram : BaseItem
+ {
+ /// <summary>
+ /// Gets the user data key.
+ /// </summary>
+ /// <returns>System.String.</returns>
+ public override string GetUserDataKey()
+ {
+ return GetClientTypeName() + "-" + Name;
+ }
+
+ public ProgramInfo ProgramInfo { get; set; }
+
+ public string ServiceName { get; set; }
+
+ public override string MediaType
+ {
+ get
+ {
+ return ProgramInfo.IsVideo ? Model.Entities.MediaType.Video : Model.Entities.MediaType.Audio;
+ }
+ }
+
+ public override string GetClientTypeName()
+ {
+ return "Program";
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/LiveTv/LiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvRecording.cs
new file mode 100644
index 000000000..1c453ab5a
--- /dev/null
+++ b/MediaBrowser.Controller/LiveTv/LiveTvRecording.cs
@@ -0,0 +1,43 @@
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Entities;
+using MediaBrowser.Model.LiveTv;
+
+namespace MediaBrowser.Controller.LiveTv
+{
+ public class LiveTvRecording : BaseItem
+ {
+ /// <summary>
+ /// Gets the user data key.
+ /// </summary>
+ /// <returns>System.String.</returns>
+ public override string GetUserDataKey()
+ {
+ return GetClientTypeName() + "-" + Name;
+ }
+
+ public RecordingInfo RecordingInfo { get; set; }
+
+ public string ServiceName { get; set; }
+
+ public override string MediaType
+ {
+ get
+ {
+ return RecordingInfo.ChannelType == ChannelType.Radio ? Model.Entities.MediaType.Audio : Model.Entities.MediaType.Video;
+ }
+ }
+
+ public override LocationType LocationType
+ {
+ get
+ {
+ return LocationType.Remote;
+ }
+ }
+
+ public override string GetClientTypeName()
+ {
+ return "Recording";
+ }
+ }
+}
diff --git a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
index 15b55f50e..959f67740 100644
--- a/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/ProgramInfo.cs
@@ -98,10 +98,16 @@ namespace MediaBrowser.Controller.LiveTv
public string EpisodeTitle { get; set; }
/// <summary>
- /// Set this value to true or false if it is known via program info whether there is an image or not.
- /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+ /// Supply the image path if it can be accessed directly from the file system
/// </summary>
- public bool? HasImage { get; set; }
+ /// <value>The image path.</value>
+ public string ImagePath { get; set; }
+
+ /// <summary>
+ /// Supply the image url if it can be downloaded
+ /// </summary>
+ /// <value>The image URL.</value>
+ public string ImageUrl { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is movie.
@@ -120,7 +126,13 @@ namespace MediaBrowser.Controller.LiveTv
/// </summary>
/// <value><c>true</c> if this instance is series; otherwise, <c>false</c>.</value>
public bool IsSeries { get; set; }
-
+
+ /// <summary>
+ /// Gets or sets a value indicating whether this instance is video.
+ /// </summary>
+ /// <value><c>true</c> if this instance is video; otherwise, <c>false</c>.</value>
+ public bool IsVideo { get; set; }
+
public ProgramInfo()
{
Genres = new List<string>();
diff --git a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
index 40a53e659..ee3d94594 100644
--- a/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
+++ b/MediaBrowser.Controller/LiveTv/RecordingInfo.cs
@@ -114,10 +114,16 @@ namespace MediaBrowser.Controller.LiveTv
public float? CommunityRating { get; set; }
/// <summary>
- /// Set this value to true or false if it is known via recording info whether there is an image or not.
- /// Leave it null if the only way to determine is by requesting the image and handling the failure.
+ /// Supply the image path if it can be accessed directly from the file system
/// </summary>
- public bool? HasImage { get; set; }
+ /// <value>The image path.</value>
+ public string ImagePath { get; set; }
+
+ /// <summary>
+ /// Supply the image url if it can be downloaded
+ /// </summary>
+ /// <value>The image URL.</value>
+ public string ImageUrl { get; set; }
public RecordingInfo()
{
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 705a0ea68..a200f610b 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -85,6 +85,7 @@
<Compile Include="Entities\IHasAspectRatio.cs" />
<Compile Include="Entities\IHasBudget.cs" />
<Compile Include="Entities\IHasCriticRating.cs" />
+ <Compile Include="Entities\IHasImages.cs" />
<Compile Include="Entities\IHasLanguage.cs" />
<Compile Include="Entities\IHasMediaStreams.cs" />
<Compile Include="Entities\IHasProductionLocations.cs" />
@@ -94,6 +95,7 @@
<Compile Include="Entities\IHasTags.cs" />
<Compile Include="Entities\IHasThemeMedia.cs" />
<Compile Include="Entities\IHasTrailers.cs" />
+ <Compile Include="Entities\IHasUserData.cs" />
<Compile Include="Entities\IItemByName.cs" />
<Compile Include="Entities\ILibraryItem.cs" />
<Compile Include="Entities\ImageSourceInfo.cs" />
@@ -106,11 +108,13 @@
<Compile Include="Library\ItemUpdateType.cs" />
<Compile Include="Library\IUserDataManager.cs" />
<Compile Include="Library\UserDataSaveEventArgs.cs" />
- <Compile Include="LiveTv\Channel.cs" />
+ <Compile Include="LiveTv\LiveTvChannel.cs" />
<Compile Include="LiveTv\ChannelInfo.cs" />
<Compile Include="LiveTv\ILiveTvManager.cs" />
<Compile Include="LiveTv\ILiveTvService.cs" />
<Compile Include="LiveTv\ImageResponseInfo.cs" />
+ <Compile Include="LiveTv\LiveTvProgram.cs" />
+ <Compile Include="LiveTv\LiveTvRecording.cs" />
<Compile Include="LiveTv\ProgramInfo.cs" />
<Compile Include="LiveTv\RecordingInfo.cs" />
<Compile Include="LiveTv\SeriesTimerInfo.cs" />
diff --git a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
index e4f4e8bbb..ced53299d 100644
--- a/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
+++ b/MediaBrowser.Controller/MediaInfo/FFMpegManager.cs
@@ -170,7 +170,7 @@ namespace MediaBrowser.Controller.MediaInfo
InputType type;
- var inputPath = MediaEncoderHelpers.GetInputArgument(video, null, out type);
+ var inputPath = MediaEncoderHelpers.GetInputArgument(video.Path, false, video.VideoType, video.IsoType, null, video.PlayableStreamFileNames, out type);
try
{
@@ -233,33 +233,23 @@ namespace MediaBrowser.Controller.MediaInfo
/// <summary>
/// Gets the subtitle cache path.
/// </summary>
- /// <param name="input">The input.</param>
- /// <param name="subtitleStreamIndex">Index of the subtitle stream.</param>
+ /// <param name="mediaPath">The media path.</param>
+ /// <param name="subtitleStream">The subtitle stream.</param>
/// <param name="offset">The offset.</param>
/// <param name="outputExtension">The output extension.</param>
/// <returns>System.String.</returns>
- public string GetSubtitleCachePath(Video input, int subtitleStreamIndex, TimeSpan? offset, string outputExtension)
+ public string GetSubtitleCachePath(string mediaPath, MediaStream subtitleStream, TimeSpan? offset, string outputExtension)
{
var ticksParam = offset.HasValue ? "_" + offset.Value.Ticks : "";
- var stream = _itemRepo.GetMediaStreams(new MediaStreamQuery
+ if (subtitleStream.IsExternal)
{
- ItemId = input.Id,
- Index = subtitleStreamIndex
-
- }).FirstOrDefault();
-
- if (stream == null)
- {
- return null;
+ ticksParam += _fileSystem.GetLastWriteTimeUtc(subtitleStream.Path).Ticks;
}
- if (stream.IsExternal)
- {
- ticksParam += _fileSystem.GetLastWriteTimeUtc(stream.Path).Ticks;
- }
+ var date = _fileSystem.GetLastWriteTimeUtc(mediaPath);
- var filename = (input.Id + "_" + subtitleStreamIndex.ToString(_usCulture) + "_" + input.DateModified.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputExtension;
+ var filename = (mediaPath + "_" + subtitleStream.Index.ToString(_usCulture) + "_" + date.Ticks.ToString(_usCulture) + ticksParam).GetMD5() + outputExtension;
var prefix = filename.Substring(0, 1);
diff --git a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs
index 8c2f7c219..904ecdf93 100644
--- a/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs
+++ b/MediaBrowser.Controller/MediaInfo/MediaEncoderHelpers.cs
@@ -1,5 +1,8 @@
-using MediaBrowser.Common.MediaInfo;
-using MediaBrowser.Controller.Entities;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using MediaBrowser.Common.MediaInfo;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.IO;
@@ -13,43 +16,47 @@ namespace MediaBrowser.Controller.MediaInfo
/// <summary>
/// Gets the input argument.
/// </summary>
- /// <param name="video">The video.</param>
+ /// <param name="videoPath">The video path.</param>
+ /// <param name="isRemote">if set to <c>true</c> [is remote].</param>
+ /// <param name="videoType">Type of the video.</param>
+ /// <param name="isoType">Type of the iso.</param>
/// <param name="isoMount">The iso mount.</param>
+ /// <param name="playableStreamFileNames">The playable stream file names.</param>
/// <param name="type">The type.</param>
/// <returns>System.String[][].</returns>
- public static string[] GetInputArgument(Video video, IIsoMount isoMount, out InputType type)
+ public static string[] GetInputArgument(string videoPath, bool isRemote, VideoType videoType, IsoType? isoType, IIsoMount isoMount, IEnumerable<string> playableStreamFileNames, out InputType type)
{
- var inputPath = isoMount == null ? new[] { video.Path } : new[] { isoMount.MountedPath };
+ var inputPath = isoMount == null ? new[] { videoPath } : new[] { isoMount.MountedPath };
type = InputType.VideoFile;
- switch (video.VideoType)
+ switch (videoType)
{
case VideoType.BluRay:
type = InputType.Bluray;
break;
case VideoType.Dvd:
type = InputType.Dvd;
- inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
+ inputPath = GetPlayableStreamFiles(inputPath[0], playableStreamFileNames).ToArray();
break;
case VideoType.Iso:
- if (video.IsoType.HasValue)
+ if (isoType.HasValue)
{
- switch (video.IsoType.Value)
+ switch (isoType.Value)
{
case IsoType.BluRay:
type = InputType.Bluray;
break;
case IsoType.Dvd:
type = InputType.Dvd;
- inputPath = video.GetPlayableStreamFiles(inputPath[0]).ToArray();
+ inputPath = GetPlayableStreamFiles(inputPath[0], playableStreamFileNames).ToArray();
break;
}
}
break;
case VideoType.VideoFile:
{
- if (video.LocationType == LocationType.Remote)
+ if (isRemote)
{
type = InputType.Url;
}
@@ -60,6 +67,17 @@ namespace MediaBrowser.Controller.MediaInfo
return inputPath;
}
+ public static List<string> GetPlayableStreamFiles(string rootPath, IEnumerable<string> filenames)
+ {
+ var allFiles = Directory
+ .EnumerateFiles(rootPath, "*", SearchOption.AllDirectories)
+ .ToList();
+
+ return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase)))
+ .Where(f => !string.IsNullOrEmpty(f))
+ .ToList();
+ }
+
/// <summary>
/// Gets the type of the input.
/// </summary>
diff --git a/MediaBrowser.Controller/Providers/IImageEnhancer.cs b/MediaBrowser.Controller/Providers/IImageEnhancer.cs
index 54ba6d322..ae605ec0d 100644
--- a/MediaBrowser.Controller/Providers/IImageEnhancer.cs
+++ b/MediaBrowser.Controller/Providers/IImageEnhancer.cs
@@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Providers
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns>
- bool Supports(BaseItem item, ImageType imageType);
+ bool Supports(IHasImages item, ImageType imageType);
/// <summary>
/// Gets the priority or order in which this enhancer should be run.
@@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Providers
/// <param name="item">The item.</param>
/// <param name="imageType">Type of the image.</param>
/// <returns>Cache key relating to the current state of this item and configuration</returns>
- string GetConfigurationCacheKey(BaseItem item, ImageType imageType);
+ string GetConfigurationCacheKey(IHasImages item, ImageType imageType);
/// <summary>
/// Gets the size of the enhanced image.
@@ -38,7 +38,7 @@ namespace MediaBrowser.Controller.Providers
/// <param name="imageIndex">Index of the image.</param>
/// <param name="originalImageSize">Size of the original image.</param>
/// <returns>ImageSize.</returns>
- ImageSize GetEnhancedImageSize(BaseItem item, ImageType imageType, int imageIndex, ImageSize originalImageSize);
+ ImageSize GetEnhancedImageSize(IHasImages item, ImageType imageType, int imageIndex, ImageSize originalImageSize);
/// <summary>
/// Enhances the image async.
@@ -49,6 +49,6 @@ namespace MediaBrowser.Controller.Providers
/// <param name="imageIndex">Index of the image.</param>
/// <returns>Task{Image}.</returns>
/// <exception cref="System.ArgumentNullException"></exception>
- Task<Image> EnhanceImageAsync(BaseItem item, Image originalImage, ImageType imageType, int imageIndex);
+ Task<Image> EnhanceImageAsync(IHasImages item, Image originalImage, ImageType imageType, int imageIndex);
}
} \ No newline at end of file