update image processing

This commit is contained in:
Luke Pulverenti 2015-07-29 16:31:15 -04:00
parent 1f6b5a8c7c
commit 8f75454d76
14 changed files with 60 additions and 42 deletions

View File

@ -285,14 +285,14 @@ namespace Emby.Drawing.ImageMagick
private MagickWand BuildThumbCollageWand(List<string> paths, int width, int height)
{
var inputPaths = ImageHelpers.ProjectPaths(paths, 8);
var inputPaths = ImageHelpers.ProjectPaths(paths, 4);
using (var wandImages = new MagickWand(inputPaths.ToArray()))
{
var wand = new MagickWand(width, height);
wand.OpenImage("gradient:#111111-#111111");
using (var draw = new DrawingWand())
{
var iSlice = Convert.ToInt32(width * .1166666667);
var iSlice = Convert.ToInt32(width * .1166666667 * 2);
int iTrans = Convert.ToInt32(height * .25);
int iHeight = Convert.ToInt32(height * .62);
var horizontalImagePadding = Convert.ToInt32(width * 0.0125);

View File

@ -2,7 +2,6 @@
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Localization;

View File

@ -89,7 +89,7 @@ namespace MediaBrowser.Api.UserLibrary
var views = user.RootFolder
.GetChildren(user, true)
.OfType<ICollectionFolder>()
.Where(i => IsEligibleForSpecialView(i))
.Where(IsEligibleForSpecialView)
.ToList();
var list = views

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace MediaBrowser.Controller.Entities
{
@ -14,4 +15,17 @@ namespace MediaBrowser.Controller.Entities
Guid Id { get; }
IEnumerable<string> PhysicalLocations { get; }
}
public static class CollectionFolderExtensions
{
public static string GetViewType(this ICollectionFolder folder, User user)
{
if (user.Configuration.PlainFolderViews.Contains(folder.Id.ToString("N"), StringComparer.OrdinalIgnoreCase))
{
return null;
}
return folder.CollectionType;
}
}
}

View File

@ -264,10 +264,7 @@ namespace MediaBrowser.Controller.Entities
private async Task<QueryResult<BaseItem>> FindPlaylists(Folder parent, User user, InternalItemsQuery query)
{
var collectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList();
var list = _playlistManager.GetPlaylists(user.Id.ToString("N"))
.Where(i => i.GetChildren(user, true).Any(media => _libraryManager.GetCollectionFolders(media).Select(c => c.Id).Any(collectionFolders.Contains)));
var list = _playlistManager.GetPlaylists(user.Id.ToString("N"));
return GetResult(list, parent, query);
}

View File

@ -476,7 +476,7 @@ namespace MediaBrowser.Server.Implementations.Channels
public Channel GetChannel(string id)
{
return (Channel)_libraryManager.GetItemById(new Guid(id));
return _libraryManager.GetItemById(new Guid(id)) as Channel;
}
public IEnumerable<ChannelFeatures> GetAllChannelFeatures()

View File

@ -1,5 +1,4 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Movies;
using System.Linq;
namespace MediaBrowser.Server.Implementations.Collections

View File

@ -351,6 +351,14 @@ namespace MediaBrowser.Server.Implementations.Dto
AttachBasicFields(dto, item, owner, options);
var collectionFolder = item as ICollectionFolder;
if (collectionFolder != null)
{
dto.CollectionType = user == null ?
collectionFolder.CollectionType :
collectionFolder.GetViewType(user);
}
var playlist = item as Playlist;
if (playlist != null)
{
@ -1066,12 +1074,6 @@ namespace MediaBrowser.Server.Implementations.Dto
dto.DisplayOrder = hasDisplayOrder.DisplayOrder;
}
var collectionFolder = item as ICollectionFolder;
if (collectionFolder != null)
{
dto.CollectionType = collectionFolder.CollectionType;
}
var userView = item as UserView;
if (userView != null)
{

View File

@ -1615,7 +1615,7 @@ namespace MediaBrowser.Server.Implementations.Library
.FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
}
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(.01);
private readonly TimeSpan _viewRefreshInterval = TimeSpan.FromHours(24);
public async Task<UserView> GetNamedView(User user,
string name,

View File

@ -91,7 +91,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.AddRange(standaloneFolders);
}
var parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
var parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.TvShows, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
.ToList();
if (parents.Count > 0)
@ -99,7 +99,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(await GetUserView(parents, list, CollectionType.TvShows, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Music, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
.ToList();
if (parents.Count > 0)
@ -107,7 +107,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(await GetUserView(parents, list, CollectionType.Music, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.CollectionType))
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Movies, StringComparison.OrdinalIgnoreCase) || string.IsNullOrWhiteSpace(i.GetViewType(user)))
.ToList();
if (parents.Count > 0)
@ -115,7 +115,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(await GetUserView(parents, list, CollectionType.Movies, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Games, StringComparison.OrdinalIgnoreCase))
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Games, StringComparison.OrdinalIgnoreCase))
.ToList();
if (parents.Count > 0)
@ -123,7 +123,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(await GetUserView(parents, list, CollectionType.Games, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.BoxSets, StringComparison.OrdinalIgnoreCase))
.ToList();
if (parents.Count > 0)
@ -131,7 +131,7 @@ namespace MediaBrowser.Server.Implementations.Library
list.Add(await GetUserView(parents, list, CollectionType.BoxSets, string.Empty, user, cancellationToken).ConfigureAwait(false));
}
parents = foldersWithViewTypes.Where(i => string.Equals(i.CollectionType, CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
parents = foldersWithViewTypes.Where(i => string.Equals(i.GetViewType(user), CollectionType.Playlists, StringComparison.OrdinalIgnoreCase))
.ToList();
if (parents.Count > 0)
@ -204,8 +204,9 @@ namespace MediaBrowser.Server.Implementations.Library
public async Task<UserView> GetUserView(List<ICollectionFolder> parents, List<Folder> currentViews, string viewType, string sortName, User user, CancellationToken cancellationToken)
{
var name = _localizationManager.GetLocalizedString("ViewType" + viewType);
var enableUserSpecificViews = _config.Configuration.EnableUserSpecificUserViews;
if (parents.Count == 1 && parents.All(i => string.Equals(i.CollectionType, viewType, StringComparison.OrdinalIgnoreCase)))
if (parents.Count == 1 && parents.All(i => string.Equals((enableUserSpecificViews ? i.CollectionType : i.GetViewType(user)), viewType, StringComparison.OrdinalIgnoreCase)))
{
if (!string.IsNullOrWhiteSpace(parents[0].Name))
{
@ -221,7 +222,7 @@ namespace MediaBrowser.Server.Implementations.Library
return await GetUserView(parentId, name, viewType, enableRichView, sortName, user, cancellationToken).ConfigureAwait(false);
}
if (_config.Configuration.EnableUserSpecificUserViews)
if (enableUserSpecificViews)
{
viewType = enableRichView ? viewType : null;
var view = await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
@ -233,8 +234,6 @@ namespace MediaBrowser.Server.Implementations.Library
}
return view;
}
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);
}
return await _libraryManager.GetNamedView(user, name, viewType, sortName, cancellationToken).ConfigureAwait(false);

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common;
using System.Globalization;
using MediaBrowser.Common;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Common.Net;
@ -453,11 +454,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
var mediaStreamInfo = await GetChannelStream(timer.ChannelId, null, CancellationToken.None);
var duration = (timer.EndDate - DateTime.UtcNow).TotalSeconds + timer.PostPaddingSeconds;
var duration = (timer.EndDate - DateTime.UtcNow).Add(TimeSpan.FromSeconds(timer.PostPaddingSeconds));
HttpRequestOptions httpRequestOptions = new HttpRequestOptions()
{
Url = mediaStreamInfo.Path + "?duration=" + duration
Url = mediaStreamInfo.Path + "?duration=" + duration.TotalSeconds.ToString(CultureInfo.InvariantCulture)
};
var info = GetProgramInfoFromCache(timer.ChannelId, timer.ProgramId);
@ -516,13 +517,15 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
try
{
httpRequestOptions.BufferContent = false;
httpRequestOptions.CancellationToken = cancellationToken;
var durationToken = new CancellationTokenSource(duration);
var linkedToken = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken, durationToken.Token).Token;
httpRequestOptions.CancellationToken = linkedToken;
_logger.Info("Writing file to path: " + recordPath);
using (var response = await _httpClient.SendAsync(httpRequestOptions, "GET"))
{
using (var output = File.Open(recordPath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
await response.Content.CopyToAsync(output, 4096, cancellationToken);
await response.Content.CopyToAsync(output, 4096, linkedToken);
}
}
@ -530,7 +533,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
}
catch (OperationCanceledException)
{
recording.Status = RecordingStatus.Cancelled;
recording.Status = RecordingStatus.Completed;
}
catch
{

View File

@ -1,4 +1,5 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Common;
using MediaBrowser.Common.Net;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.LiveTv;
@ -20,19 +21,25 @@ namespace MediaBrowser.Server.Implementations.LiveTv.Listings
private readonly ILogger _logger;
private readonly IJsonSerializer _jsonSerializer;
private readonly IHttpClient _httpClient;
private const string UserAgent = "EmbyTV";
private readonly SemaphoreSlim _tokenSemaphore = new SemaphoreSlim(1, 1);
private readonly IApplicationHost _appHost;
private const string ApiUrl = "https://json.schedulesdirect.org/20141201";
private readonly ConcurrentDictionary<string, ScheduleDirect.Station> _channelPair =
new ConcurrentDictionary<string, ScheduleDirect.Station>();
public SchedulesDirect(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient)
public SchedulesDirect(ILogger logger, IJsonSerializer jsonSerializer, IHttpClient httpClient, IApplicationHost appHost)
{
_logger = logger;
_jsonSerializer = jsonSerializer;
_httpClient = httpClient;
_appHost = appHost;
}
private string UserAgent
{
get { return "Emby/" + _appHost.ApplicationVersion; }
}
private List<string> GetScheduleRequestDates(DateTime startDateUtc, DateTime endDateUtc)

View File

@ -118,7 +118,7 @@ namespace MediaBrowser.Server.Implementations.Photos
protected Task<bool> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, bool drawText)
{
return CreateCollage(primaryItem, items, outputPath, 960, 540, drawText, primaryItem.Name);
return CreateCollage(primaryItem, items, outputPath, 640, 360, drawText, primaryItem.Name);
}
protected virtual IEnumerable<string> GetStripCollageImagePaths(IHasImages primaryItem, IEnumerable<BaseItem> items)
@ -130,12 +130,12 @@ namespace MediaBrowser.Server.Implementations.Photos
protected Task<bool> CreatePosterCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath)
{
return CreateCollage(primaryItem, items, outputPath, 600, 900, true, primaryItem.Name);
return CreateCollage(primaryItem, items, outputPath, 400, 600, true, primaryItem.Name);
}
protected Task<bool> CreateSquareCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, bool drawText)
{
return CreateCollage(primaryItem, items, outputPath, 800, 800, drawText, primaryItem.Name);
return CreateCollage(primaryItem, items, outputPath, 600, 600, drawText, primaryItem.Name);
}
protected Task<bool> CreateThumbCollage(IHasImages primaryItem, List<BaseItem> items, string outputPath, int width, int height, bool drawText, string text)

View File

@ -16,9 +16,7 @@ namespace MediaBrowser.Server.Implementations.Playlists
public override bool IsVisible(User user)
{
return base.IsVisible(user) && GetChildren(user, false)
.OfType<Playlist>()
.Any(i => i.IsVisible(user));
return base.IsVisible(user) && GetChildren(user, false).Any();
}
protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user)