Unable to properly parse many movie titles

pull/74/head
Tim Turner 8 years ago
parent 14bf63e21d
commit 7a45394820

@ -107,8 +107,8 @@ namespace NzbDrone.Api.Indexers
ReleaseGroup = parsedMovieInfo.ReleaseGroup,
ReleaseHash = parsedMovieInfo.ReleaseHash,
Title = releaseInfo.Title,
FullSeason = parsedMovieInfo.FullSeason,
SeasonNumber = parsedMovieInfo.SeasonNumber,
//FullSeason = parsedMovieInfo.FullSeason,
//SeasonNumber = parsedMovieInfo.SeasonNumber,
Language = parsedMovieInfo.Language,
AirDate = "",
SeriesTitle = parsedMovieInfo.MovieTitle,
@ -138,7 +138,7 @@ namespace NzbDrone.Api.Indexers
IsDaily = false,
IsAbsoluteNumbering = false,
IsPossibleSpecialEpisode = false,
Special = parsedMovieInfo.Special,
//Special = parsedMovieInfo.Special,
};
}

@ -33,6 +33,7 @@ namespace NzbDrone.Api.Movie
public bool Downloaded { get; set; }
public string RemotePoster { get; set; }
public int Year { get; set; }
public bool HasFile { get; set; }
//View & Edit
public string Path { get; set; }
@ -80,7 +81,17 @@ namespace NzbDrone.Api.Movie
{
if (model == null) return null;
long Size = model.MovieFile.Value != null ? model.MovieFile.Value.Size : 0;
long size = 0;
bool downloaded = false;
if(model.MovieFile != null && model.MovieFile.IsLoaded)
{
size = model.MovieFile.Value.Size;
downloaded = true;
}
//long Size = model.MovieFile != null ? model.MovieFile.Value.Size : 0;
return new MovieResource
{
@ -91,8 +102,8 @@ namespace NzbDrone.Api.Movie
SortTitle = model.SortTitle,
InCinemas = model.InCinemas,
PhysicalRelease = model.PhysicalRelease,
Downloaded = model.MovieFile.Value != null,
HasFile = model.HasFile,
Downloaded = downloaded,
//TotalEpisodeCount
//EpisodeCount
//EpisodeFileCount
@ -110,7 +121,7 @@ namespace NzbDrone.Api.Movie
Monitored = model.Monitored,
SizeOnDisk = Size,
SizeOnDisk = size,
Runtime = model.Runtime,
LastInfoSync = model.LastInfoSync,

@ -159,7 +159,7 @@ namespace NzbDrone.Core.MediaFiles
}
var cleanedUpName = GetCleanedUpFolderName(directoryInfo.Name);
var folderInfo = Parser.Parser.ParseTitle(directoryInfo.Name);
var folderInfo = Parser.Parser.ParseMovieTitle(directoryInfo.Name);
if (folderInfo != null)
{

@ -80,7 +80,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
episodeFile.Quality = localMovie.Quality;
episodeFile.MediaInfo = localMovie.MediaInfo;
episodeFile.Movie = localMovie.Movie;
episodeFile.ReleaseGroup = localMovie.ParsedEpisodeInfo.ReleaseGroup;
episodeFile.ReleaseGroup = localMovie.ParsedMovieInfo.ReleaseGroup;
bool copyOnly;
switch (importMode)

@ -24,12 +24,12 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
LocalMovie = localMovie;
Rejections = rejections.ToList();
LocalEpisode = new LocalEpisode
LocalMovie = new LocalMovie
{
Quality = localMovie.Quality,
ExistingFile = localMovie.ExistingFile,
MediaInfo = localMovie.MediaInfo,
ParsedEpisodeInfo = localMovie.ParsedEpisodeInfo,
ParsedMovieInfo = localMovie.ParsedMovieInfo,
Path = localMovie.Path,
Size = localMovie.Size
};

@ -19,7 +19,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
{
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie);
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedEpisodeInfo folderInfo, bool sceneSource); //TODO: Needs changing to ParsedMovieInfo!!
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource); //TODO: Needs changing to ParsedMovieInfo!!
List<ImportDecision> GetImportDecisions(List<string> videoFiles, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
}
@ -77,7 +77,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return decisions;
}
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedEpisodeInfo folderInfo, bool sceneSource)
public List<ImportDecision> GetImportDecisions(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource)
{
var newFiles = _mediaFileService.FilterExistingFiles(videoFiles.ToList(), movie);
@ -94,7 +94,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return decisions;
}
private ImportDecision GetDecision(string file, Movie movie, ParsedEpisodeInfo folderInfo, bool sceneSource, bool shouldUseFolderName)
private ImportDecision GetDecision(string file, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource, bool shouldUseFolderName)
{
ImportDecision decision = null;
@ -291,17 +291,17 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
}) == 1;
}
private bool ShouldUseFolderName(List<string> videoFiles, Movie movie, ParsedEpisodeInfo folderInfo)
private bool ShouldUseFolderName(List<string> videoFiles, Movie movie, ParsedMovieInfo folderInfo)
{
if (folderInfo == null)
{
return false;
}
if (folderInfo.FullSeason)
{
return false;
}
//if (folderInfo.FullSeason)
//{
// return false;
//}
return videoFiles.Count(file =>
{
@ -325,7 +325,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
}) == 1;
}
private QualityModel GetQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Movie movie)
private QualityModel GetQuality(ParsedMovieInfo folderInfo, QualityModel fileQuality, Movie movie)
{
if (UseFolderQuality(folderInfo, fileQuality, movie))
{
@ -347,7 +347,7 @@ namespace NzbDrone.Core.MediaFiles.EpisodeImport
return fileQuality;
}
private bool UseFolderQuality(ParsedEpisodeInfo folderInfo, QualityModel fileQuality, Movie movie)
private bool UseFolderQuality(ParsedMovieInfo folderInfo, QualityModel fileQuality, Movie movie)
{
if (folderInfo == null)
{

@ -63,7 +63,7 @@ namespace NzbDrone.Core.MediaFiles
var movieFilePath = Path.Combine(movie.Path, file.RelativePath);
var newName = _filenameBuilder.BuildFileName(movie, file);
var newPath = _filenameBuilder.BuildFilePath(movie, newName, Path.GetExtension(file.Path));
var newPath = _filenameBuilder.BuildFilePath(movie, newName, Path.GetExtension(movieFilePath));
if(!movieFilePath.PathEquals(newPath, StringComparison.Ordinal))
{

@ -254,7 +254,7 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
}
}
var searchTerm = lowerTitle.Replace("_", "+").Replace(" ", "+");
var searchTerm = lowerTitle.Replace("_", "+").Replace(" ", "+").Replace(".", "+");
var firstChar = searchTerm.First();

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Collections.Generic;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Tv;
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Parser.Model
public string Path { get; set; }
public long Size { get; set; }
public ParsedEpisodeInfo ParsedEpisodeInfo { get; set; }
public ParsedMovieInfo ParsedMovieInfo { get; set; }
public Movie Movie { get; set; }
public QualityModel Quality { get; set; }
public MediaInfoModel MediaInfo { get; set; }

@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Qualities;
@ -9,10 +9,10 @@ namespace NzbDrone.Core.Parser.Model
public string MovieTitle { get; set; }
public SeriesTitleInfo MovieTitleInfo { get; set; }
public QualityModel Quality { get; set; }
public int SeasonNumber { get; set; }
//public int SeasonNumber { get; set; }
public Language Language { get; set; }
public bool FullSeason { get; set; }
public bool Special { get; set; }
//public bool FullSeason { get; set; }
//public bool Special { get; set; }
public string ReleaseGroup { get; set; }
public string ReleaseHash { get; set; }
public string Edition { get; set;}

@ -321,6 +321,28 @@ namespace NzbDrone.Core.Parser
return result;
}
public static ParsedMovieInfo ParseMoviePath(string path)
{
var fileInfo = new FileInfo(path);
var result = ParseMovieTitle(fileInfo.Name);
if (result == null)
{
Logger.Debug("Attempting to parse episode info using directory and file names. {0}", fileInfo.Directory.Name);
result = ParseMovieTitle(fileInfo.Directory.Name + " " + fileInfo.Name);
}
if (result == null)
{
Logger.Debug("Attempting to parse episode info using directory name. {0}", fileInfo.Directory.Name);
result = ParseMovieTitle(fileInfo.Directory.Name + fileInfo.Extension);
}
return result;
}
public static ParsedMovieInfo ParseMovieTitle(string title)
{

@ -16,7 +16,7 @@ namespace NzbDrone.Core.Parser
LocalEpisode GetLocalEpisode(string filename, Series series);
LocalEpisode GetLocalEpisode(string filename, Series series, ParsedEpisodeInfo folderInfo, bool sceneSource);
LocalMovie GetLocalMovie(string filename, Movie movie);
LocalMovie GetLocalMovie(string filename, Movie movie, ParsedEpisodeInfo folderInfo, bool sceneSource);
LocalMovie GetLocalMovie(string filename, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource);
Series GetSeries(string title);
Movie GetMovie(string title);
RemoteEpisode Map(ParsedEpisodeInfo parsedEpisodeInfo, int tvdbId, int tvRageId, SearchCriteriaBase searchCriteria = null);
@ -120,26 +120,26 @@ namespace NzbDrone.Core.Parser
return GetLocalMovie(filename, movie, null, false);
}
public LocalMovie GetLocalMovie(string filename, Movie movie, ParsedEpisodeInfo folderInfo, bool sceneSource)
public LocalMovie GetLocalMovie(string filename, Movie movie, ParsedMovieInfo folderInfo, bool sceneSource)
{
ParsedEpisodeInfo parsedEpisodeInfo;
ParsedMovieInfo parsedMovieInfo;
if (folderInfo != null)
{
parsedEpisodeInfo = folderInfo.JsonClone();
parsedEpisodeInfo.Quality = QualityParser.ParseQuality(Path.GetFileName(filename));
parsedMovieInfo = folderInfo.JsonClone();
parsedMovieInfo.Quality = QualityParser.ParseQuality(Path.GetFileName(filename));
}
else
{
parsedEpisodeInfo = Parser.ParsePath(filename);
parsedMovieInfo = Parser.ParseMoviePath(filename);
}
if (parsedEpisodeInfo == null)
if (parsedMovieInfo == null)
{
if (MediaFileExtensions.Extensions.Contains(Path.GetExtension(filename)))
{
_logger.Warn("Unable to parse episode info from path {0}", filename);
_logger.Warn("Unable to parse movie info from path {0}", filename);
}
return null;
@ -148,9 +148,9 @@ namespace NzbDrone.Core.Parser
return new LocalMovie
{
Movie = movie,
Quality = parsedEpisodeInfo.Quality,
Quality = parsedMovieInfo.Quality,
Path = filename,
ParsedEpisodeInfo = parsedEpisodeInfo,
ParsedMovieInfo = parsedMovieInfo,
ExistingFile = movie.Path.IsParentPath(filename)
};
}

@ -48,6 +48,9 @@ namespace NzbDrone.Core.Tv
public LazyLoaded<MovieFile> MovieFile { get; set; }
public int MovieFileId { get; set; }
public List<string> AlternativeTitles { get; set; }
public bool HasFile => MovieFileId > 0;
public override string ToString()
{
return string.Format("[{0}][{1}]", ImdbId, Title.NullSafe());

Loading…
Cancel
Save