New: Show Custom Format score in Manual Import

(cherry picked from commit 972e1408993fc4656196087c6646f23d222e41f5)

Closes #8839
pull/8882/head
jack-mil 1 year ago committed by Bogdan
parent ffde07e4d6
commit 36338310df

@ -25,6 +25,7 @@ import {
import { SelectStateInputProps } from 'typings/props'; import { SelectStateInputProps } from 'typings/props';
import Rejection from 'typings/Rejection'; import Rejection from 'typings/Rejection';
import formatBytes from 'Utilities/Number/formatBytes'; import formatBytes from 'Utilities/Number/formatBytes';
import formatCustomFormatScore from 'Utilities/Number/formatCustomFormatScore';
import translate from 'Utilities/String/translate'; import translate from 'Utilities/String/translate';
import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder'; import InteractiveImportRowCellPlaceholder from './InteractiveImportRowCellPlaceholder';
import styles from './InteractiveImportRow.css'; import styles from './InteractiveImportRow.css';
@ -45,6 +46,7 @@ interface InteractiveImportRowProps {
languages?: Language[]; languages?: Language[];
size: number; size: number;
customFormats?: object[]; customFormats?: object[];
customFormatScore?: number;
rejections: Rejection[]; rejections: Rejection[];
columns: Column[]; columns: Column[];
movieFileId?: number; movieFileId?: number;
@ -66,6 +68,7 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
releaseGroup, releaseGroup,
size, size,
customFormats, customFormats,
customFormatScore,
rejections, rejections,
isSelected, isSelected,
modalTitle, modalTitle,
@ -293,8 +296,11 @@ function InteractiveImportRow(props: InteractiveImportRowProps) {
<TableRowCell> <TableRowCell>
{customFormats?.length ? ( {customFormats?.length ? (
<Popover <Popover
anchor={<Icon name={icons.INTERACTIVE} />} anchor={formatCustomFormatScore(
title={translate('Formats')} customFormatScore,
customFormats.length
)}
title={translate('CustomFormats')}
body={ body={
<div className={styles.customFormatTooltip}> <div className={styles.customFormatTooltip}>
<MovieFormats formats={customFormats} /> <MovieFormats formats={customFormats} />

@ -47,6 +47,10 @@ export const defaultState = {
quality: function(item, direction) { quality: function(item, direction) {
return item.qualityWeight || 0; return item.qualityWeight || 0;
},
customFormats: function(item, direction) {
return item.customFormatScore;
} }
} }
}; };

@ -19,6 +19,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
public string ReleaseGroup { get; set; } public string ReleaseGroup { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public List<CustomFormat> CustomFormats { get; set; } public List<CustomFormat> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public IEnumerable<Rejection> Rejections { get; set; } public IEnumerable<Rejection> Rejections { get; set; }
public Movie Movie { get; set; } public Movie Movie { get; set; }

@ -312,6 +312,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport.Manual
item.Movie = decision.LocalMovie.Movie; item.Movie = decision.LocalMovie.Movie;
item.CustomFormats = _formatCalculator.ParseCustomFormat(decision.LocalMovie); item.CustomFormats = _formatCalculator.ParseCustomFormat(decision.LocalMovie);
item.CustomFormatScore = item.Movie.Profile?.CalculateCustomFormatScore(item.CustomFormats) ?? 0;
} }
item.Quality = decision.LocalMovie.Quality; item.Quality = decision.LocalMovie.Quality;

@ -5,6 +5,7 @@ using NzbDrone.Common.Extensions;
using NzbDrone.Core.Languages; using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaFiles.MovieImport.Manual; using NzbDrone.Core.MediaFiles.MovieImport.Manual;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using Radarr.Api.V3.CustomFormats;
using Radarr.Api.V3.Movies; using Radarr.Api.V3.Movies;
using Radarr.Http; using Radarr.Http;
@ -35,6 +36,8 @@ namespace Radarr.Api.V3.ManualImport
item.Movie = processedItem.Movie.ToResource(0); item.Movie = processedItem.Movie.ToResource(0);
item.Rejections = processedItem.Rejections; item.Rejections = processedItem.Rejections;
item.CustomFormats = processedItem.CustomFormats.ToResource(false);
item.CustomFormatScore = processedItem.CustomFormatScore;
if (item.Languages?.Count <= 1 && (item.Languages?.SingleOrDefault() ?? Language.Unknown) == Language.Unknown && if (item.Languages?.Count <= 1 && (item.Languages?.SingleOrDefault() ?? Language.Unknown) == Language.Unknown &&
processedItem.Languages.Any()) processedItem.Languages.Any())

@ -2,6 +2,7 @@ using System.Collections.Generic;
using NzbDrone.Core.DecisionEngine; using NzbDrone.Core.DecisionEngine;
using NzbDrone.Core.Languages; using NzbDrone.Core.Languages;
using NzbDrone.Core.Qualities; using NzbDrone.Core.Qualities;
using Radarr.Api.V3.CustomFormats;
using Radarr.Api.V3.Movies; using Radarr.Api.V3.Movies;
using Radarr.Http.REST; using Radarr.Http.REST;
@ -16,7 +17,8 @@ namespace Radarr.Api.V3.ManualImport
public List<Language> Languages { get; set; } public List<Language> Languages { get; set; }
public string ReleaseGroup { get; set; } public string ReleaseGroup { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public List<CustomFormatResource> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public IEnumerable<Rejection> Rejections { get; set; } public IEnumerable<Rejection> Rejections { get; set; }
} }
} }

@ -25,6 +25,7 @@ namespace Radarr.Api.V3.ManualImport
public int QualityWeight { get; set; } public int QualityWeight { get; set; }
public string DownloadId { get; set; } public string DownloadId { get; set; }
public List<CustomFormatResource> CustomFormats { get; set; } public List<CustomFormatResource> CustomFormats { get; set; }
public int CustomFormatScore { get; set; }
public IEnumerable<Rejection> Rejections { get; set; } public IEnumerable<Rejection> Rejections { get; set; }
} }
@ -37,6 +38,9 @@ namespace Radarr.Api.V3.ManualImport
return null; return null;
} }
var customFormats = model.CustomFormats;
var customFormatScore = model.Movie?.Profile?.CalculateCustomFormatScore(customFormats) ?? 0;
return new ManualImportResource return new ManualImportResource
{ {
Id = HashConverter.GetHashInt31(model.Path), Id = HashConverter.GetHashInt31(model.Path),
@ -49,7 +53,8 @@ namespace Radarr.Api.V3.ManualImport
ReleaseGroup = model.ReleaseGroup, ReleaseGroup = model.ReleaseGroup,
Quality = model.Quality, Quality = model.Quality,
Languages = model.Languages, Languages = model.Languages,
CustomFormats = model.CustomFormats.ToResource(false), CustomFormats = customFormats.ToResource(false),
CustomFormatScore = customFormatScore,
// QualityWeight // QualityWeight
DownloadId = model.DownloadId, DownloadId = model.DownloadId,

Loading…
Cancel
Save