sync updates

pull/702/head
Luke Pulverenti 10 years ago
parent 8497c2926f
commit d451386f5d

@ -83,6 +83,13 @@ namespace MediaBrowser.Api
{
info.ContentTypeOptions = GetContentTypeOptions(true);
info.ContentType = configuredContentType;
if (string.Equals(inheritedContentType, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
{
info.ContentTypeOptions = info.ContentTypeOptions
.Where(i => string.IsNullOrWhiteSpace(i.Value) || string.Equals(i.Value, CollectionType.TvShows, StringComparison.OrdinalIgnoreCase))
.ToList();
}
}
}
}

@ -52,6 +52,16 @@ namespace MediaBrowser.Controller.Entities.Audio
}
}
public override bool IsSaveLocalMetadataEnabled()
{
if (IsAccessedByName)
{
return true;
}
return base.IsSaveLocalMetadataEnabled();
}
private readonly Task _cachedTask = Task.FromResult(true);
protected override Task ValidateChildrenInternal(IProgress<double> progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService)
{

@ -44,6 +44,11 @@ namespace MediaBrowser.Controller.Entities.Audio
return false;
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

@ -43,6 +43,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
public override bool CanDelete()
{
return false;

@ -34,6 +34,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
public override bool CanDelete()
{
return false;

@ -79,6 +79,11 @@ namespace MediaBrowser.Controller.Entities.Movies
return true;
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
/// <summary>
/// Gets the trailer ids.
/// </summary>

@ -1,8 +1,8 @@
using System.Runtime.Serialization;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Controller.Providers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
namespace MediaBrowser.Controller.Entities
{
@ -50,6 +50,11 @@ namespace MediaBrowser.Controller.Entities
return false;
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>

@ -45,6 +45,11 @@ namespace MediaBrowser.Controller.Entities
return false;
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
/// <summary>
/// Gets a value indicating whether this instance is owned item.
/// </summary>
@ -63,7 +68,6 @@ namespace MediaBrowser.Controller.Entities
return inputItems.Where(GetItemFilter());
}
public Func<BaseItem, bool> GetItemFilter()
{
return i => i.Studios.Contains(Name, StringComparer.OrdinalIgnoreCase);

@ -52,6 +52,11 @@ namespace MediaBrowser.Controller.Entities
}
}
public override bool IsSaveLocalMetadataEnabled()
{
return true;
}
public IEnumerable<BaseItem> GetTaggedItems(IEnumerable<BaseItem> inputItems)
{
int year;

@ -1,5 +1,4 @@
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;

@ -87,6 +87,12 @@ namespace MediaBrowser.Model.Dto
/// <value>The percent played.</value>
public int? PercentPlayed { get; set; }
/// <summary>
/// Gets or sets the un played count.
/// </summary>
/// <value>The un played count.</value>
public int? UnPlayedCount { get; set; }
/// <summary>
/// Gets or sets the color of the background.
/// </summary>

@ -5,10 +5,12 @@ using MediaBrowser.Controller.FileOrganization;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Extensions;
using MediaBrowser.Model.FileOrganization;
using MediaBrowser.Model.Logging;
using MediaBrowser.Naming.Common;
using MediaBrowser.Naming.IO;
using MediaBrowser.Server.Implementations.Library;
using MediaBrowser.Server.Implementations.Logging;
using System;
using System.Collections.Generic;
using System.Globalization;
@ -16,8 +18,6 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Server.Implementations.Library;
using MediaBrowser.Server.Implementations.Logging;
namespace MediaBrowser.Server.Implementations.FileOrganization
{
@ -202,15 +202,26 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
if (overwriteExisting)
{
var hasRenamedFiles = false;
foreach (var path in otherDuplicatePaths)
{
_logger.Debug("Removing duplicate episode {0}", path);
_libraryMonitor.ReportFileSystemChangeBeginning(path);
var renameRelatedFiles = false;
//var renameRelatedFiles = !hasRenamedFiles &&
// string.Equals(Path.GetDirectoryName(path), Path.GetDirectoryName(result.TargetPath), StringComparison.OrdinalIgnoreCase);
if (renameRelatedFiles)
{
hasRenamedFiles = true;
}
try
{
DeleteLibraryFile(path);
DeleteLibraryFile(path, renameRelatedFiles, result.TargetPath);
}
catch (IOException ex)
{
@ -224,13 +235,41 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
}
}
private void DeleteLibraryFile(string path)
private void DeleteLibraryFile(string path, bool renameRelatedFiles, string targetPath)
{
var filename = Path.GetFileNameWithoutExtension(path);
_fileSystem.DeleteFile(path);
if (!renameRelatedFiles)
{
return;
}
// Now find other files
var originalFilenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
var directory = Path.GetDirectoryName(path);
if (!string.IsNullOrWhiteSpace(originalFilenameWithoutExtension) && !string.IsNullOrWhiteSpace(directory))
{
// Get all related files, e.g. metadata, images, etc
var files = Directory.EnumerateFiles(directory, "*", SearchOption.TopDirectoryOnly)
.Where(i => (Path.GetFileNameWithoutExtension(i) ?? string.Empty).StartsWith(originalFilenameWithoutExtension, StringComparison.OrdinalIgnoreCase))
.ToList();
var targetFilenameWithoutExtension = Path.GetFileNameWithoutExtension(targetPath);
foreach (var file in files)
{
directory = Path.GetDirectoryName(file);
var filename = Path.GetFileName(file);
filename = filename.Replace(originalFilenameWithoutExtension, targetFilenameWithoutExtension,
StringComparison.OrdinalIgnoreCase);
var destination = Path.Combine(directory, filename);
File.Move(file, destination);
}
}
}
private List<string> GetOtherDuplicatePaths(string targetPath, Series series, int seasonNumber, int episodeNumber, int? endingEpisodeNumber)

@ -380,6 +380,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
Priority = route.Priority,
Summary = route.Summary
});
// TODO: This is a hack for iOS. Remove it asap.
routes.Add(new RouteAttribute(DoubleNormalizeRoutePath(route.Path), route.Verbs)
{
Notes = route.Notes,
Priority = route.Priority,
Summary = route.Summary
});
}
return routes.ToArray();
@ -395,6 +403,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return "mediabrowser/" + path;
}
private string DoubleNormalizeRoutePath(string path)
{
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
{
return "/mediabrowser/mediabrowser" + path;
}
return "mediabrowser//mediabrowser" + path;
}
/// <summary>
/// Releases the specified instance.
/// </summary>

Loading…
Cancel
Save