You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Radarr/src/NzbDrone.Core/Organizer/FileNameSampleService.cs

103 lines
3.2 KiB

using System.Collections.Generic;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Qualities;
using NzbDrone.Core.Movies;
using NzbDrone.Core.MediaFiles.MediaInfo;
using System;
namespace NzbDrone.Core.Organizer
{
public interface IFilenameSampleService
{
SampleResult GetMovieSample(NamingConfig nameSpec);
string GetMovieFolderSample(NamingConfig nameSpec);
}
public class FileNameSampleService : IFilenameSampleService
{
private readonly IBuildFileNames _buildFileNames;
private static MovieFile _movieFile;
private static Movie _movie;
public FileNameSampleService(IBuildFileNames buildFileNames)
{
_buildFileNames = buildFileNames;
var mediaInfo = new MediaInfoModel()
{
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
6 years ago
VideoFormat = "AVC",
VideoBitDepth = 10,
VideoMultiViewCount = 2,
VideoColourPrimaries = "BT.2020",
VideoTransferCharacteristics = "HLG",
AudioFormat = "DTS",
AudioChannels = 6,
AudioChannelPositions = "3/2/0.1",
AudioLanguages = "English",
Subtitles = "English/German"
};
var mediaInfoAnime = new MediaInfoModel()
{
New: Refactor MediaInfo tokens (fixes old tokens adds new stuff) (#3058) * Rename all 'episodeFile' variables to 'movieFile' * Improve media info extraction with more fields * Improve media info tokens extraction * Add missing fields to MediaInfoModel * Restore to previous implementation of null handling * Forgot to add MediaInfoFormatter to project * Add missing EqualsIgnoreCase extension method * Simplify Logger.Debug() invocations * Add missing StartsWithIgnoreCase extension method * This '.Value' shouldn't be required * Remove TODO comment * Upgrade MediaInfo from 17.10 to 18.08.1 * Use correct media info field for files listing * Replace media info "VideoCodec" (deprecated) with "VideoFormat" * Fix 'Formatiting' typos * Add support for media info Format_AdditionalFeatures' field * Add proper support for all DTS and TrueHD flavors * Add support for '3D' media info token * Remove deprecated media info video/audio profile fields * Add support for 'HDR' media info token * Add new video parameters to anime file name sample * Adapt tests for new media info fields * Revert "Remove deprecated media info video/audio profile fields" * Include missing test files in core test project * Fix small regression issue * Allow sample movie to be detected as HDR * Do not parse audio channel positions if there are no channels * Clean up extra blank line * Reuse already declared variable * Fix wrong audio channels detection on DTS:X streams * Fix all failing unit tests * Fix remaining failing unit tests
6 years ago
VideoFormat = "AVC",
VideoBitDepth = 10,
VideoMultiViewCount = 2,
VideoColourPrimaries = "BT.2020",
VideoTransferCharacteristics = "HLG",
AudioFormat = "DTS",
AudioChannels = 6,
AudioChannelPositions = "3/2/0.1",
AudioLanguages = "Japanese",
Subtitles = "Japanese/English"
};
_movieFile = new MovieFile
{
Quality = new QualityModel(Quality.Bluray1080p, new Revision(2)),
RelativePath = "The.Movie.Title.2010.1080p.BluRay.DTS.x264-EVOLVE.mkv",
SceneName = "The.Movie.Title.2010.1080p.BluRay.DTS.x264-EVOLVE",
ReleaseGroup = "EVOLVE",
MediaInfo = mediaInfo,
Edition = "Ultimate extended edition",
};
_movie = new Movie
{
Title = "The Movie: Title",
Year = 2010,
ImdbId = "tt0066921",
MovieFile = _movieFile,
MovieFileId = 1,
};
}
public SampleResult GetMovieSample(NamingConfig nameSpec)
{
var result = new SampleResult
{
FileName = BuildSample(_movie, _movieFile, nameSpec),
};
return result;
}
public string GetMovieFolderSample(NamingConfig nameSpec)
{
return _buildFileNames.GetMovieFolder(_movie, nameSpec);
}
private string BuildSample(Movie movie, MovieFile movieFile, NamingConfig nameSpec)
{
try
{
return _buildFileNames.BuildFileName(movie, movieFile, nameSpec);
}
catch (NamingFormatException)
{
return string.Empty;
}
}
}
}