don't organize episode if series has no provider ids
This commit is contained in:
parent
af599ed5d7
commit
2d97423a40
|
@ -76,50 +76,50 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
{
|
{
|
||||||
var seasonNumber = episodeInfo.SeasonNumber;
|
var seasonNumber = episodeInfo.SeasonNumber;
|
||||||
|
|
||||||
result.ExtractedSeasonNumber = seasonNumber;
|
result.ExtractedSeasonNumber = seasonNumber;
|
||||||
|
|
||||||
// Passing in true will include a few extra regex's
|
// Passing in true will include a few extra regex's
|
||||||
var episodeNumber = episodeInfo.EpisodeNumber;
|
var episodeNumber = episodeInfo.EpisodeNumber;
|
||||||
|
|
||||||
result.ExtractedEpisodeNumber = episodeNumber;
|
result.ExtractedEpisodeNumber = episodeNumber;
|
||||||
|
|
||||||
var premiereDate = episodeInfo.IsByDate ?
|
var premiereDate = episodeInfo.IsByDate ?
|
||||||
new DateTime(episodeInfo.Year.Value, episodeInfo.Month.Value, episodeInfo.Day.Value) :
|
new DateTime(episodeInfo.Year.Value, episodeInfo.Month.Value, episodeInfo.Day.Value) :
|
||||||
(DateTime?)null;
|
(DateTime?)null;
|
||||||
|
|
||||||
if (episodeInfo.IsByDate || (seasonNumber.HasValue && episodeNumber.HasValue))
|
if (episodeInfo.IsByDate || (seasonNumber.HasValue && episodeNumber.HasValue))
|
||||||
{
|
{
|
||||||
if (episodeInfo.IsByDate)
|
if (episodeInfo.IsByDate)
|
||||||
{
|
{
|
||||||
_logger.Debug("Extracted information from {0}. Series name {1}, Date {2}", path, seriesName, premiereDate.Value);
|
_logger.Debug("Extracted information from {0}. Series name {1}, Date {2}", path, seriesName, premiereDate.Value);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_logger.Debug("Extracted information from {0}. Series name {1}, Season {2}, Episode {3}", path, seriesName, seasonNumber, episodeNumber);
|
_logger.Debug("Extracted information from {0}. Series name {1}, Season {2}, Episode {3}", path, seriesName, seasonNumber, episodeNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
var endingEpisodeNumber = episodeInfo.EndingEpsiodeNumber;
|
var endingEpisodeNumber = episodeInfo.EndingEpsiodeNumber;
|
||||||
|
|
||||||
result.ExtractedEndingEpisodeNumber = endingEpisodeNumber;
|
result.ExtractedEndingEpisodeNumber = endingEpisodeNumber;
|
||||||
|
|
||||||
await OrganizeEpisode(path,
|
await OrganizeEpisode(path,
|
||||||
seriesName,
|
seriesName,
|
||||||
seasonNumber,
|
seasonNumber,
|
||||||
episodeNumber,
|
episodeNumber,
|
||||||
endingEpisodeNumber,
|
endingEpisodeNumber,
|
||||||
premiereDate,
|
premiereDate,
|
||||||
options,
|
options,
|
||||||
overwriteExisting,
|
overwriteExisting,
|
||||||
result,
|
result,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var msg = string.Format("Unable to determine episode number from {0}", path);
|
var msg = string.Format("Unable to determine episode number from {0}", path);
|
||||||
result.Status = FileSortingStatus.Failure;
|
result.Status = FileSortingStatus.Failure;
|
||||||
result.StatusMessage = msg;
|
result.StatusMessage = msg;
|
||||||
_logger.Warn(msg);
|
_logger.Warn(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -151,32 +151,32 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
|
|
||||||
var series = (Series)_libraryManager.GetItemById(new Guid(request.SeriesId));
|
var series = (Series)_libraryManager.GetItemById(new Guid(request.SeriesId));
|
||||||
|
|
||||||
await OrganizeEpisode(result.OriginalPath,
|
await OrganizeEpisode(result.OriginalPath,
|
||||||
series,
|
series,
|
||||||
request.SeasonNumber,
|
request.SeasonNumber,
|
||||||
request.EpisodeNumber,
|
request.EpisodeNumber,
|
||||||
request.EndingEpisodeNumber,
|
request.EndingEpisodeNumber,
|
||||||
null,
|
null,
|
||||||
options,
|
options,
|
||||||
true,
|
true,
|
||||||
result,
|
result,
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
await _organizationService.SaveResult(result, CancellationToken.None).ConfigureAwait(false);
|
await _organizationService.SaveResult(result, CancellationToken.None).ConfigureAwait(false);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task OrganizeEpisode(string sourcePath,
|
private Task OrganizeEpisode(string sourcePath,
|
||||||
string seriesName,
|
string seriesName,
|
||||||
int? seasonNumber,
|
int? seasonNumber,
|
||||||
int? episodeNumber,
|
int? episodeNumber,
|
||||||
int? endingEpiosdeNumber,
|
int? endingEpiosdeNumber,
|
||||||
DateTime? premiereDate,
|
DateTime? premiereDate,
|
||||||
TvFileOrganizationOptions options,
|
TvFileOrganizationOptions options,
|
||||||
bool overwriteExisting,
|
bool overwriteExisting,
|
||||||
FileOrganizationResult result,
|
FileOrganizationResult result,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var series = GetMatchingSeries(seriesName, result);
|
var series = GetMatchingSeries(seriesName, result);
|
||||||
|
|
||||||
|
@ -189,33 +189,42 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
return Task.FromResult(true);
|
return Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OrganizeEpisode(sourcePath,
|
if (!series.ProviderIds.Any())
|
||||||
series,
|
{
|
||||||
seasonNumber,
|
var msg = string.Format("Series has not yet been identified: {0}. If you just added the series, please run a library scan or use the identify feature to identify it.", seriesName);
|
||||||
episodeNumber,
|
result.Status = FileSortingStatus.Failure;
|
||||||
endingEpiosdeNumber,
|
result.StatusMessage = msg;
|
||||||
premiereDate,
|
_logger.Warn(msg);
|
||||||
options,
|
return Task.FromResult(true);
|
||||||
overwriteExisting,
|
}
|
||||||
result,
|
|
||||||
cancellationToken);
|
return OrganizeEpisode(sourcePath,
|
||||||
|
series,
|
||||||
|
seasonNumber,
|
||||||
|
episodeNumber,
|
||||||
|
endingEpiosdeNumber,
|
||||||
|
premiereDate,
|
||||||
|
options,
|
||||||
|
overwriteExisting,
|
||||||
|
result,
|
||||||
|
cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task OrganizeEpisode(string sourcePath,
|
private async Task OrganizeEpisode(string sourcePath,
|
||||||
Series series,
|
Series series,
|
||||||
int? seasonNumber,
|
int? seasonNumber,
|
||||||
int? episodeNumber,
|
int? episodeNumber,
|
||||||
int? endingEpiosdeNumber,
|
int? endingEpiosdeNumber,
|
||||||
DateTime? premiereDate,
|
DateTime? premiereDate,
|
||||||
TvFileOrganizationOptions options,
|
TvFileOrganizationOptions options,
|
||||||
bool overwriteExisting,
|
bool overwriteExisting,
|
||||||
FileOrganizationResult result,
|
FileOrganizationResult result,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
_logger.Info("Sorting file {0} into series {1}", sourcePath, series.Path);
|
_logger.Info("Sorting file {0} into series {1}", sourcePath, series.Path);
|
||||||
|
|
||||||
// Proceed to sort the file
|
// Proceed to sort the file
|
||||||
var newPath = await GetNewPath(sourcePath, series, seasonNumber, episodeNumber, endingEpiosdeNumber, premiereDate, options, cancellationToken).ConfigureAwait(false);
|
var newPath = await GetNewPath(sourcePath, series, seasonNumber, episodeNumber, endingEpiosdeNumber, premiereDate, options, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(newPath))
|
if (string.IsNullOrEmpty(newPath))
|
||||||
{
|
{
|
||||||
|
@ -324,17 +333,17 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetOtherDuplicatePaths(string targetPath,
|
private List<string> GetOtherDuplicatePaths(string targetPath,
|
||||||
Series series,
|
Series series,
|
||||||
int? seasonNumber,
|
int? seasonNumber,
|
||||||
int? episodeNumber,
|
int? episodeNumber,
|
||||||
int? endingEpisodeNumber)
|
int? endingEpisodeNumber)
|
||||||
{
|
{
|
||||||
// TODO: Support date-naming?
|
// TODO: Support date-naming?
|
||||||
if (!seasonNumber.HasValue || episodeNumber.HasValue)
|
if (!seasonNumber.HasValue || episodeNumber.HasValue)
|
||||||
{
|
{
|
||||||
return new List<string> ();
|
return new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
var episodePaths = series.GetRecursiveChildren()
|
var episodePaths = series.GetRecursiveChildren()
|
||||||
.OfType<Episode>()
|
.OfType<Episode>()
|
||||||
|
@ -464,14 +473,14 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
/// <param name="endingEpisodeNumber">The ending episode number.</param>
|
/// <param name="endingEpisodeNumber">The ending episode number.</param>
|
||||||
/// <param name="options">The options.</param>
|
/// <param name="options">The options.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
private async Task<string> GetNewPath(string sourcePath,
|
private async Task<string> GetNewPath(string sourcePath,
|
||||||
Series series,
|
Series series,
|
||||||
int? seasonNumber,
|
int? seasonNumber,
|
||||||
int? episodeNumber,
|
int? episodeNumber,
|
||||||
int? endingEpisodeNumber,
|
int? endingEpisodeNumber,
|
||||||
DateTime? premiereDate,
|
DateTime? premiereDate,
|
||||||
TvFileOrganizationOptions options,
|
TvFileOrganizationOptions options,
|
||||||
CancellationToken cancellationToken)
|
CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var episodeInfo = new EpisodeInfo
|
var episodeInfo = new EpisodeInfo
|
||||||
{
|
{
|
||||||
|
@ -481,7 +490,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
MetadataLanguage = series.GetPreferredMetadataLanguage(),
|
MetadataLanguage = series.GetPreferredMetadataLanguage(),
|
||||||
ParentIndexNumber = seasonNumber,
|
ParentIndexNumber = seasonNumber,
|
||||||
SeriesProviderIds = series.ProviderIds,
|
SeriesProviderIds = series.ProviderIds,
|
||||||
PremiereDate = premiereDate
|
PremiereDate = premiereDate
|
||||||
};
|
};
|
||||||
|
|
||||||
var searchResults = await _providerManager.GetRemoteSearchResults<Episode, EpisodeInfo>(new RemoteSearchQuery<EpisodeInfo>
|
var searchResults = await _providerManager.GetRemoteSearchResults<Episode, EpisodeInfo>(new RemoteSearchQuery<EpisodeInfo>
|
||||||
|
@ -491,7 +500,7 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
}, cancellationToken).ConfigureAwait(false);
|
}, cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
var episode = searchResults.FirstOrDefault();
|
var episode = searchResults.FirstOrDefault();
|
||||||
|
|
||||||
string episodeName = string.Empty;
|
string episodeName = string.Empty;
|
||||||
|
|
||||||
if (episode == null)
|
if (episode == null)
|
||||||
|
@ -503,10 +512,10 @@ namespace MediaBrowser.Server.Implementations.FileOrganization
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
episodeName = episode.Name;
|
episodeName = episode.Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
seasonNumber = seasonNumber ?? episode.ParentIndexNumber;
|
seasonNumber = seasonNumber ?? episode.ParentIndexNumber;
|
||||||
episodeNumber = episodeNumber ?? episode.IndexNumber;
|
episodeNumber = episodeNumber ?? episode.IndexNumber;
|
||||||
|
|
||||||
var newPath = GetSeasonFolderPath(series, seasonNumber.Value, options);
|
var newPath = GetSeasonFolderPath(series, seasonNumber.Value, options);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user