1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-09-11 20:12:41 +02:00

Fixed: Movie Path UI Warning, Duplicate Import Fixes

This commit is contained in:
Qstick 2019-09-29 16:27:30 -04:00
parent b225435164
commit 7fd391259c
23 changed files with 216 additions and 76 deletions

View File

@ -1,5 +1,5 @@
.description { .description {
composes: title from '~Components/DescriptionList/DescriptionListItemDescription.css'; composes: description from '~Components/DescriptionList/DescriptionListItemDescription.css';
overflow-wrap: break-word; overflow-wrap: break-word;
} }

View File

@ -307,7 +307,7 @@ QueueRow.propTypes = {
trackedDownloadStatus: PropTypes.string, trackedDownloadStatus: PropTypes.string,
statusMessages: PropTypes.arrayOf(PropTypes.object), statusMessages: PropTypes.arrayOf(PropTypes.object),
errorMessage: PropTypes.string, errorMessage: PropTypes.string,
movie: PropTypes.object.isRequired, movie: PropTypes.object,
quality: PropTypes.object.isRequired, quality: PropTypes.object.isRequired,
languages: PropTypes.arrayOf(PropTypes.object).isRequired, languages: PropTypes.arrayOf(PropTypes.object).isRequired,
protocol: PropTypes.string.isRequired, protocol: PropTypes.string.isRequired,

View File

@ -35,14 +35,20 @@
.message { .message {
margin-top: 30px; margin-top: 30px;
text-align: center; text-align: center;
font-weight: 300;
font-size: $largeFontSize;
} }
.helpText { .helpText {
margin-bottom: 10px; margin-bottom: 10px;
font-weight: 300;
font-size: 24px; font-size: 24px;
} }
.noMoviesText {
margin-top: 80px;
margin-bottom: 20px;
}
.noResults { .noResults {
margin-bottom: 10px; margin-bottom: 10px;
font-weight: 300; font-weight: 300;

View File

@ -1,7 +1,7 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import getErrorMessage from 'Utilities/Object/getErrorMessage'; import getErrorMessage from 'Utilities/Object/getErrorMessage';
import { icons } from 'Helpers/Props'; import { icons, kinds } from 'Helpers/Props';
import Button from 'Components/Link/Button'; import Button from 'Components/Link/Button';
import Link from 'Components/Link/Link'; import Link from 'Components/Link/Link';
import Icon from 'Components/Icon'; import Icon from 'Components/Icon';
@ -79,7 +79,8 @@ class AddNewMovie extends Component {
render() { render() {
const { const {
error, error,
items items,
hasExistingMovies
} = this.props; } = this.props;
const term = this.state.term; const term = this.state.term;
@ -160,13 +161,34 @@ class AddNewMovie extends Component {
} }
{ {
!term && term ?
null :
<div className={styles.message}> <div className={styles.message}>
<div className={styles.helpText}>It's easy to add a new movie, just start typing the name the movie you want to add.</div> <div className={styles.helpText}>
It's easy to add a new movie, just start typing the name the movie you want to add.
</div>
<div>You can also search using TMDB ID of a movie. eg. tmdb:71663</div> <div>You can also search using TMDB ID of a movie. eg. tmdb:71663</div>
</div> </div>
} }
{
!term && !hasExistingMovies ?
<div className={styles.message}>
<div className={styles.noMoviesText}>
You haven't added any movies yet, do you want to import some or all of your movies first?
</div>
<div>
<Button
to="/add/import"
kind={kinds.PRIMARY}
>
Import Existing Movies
</Button>
</div>
</div> :
null
}
<div /> <div />
</PageContentBodyConnector> </PageContentBodyConnector>
</PageContent> </PageContent>
@ -181,6 +203,7 @@ AddNewMovie.propTypes = {
isAdding: PropTypes.bool.isRequired, isAdding: PropTypes.bool.isRequired,
addError: PropTypes.object, addError: PropTypes.object,
items: PropTypes.arrayOf(PropTypes.object).isRequired, items: PropTypes.arrayOf(PropTypes.object).isRequired,
hasExistingMovies: PropTypes.bool.isRequired,
onMovieLookupChange: PropTypes.func.isRequired, onMovieLookupChange: PropTypes.func.isRequired,
onClearMovieLookup: PropTypes.func.isRequired onClearMovieLookup: PropTypes.func.isRequired
}; };

View File

@ -11,13 +11,15 @@ import AddNewMovie from './AddNewMovie';
function createMapStateToProps() { function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.addMovie, (state) => state.addMovie,
(state) => state.movies.items.length,
(state) => state.router.location, (state) => state.router.location,
(addMovie, location) => { (addMovie, existingMoviesCount, location) => {
const { params } = parseUrl(location.search); const { params } = parseUrl(location.search);
return { return {
...addMovie,
term: params.term, term: params.term,
...addMovie hasExistingMovies: existingMoviesCount > 0
}; };
} }
); );

View File

@ -55,8 +55,10 @@ class AddNewMovieModalContent extends Component {
rootFolderPath, rootFolderPath,
monitor, monitor,
qualityProfileId, qualityProfileId,
folder,
tags, tags,
isSmallScreen, isSmallScreen,
isWindows,
onModalClose, onModalClose,
onInputChange onInputChange
} = this.props; } = this.props;
@ -97,6 +99,15 @@ class AddNewMovieModalContent extends Component {
<FormInputGroup <FormInputGroup
type={inputTypes.ROOT_FOLDER_SELECT} type={inputTypes.ROOT_FOLDER_SELECT}
name="rootFolderPath" name="rootFolderPath"
valueOptions={{
movieFolder: folder,
isWindows
}}
selectedValueOptions={{
movieFolder: folder,
isWindows
}}
helpText={`'${folder}' subfolder will be created automatically`}
onChange={onInputChange} onChange={onInputChange}
{...rootFolderPath} {...rootFolderPath}
/> />
@ -180,8 +191,10 @@ AddNewMovieModalContent.propTypes = {
rootFolderPath: PropTypes.object, rootFolderPath: PropTypes.object,
monitor: PropTypes.object.isRequired, monitor: PropTypes.object.isRequired,
qualityProfileId: PropTypes.object, qualityProfileId: PropTypes.object,
folder: PropTypes.string.isRequired,
tags: PropTypes.object.isRequired, tags: PropTypes.object.isRequired,
isSmallScreen: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired,
isWindows: PropTypes.bool.isRequired,
onModalClose: PropTypes.func.isRequired, onModalClose: PropTypes.func.isRequired,
onInputChange: PropTypes.func.isRequired, onInputChange: PropTypes.func.isRequired,
onAddMoviePress: PropTypes.func.isRequired onAddMoviePress: PropTypes.func.isRequired

View File

@ -4,6 +4,7 @@ import { connect } from 'react-redux';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { setAddMovieDefault, addMovie } from 'Store/Actions/addMovieActions'; import { setAddMovieDefault, addMovie } from 'Store/Actions/addMovieActions';
import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector'; import createDimensionsSelector from 'Store/Selectors/createDimensionsSelector';
import createSystemStatusSelector from 'Store/Selectors/createSystemStatusSelector';
import selectSettings from 'Store/Selectors/selectSettings'; import selectSettings from 'Store/Selectors/selectSettings';
import AddNewMovieModalContent from './AddNewMovieModalContent'; import AddNewMovieModalContent from './AddNewMovieModalContent';
@ -11,7 +12,8 @@ function createMapStateToProps() {
return createSelector( return createSelector(
(state) => state.addMovie, (state) => state.addMovie,
createDimensionsSelector(), createDimensionsSelector(),
(addMovieState, dimensions) => { createSystemStatusSelector(),
(addMovieState, dimensions, systemStatus) => {
const { const {
isAdding, isAdding,
addError, addError,
@ -30,6 +32,7 @@ function createMapStateToProps() {
isSmallScreen: dimensions.isSmallScreen, isSmallScreen: dimensions.isSmallScreen,
validationErrors, validationErrors,
validationWarnings, validationWarnings,
isWindows: systemStatus.isWindows,
...settings ...settings
}; };
} }

View File

@ -52,6 +52,7 @@ class AddNewMovieSearchResult extends Component {
status, status,
overview, overview,
ratings, ratings,
folder,
images, images,
isExistingMovie, isExistingMovie,
isExclusionMovie, isExclusionMovie,
@ -148,6 +149,7 @@ class AddNewMovieSearchResult extends Component {
title={title} title={title}
year={year} year={year}
overview={overview} overview={overview}
folder={folder}
images={images} images={images}
onModalClose={this.onAddMovieModalClose} onModalClose={this.onAddMovieModalClose}
/> />
@ -165,6 +167,7 @@ AddNewMovieSearchResult.propTypes = {
status: PropTypes.string.isRequired, status: PropTypes.string.isRequired,
overview: PropTypes.string, overview: PropTypes.string,
ratings: PropTypes.object.isRequired, ratings: PropTypes.object.isRequired,
folder: PropTypes.string.isRequired,
images: PropTypes.arrayOf(PropTypes.object).isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired,
isExistingMovie: PropTypes.bool.isRequired, isExistingMovie: PropTypes.bool.isRequired,
isExclusionMovie: PropTypes.bool.isRequired, isExclusionMovie: PropTypes.bool.isRequired,

View File

@ -262,6 +262,7 @@ class EnhancedSelectInput extends Component {
isDisabled, isDisabled,
hasError, hasError,
hasWarning, hasWarning,
valueOptions,
selectedValueOptions, selectedValueOptions,
selectedValueComponent: SelectedValueComponent, selectedValueComponent: SelectedValueComponent,
optionComponent: OptionComponent optionComponent: OptionComponent
@ -363,6 +364,7 @@ class EnhancedSelectInput extends Component {
key={v.key} key={v.key}
id={v.key} id={v.key}
isSelected={index === selectedIndex} isSelected={index === selectedIndex}
{...valueOptions}
{...v} {...v}
isMobile={false} isMobile={false}
onSelect={this.onSelect} onSelect={this.onSelect}
@ -404,6 +406,7 @@ class EnhancedSelectInput extends Component {
key={v.key} key={v.key}
id={v.key} id={v.key}
isSelected={index === selectedIndex} isSelected={index === selectedIndex}
{...valueOptions}
{...v} {...v}
isMobile={true} isMobile={true}
onSelect={this.onSelect} onSelect={this.onSelect}
@ -431,6 +434,7 @@ EnhancedSelectInput.propTypes = {
isDisabled: PropTypes.bool, isDisabled: PropTypes.bool,
hasError: PropTypes.bool, hasError: PropTypes.bool,
hasWarning: PropTypes.bool, hasWarning: PropTypes.bool,
valueOptions: PropTypes.object.isRequired,
selectedValueOptions: PropTypes.object.isRequired, selectedValueOptions: PropTypes.object.isRequired,
selectedValueComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired, selectedValueComponent: PropTypes.oneOfType([PropTypes.string, PropTypes.func]).isRequired,
optionComponent: PropTypes.elementType, optionComponent: PropTypes.elementType,
@ -441,6 +445,7 @@ EnhancedSelectInput.defaultProps = {
className: styles.enhancedSelect, className: styles.enhancedSelect,
disabledClassName: styles.isDisabled, disabledClassName: styles.isDisabled,
isDisabled: false, isDisabled: false,
valueOptions: {},
selectedValueOptions: {}, selectedValueOptions: {},
selectedValueComponent: HintedSelectInputSelectedValue, selectedValueComponent: HintedSelectInputSelectedValue,
optionComponent: HintedSelectInputOption optionComponent: HintedSelectInputOption

View File

@ -1,4 +1,3 @@
import _ from 'lodash';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React, { Component } from 'react'; import React, { Component } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
@ -13,7 +12,7 @@ function createMapStateToProps() {
(state) => state.rootFolders, (state) => state.rootFolders,
(state, { includeNoChange }) => includeNoChange, (state, { includeNoChange }) => includeNoChange,
(rootFolders, includeNoChange) => { (rootFolders, includeNoChange) => {
const values = _.map(rootFolders.items, (rootFolder) => { const values = rootFolders.items.map((rootFolder) => {
return { return {
key: rootFolder.path, key: rootFolder.path,
value: rootFolder.path, value: rootFolder.path,
@ -85,7 +84,7 @@ class RootFolderSelectInputConnector extends Component {
onChange onChange
} = this.props; } = this.props;
if (!value || !_.some(values, (v) => v.key === value) || value === ADD_NEW_KEY) { if (!value || !values.some((v) => v.key === value) || value === ADD_NEW_KEY) {
const defaultValue = values[0]; const defaultValue = values[0];
if (defaultValue.key === ADD_NEW_KEY) { if (defaultValue.key === ADD_NEW_KEY) {

View File

@ -13,6 +13,15 @@
} }
} }
.value {
display: flex;
}
.movieFolder {
flex: 0 0 auto;
color: $disabledColor;
}
.freeSpace { .freeSpace {
margin-left: 15px; margin-left: 15px;
color: $darkGray; color: $darkGray;

View File

@ -7,14 +7,20 @@ import styles from './RootFolderSelectInputOption.css';
function RootFolderSelectInputOption(props) { function RootFolderSelectInputOption(props) {
const { const {
id,
value, value,
freeSpace, freeSpace,
movieFolder,
isMobile, isMobile,
isWindows,
...otherProps ...otherProps
} = props; } = props;
const slashCharacter = isWindows ? '\\' : '/';
return ( return (
<EnhancedSelectInputOption <EnhancedSelectInputOption
id={id}
isMobile={isMobile} isMobile={isMobile}
{...otherProps} {...otherProps}
> >
@ -23,7 +29,18 @@ function RootFolderSelectInputOption(props) {
isMobile && styles.isMobile isMobile && styles.isMobile
)} )}
> >
<div>{value}</div> <div className={styles.value}>
{value}
{
movieFolder && id !== 'addNew' ?
<div className={styles.movieFolder}>
{slashCharacter}
{movieFolder}
</div> :
null
}
</div>
{ {
freeSpace != null && freeSpace != null &&
@ -37,9 +54,12 @@ function RootFolderSelectInputOption(props) {
} }
RootFolderSelectInputOption.propTypes = { RootFolderSelectInputOption.propTypes = {
id: PropTypes.string.isRequired,
value: PropTypes.string.isRequired, value: PropTypes.string.isRequired,
freeSpace: PropTypes.number, freeSpace: PropTypes.number,
isMobile: PropTypes.bool.isRequired movieFolder: PropTypes.string,
isMobile: PropTypes.bool.isRequired,
isWindows: PropTypes.bool
}; };
export default RootFolderSelectInputOption; export default RootFolderSelectInputOption;

View File

@ -7,10 +7,20 @@
overflow: hidden; overflow: hidden;
} }
.pathContainer {
@add-mixin truncate;
display: flex;
flex: 1 0 0;
}
.path { .path {
@add-mixin truncate; @add-mixin truncate;
flex: 0 1 auto;
}
flex: 1 0 0; .movieFolder {
flex: 0 1 auto;
color: $disabledColor;
} }
.freeSpace { .freeSpace {

View File

@ -8,17 +8,32 @@ function RootFolderSelectInputSelectedValue(props) {
const { const {
value, value,
freeSpace, freeSpace,
movieFolder,
includeFreeSpace, includeFreeSpace,
isWindows,
...otherProps ...otherProps
} = props; } = props;
const slashCharacter = isWindows ? '\\' : '/';
return ( return (
<EnhancedSelectInputSelectedValue <EnhancedSelectInputSelectedValue
className={styles.selectedValue} className={styles.selectedValue}
{...otherProps} {...otherProps}
> >
<div className={styles.path}> <div className={styles.pathContainer}>
{value} <div className={styles.path}>
{value}
</div>
{
movieFolder ?
<div className={styles.movieFolder}>
{slashCharacter}
{movieFolder}
</div> :
null
}
</div> </div>
{ {
@ -34,6 +49,8 @@ function RootFolderSelectInputSelectedValue(props) {
RootFolderSelectInputSelectedValue.propTypes = { RootFolderSelectInputSelectedValue.propTypes = {
value: PropTypes.string, value: PropTypes.string,
freeSpace: PropTypes.number, freeSpace: PropTypes.number,
movieFolder: PropTypes.string,
isWindows: PropTypes.bool,
includeFreeSpace: PropTypes.bool.isRequired includeFreeSpace: PropTypes.bool.isRequired
}; };

View File

@ -227,19 +227,9 @@ public static Core.Movies.Movie ToModel(this MovieResource resource)
public static Core.Movies.Movie ToModel(this MovieResource resource, Core.Movies.Movie movie) public static Core.Movies.Movie ToModel(this MovieResource resource, Core.Movies.Movie movie)
{ {
movie.ImdbId = resource.ImdbId; var updatedmovie = resource.ToModel();
movie.TmdbId = resource.TmdbId;
movie.Path = resource.Path; movie.ApplyChanges(updatedmovie);
movie.ProfileId = resource.ProfileId;
movie.PathState = resource.PathState;
movie.Monitored = resource.Monitored;
movie.MinimumAvailability = resource.MinimumAvailability;
movie.RootFolderPath = resource.RootFolderPath;
movie.Tags = resource.Tags;
movie.AddOptions = resource.AddOptions;
return movie; return movie;
} }

View File

@ -81,6 +81,15 @@ public static string GetParentPath(this string childPath)
return Directory.GetParent(cleanPath)?.FullName; return Directory.GetParent(cleanPath)?.FullName;
} }
public static string GetCleanPath(this string path)
{
var cleanPath = OsInfo.IsWindows
? PARENT_PATH_END_SLASH_REGEX.Replace(path, "")
: path.TrimEnd(Path.DirectorySeparatorChar);
return cleanPath;
}
public static bool IsParentPath(this string parentPath, string childPath) public static bool IsParentPath(this string parentPath, string childPath)
{ {
if (parentPath != "/" && !parentPath.EndsWith(":\\")) if (parentPath != "/" && !parentPath.EndsWith(":\\"))

View File

@ -142,6 +142,22 @@ public override string ToString()
{ {
return string.Format("[{1} ({2})][{0}, {3}]", ImdbId, Title.NullSafe(), Year.NullSafe(), TmdbId); return string.Format("[{1} ({2})][{0}, {3}]", ImdbId, Title.NullSafe(), Year.NullSafe(), TmdbId);
} }
public void ApplyChanges(Movie otherMovie)
{
TmdbId = otherMovie.TmdbId;
Path = otherMovie.Path;
ProfileId = otherMovie.ProfileId;
PathState = otherMovie.PathState;
Monitored = otherMovie.Monitored;
MinimumAvailability = otherMovie.MinimumAvailability;
RootFolderPath = otherMovie.RootFolderPath;
Tags = otherMovie.Tags;
AddOptions = otherMovie.AddOptions;
}
} }
public enum MoviePathState public enum MoviePathState

View File

@ -1,25 +0,0 @@
using NzbDrone.Core.Messaging.Commands;
using NzbDrone.Core.Messaging.Events;
using NzbDrone.Core.Movies.Commands;
using NzbDrone.Core.Movies.Events;
namespace NzbDrone.Core.Movies
{
public class MovieEditedService : IHandle<MovieEditedEvent>
{
private readonly IManageCommandQueue _commandQueueManager;
public MovieEditedService(IManageCommandQueue commandQueueManager)
{
_commandQueueManager = commandQueueManager;
}
public void Handle(MovieEditedEvent message)
{
if (message.Movie.ImdbId != message.OldMovie.ImdbId)
{
_commandQueueManager.Push(new RefreshMovieCommand(message.Movie.Id)); //Probably not needed, as metadata should stay the same.
}
}
}
}

View File

@ -0,0 +1,39 @@
using System;
using System.IO;
using FluentValidation.Validators;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Organizer;
namespace Radarr.Api.V2.Movies
{
public class MovieFolderAsRootFolderValidator : PropertyValidator
{
private readonly IBuildFileNames _fileNameBuilder;
public MovieFolderAsRootFolderValidator(IBuildFileNames fileNameBuilder)
: base("Root folder path contains movie folder")
{
_fileNameBuilder = fileNameBuilder;
}
protected override bool IsValid(PropertyValidatorContext context)
{
if (context.PropertyValue == null) return true;
var movieResource = context.Instance as MovieResource;
if (movieResource == null) return true;
var rootFolderPath = context.PropertyValue.ToString();
var rootFolder = new DirectoryInfo(rootFolderPath).Name;
var movie = movieResource.ToModel();
var movieFolder = _fileNameBuilder.GetMovieFolder(movie);
if (movieFolder == rootFolder) return false;
var distance = movieFolder.LevenshteinDistance(rootFolder);
return distance >= Math.Max(1, movieFolder.Length * 0.2);
}
}
}

View File

@ -8,6 +8,7 @@
using System; using System;
using Radarr.Http; using Radarr.Http;
using Radarr.Http.REST; using Radarr.Http.REST;
using NzbDrone.Core.Organizer;
namespace Radarr.Api.V2.Movies namespace Radarr.Api.V2.Movies
{ {
@ -15,12 +16,14 @@ public class MovieLookupModule : RadarrRestModule<MovieResource>
{ {
private readonly ISearchForNewMovie _searchProxy; private readonly ISearchForNewMovie _searchProxy;
private readonly IProvideMovieInfo _movieInfo; private readonly IProvideMovieInfo _movieInfo;
private readonly IBuildFileNames _fileNameBuilder;
public MovieLookupModule(ISearchForNewMovie searchProxy, IProvideMovieInfo movieInfo) public MovieLookupModule(ISearchForNewMovie searchProxy, IProvideMovieInfo movieInfo, IBuildFileNames fileNameBuilder)
: base("/movie/lookup") : base("/movie/lookup")
{ {
_movieInfo = movieInfo; _movieInfo = movieInfo;
_searchProxy = searchProxy; _searchProxy = searchProxy;
_fileNameBuilder = fileNameBuilder;
Get("/", x => Search()); Get("/", x => Search());
Get("/tmdb", x => SearchByTmdbId()); Get("/tmdb", x => SearchByTmdbId());
Get("/imdb", x => SearchByImdbId()); Get("/imdb", x => SearchByImdbId());
@ -51,17 +54,19 @@ private object Search()
return MapToResource(imdbResults); return MapToResource(imdbResults);
} }
private static IEnumerable<MovieResource> MapToResource(IEnumerable<Movie> movies) private IEnumerable<MovieResource> MapToResource(IEnumerable<Movie> movies)
{ {
foreach (var currentSeries in movies) foreach (var currentMovie in movies)
{ {
var resource = currentSeries.ToResource(); var resource = currentMovie.ToResource();
var poster = currentSeries.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster); var poster = currentMovie.Images.FirstOrDefault(c => c.CoverType == MediaCoverTypes.Poster);
if (poster != null) if (poster != null)
{ {
resource.RemotePoster = poster.Url; resource.RemotePoster = poster.Url;
} }
resource.Folder = _fileNameBuilder.GetMovieFolder(currentMovie);
yield return resource; yield return resource;
} }
} }

View File

@ -38,7 +38,8 @@ public MovieModule(IBroadcastSignalRMessage signalRBroadcaster,
MoviePathValidator moviesPathValidator, MoviePathValidator moviesPathValidator,
MovieExistsValidator moviesExistsValidator, MovieExistsValidator moviesExistsValidator,
MovieAncestorValidator moviesAncestorValidator, MovieAncestorValidator moviesAncestorValidator,
ProfileExistsValidator profileExistsValidator ProfileExistsValidator profileExistsValidator,
MovieFolderAsRootFolderValidator movieFolderAsRootFolderValidator
) )
: base(signalRBroadcaster) : base(signalRBroadcaster)
{ {
@ -65,7 +66,10 @@ ProfileExistsValidator profileExistsValidator
SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(profileExistsValidator); SharedValidator.RuleFor(s => s.QualityProfileId).SetValidator(profileExistsValidator);
PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.Path).IsValidPath().When(s => s.RootFolderPath.IsNullOrWhiteSpace());
PostValidator.RuleFor(s => s.RootFolderPath).IsValidPath().When(s => s.Path.IsNullOrWhiteSpace()); PostValidator.RuleFor(s => s.RootFolderPath)
.IsValidPath()
.SetValidator(movieFolderAsRootFolderValidator)
.When(s => s.Path.IsNullOrWhiteSpace());
PostValidator.RuleFor(s => s.Title).NotEmpty(); PostValidator.RuleFor(s => s.Title).NotEmpty();
PostValidator.RuleFor(s => s.TmdbId).NotNull().NotEmpty().SetValidator(moviesExistsValidator); PostValidator.RuleFor(s => s.TmdbId).NotNull().NotEmpty().SetValidator(moviesExistsValidator);

View File

@ -58,6 +58,7 @@ public MovieResource()
public int TmdbId { get; set; } public int TmdbId { get; set; }
public string TitleSlug { get; set; } public string TitleSlug { get; set; }
public string RootFolderPath { get; set; } public string RootFolderPath { get; set; }
public string Folder { get; set; }
public string Certification { get; set; } public string Certification { get; set; }
public List<string> Genres { get; set; } public List<string> Genres { get; set; }
public HashSet<int> Tags { get; set; } public HashSet<int> Tags { get; set; }
@ -178,19 +179,9 @@ public static Movie ToModel(this MovieResource resource)
public static Movie ToModel(this MovieResource resource, Movie movie) public static Movie ToModel(this MovieResource resource, Movie movie)
{ {
movie.ImdbId = resource.ImdbId; var updatedmovie = resource.ToModel();
movie.TmdbId = resource.TmdbId;
movie.Path = resource.Path; movie.ApplyChanges(updatedmovie);
movie.ProfileId = resource.QualityProfileId;
movie.PathState = resource.PathState;
movie.Monitored = resource.Monitored;
movie.MinimumAvailability = resource.MinimumAvailability;
movie.RootFolderPath = resource.RootFolderPath;
movie.Tags = resource.Tags;
movie.AddOptions = resource.AddOptions;
return movie; return movie;
} }

View File

@ -1,5 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.RootFolders; using NzbDrone.Core.RootFolders;
using Radarr.Http.REST; using Radarr.Http.REST;
@ -23,7 +24,7 @@ public static RootFolderResource ToResource(this RootFolder model)
{ {
Id = model.Id, Id = model.Id,
Path = model.Path, Path = model.Path.GetCleanPath(),
FreeSpace = model.FreeSpace, FreeSpace = model.FreeSpace,
UnmappedFolders = model.UnmappedFolders UnmappedFolders = model.UnmappedFolders
}; };
@ -37,7 +38,7 @@ public static RootFolder ToModel(this RootFolderResource resource)
{ {
Id = resource.Id, Id = resource.Id,
Path = resource.Path, Path = resource.Path
//FreeSpace //FreeSpace
//UnmappedFolders //UnmappedFolders
}; };