Improve default series type handling (for daily series)

New: Display default series type when adding new/existing series when available
Fixed: Don't override series type on series refresh
pull/3484/head
Mark McDowall 5 years ago
parent e9b537b6e6
commit db42256dc3

@ -14,6 +14,7 @@ import ModalBody from 'Components/Modal/ModalBody';
import ModalFooter from 'Components/Modal/ModalFooter'; import ModalFooter from 'Components/Modal/ModalFooter';
import Popover from 'Components/Tooltip/Popover'; import Popover from 'Components/Tooltip/Popover';
import SeriesPoster from 'Series/SeriesPoster'; import SeriesPoster from 'Series/SeriesPoster';
import * as seriesTypes from 'Utilities/Series/seriesTypes';
import SeriesMonitoringOptionsPopoverContent from 'AddSeries/SeriesMonitoringOptionsPopoverContent'; import SeriesMonitoringOptionsPopoverContent from 'AddSeries/SeriesMonitoringOptionsPopoverContent';
import SeriesTypePopoverContent from 'AddSeries/SeriesTypePopoverContent'; import SeriesTypePopoverContent from 'AddSeries/SeriesTypePopoverContent';
import styles from './AddNewSeriesModalContent.css'; import styles from './AddNewSeriesModalContent.css';
@ -27,10 +28,19 @@ class AddNewSeriesModalContent extends Component {
super(props, context); super(props, context);
this.state = { this.state = {
seriesType: props.initialSeriesType === seriesTypes.STANDARD ?
props.seriesType.value :
props.initialSeriesType,
searchForMissingEpisodes: false searchForMissingEpisodes: false
}; };
} }
componentDidUpdate(prevProps) {
if (this.props.seriesType.value !== prevProps.seriesType.value) {
this.setState({ seriesType: this.props.seriesType.value });
}
}
// //
// Listeners // Listeners
@ -47,7 +57,12 @@ class AddNewSeriesModalContent extends Component {
} }
onAddSeriesPress = () => { onAddSeriesPress = () => {
this.props.onAddSeriesPress(this.state.searchForMissingEpisodes); const {
searchForMissingEpisodes,
seriesType
} = this.state;
this.props.onAddSeriesPress(searchForMissingEpisodes, seriesType);
} }
// //
@ -200,6 +215,7 @@ class AddNewSeriesModalContent extends Component {
name="seriesType" name="seriesType"
onChange={onInputChange} onChange={onInputChange}
{...seriesType} {...seriesType}
value={this.state.seriesType}
/> />
</FormGroup> </FormGroup>
@ -262,6 +278,7 @@ AddNewSeriesModalContent.propTypes = {
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
year: PropTypes.number.isRequired, year: PropTypes.number.isRequired,
overview: PropTypes.string, overview: PropTypes.string,
initialSeriesType: PropTypes.string.isRequired,
images: PropTypes.arrayOf(PropTypes.object).isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired,
isAdding: PropTypes.bool.isRequired, isAdding: PropTypes.bool.isRequired,
addError: PropTypes.object, addError: PropTypes.object,

@ -55,14 +55,13 @@ class AddNewSeriesModalContentConnector extends Component {
this.props.setAddSeriesDefault({ [name]: value }); this.props.setAddSeriesDefault({ [name]: value });
} }
onAddSeriesPress = (searchForMissingEpisodes) => { onAddSeriesPress = (searchForMissingEpisodes, seriesType) => {
const { const {
tvdbId, tvdbId,
rootFolderPath, rootFolderPath,
monitor, monitor,
qualityProfileId, qualityProfileId,
languageProfileId, languageProfileId,
seriesType,
seasonFolder, seasonFolder,
tags tags
} = this.props; } = this.props;
@ -73,7 +72,7 @@ class AddNewSeriesModalContentConnector extends Component {
monitor: monitor.value, monitor: monitor.value,
qualityProfileId: qualityProfileId.value, qualityProfileId: qualityProfileId.value,
languageProfileId: languageProfileId.value, languageProfileId: languageProfileId.value,
seriesType: seriesType.value, seriesType,
seasonFolder: seasonFolder.value, seasonFolder: seasonFolder.value,
tags: tags.value, tags: tags.value,
searchForMissingEpisodes searchForMissingEpisodes

@ -58,6 +58,7 @@ class AddNewSeriesSearchResult extends Component {
statistics, statistics,
ratings, ratings,
folder, folder,
seriesType,
images, images,
isExistingSeries, isExistingSeries,
isSmallScreen isSmallScreen
@ -191,6 +192,7 @@ class AddNewSeriesSearchResult extends Component {
year={year} year={year}
overview={overview} overview={overview}
folder={folder} folder={folder}
initialSeriesType={seriesType}
images={images} images={images}
onModalClose={this.onAddSeriesModalClose} onModalClose={this.onAddSeriesModalClose}
/> />
@ -210,6 +212,7 @@ AddNewSeriesSearchResult.propTypes = {
statistics: PropTypes.object.isRequired, statistics: PropTypes.object.isRequired,
ratings: PropTypes.object.isRequired, ratings: PropTypes.object.isRequired,
folder: PropTypes.string.isRequired, folder: PropTypes.string.isRequired,
seriesType: PropTypes.string.isRequired,
images: PropTypes.arrayOf(PropTypes.object).isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired,
isExistingSeries: PropTypes.bool.isRequired, isExistingSeries: PropTypes.bool.isRequired,
isSmallScreen: PropTypes.bool.isRequired isSmallScreen: PropTypes.bool.isRequired

@ -90,6 +90,7 @@ function ImportSeriesRow(props) {
<ImportSeriesSelectSeriesConnector <ImportSeriesSelectSeriesConnector
id={id} id={id}
isExistingSeries={isExistingSeries} isExistingSeries={isExistingSeries}
onInputChange={onInputChange}
/> />
</VirtualTableRowCell> </VirtualTableRowCell>
</VirtualTableRow> </VirtualTableRow>

@ -1,10 +1,10 @@
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';
import { createSelector } from 'reselect'; import { createSelector } from 'reselect';
import { queueLookupSeries, setImportSeriesValue } from 'Store/Actions/importSeriesActions'; import { queueLookupSeries, setImportSeriesValue } from 'Store/Actions/importSeriesActions';
import createImportSeriesItemSelector from 'Store/Selectors/createImportSeriesItemSelector'; import createImportSeriesItemSelector from 'Store/Selectors/createImportSeriesItemSelector';
import * as seriesTypes from 'Utilities/Series/seriesTypes';
import ImportSeriesSelectSeries from './ImportSeriesSelectSeries'; import ImportSeriesSelectSeries from './ImportSeriesSelectSeries';
function createMapStateToProps() { function createMapStateToProps() {
@ -41,13 +41,23 @@ class ImportSeriesSelectSeriesConnector extends Component {
onSeriesSelect = (tvdbId) => { onSeriesSelect = (tvdbId) => {
const { const {
id, id,
items items,
onInputChange
} = this.props; } = this.props;
const selectedSeries = items.find((item) => item.tvdbId === tvdbId);
this.props.setImportSeriesValue({ this.props.setImportSeriesValue({
id, id,
selectedSeries: _.find(items, { tvdbId }) selectedSeries
}); });
if (selectedSeries.seriesType !== seriesTypes.STANDARD) {
onInputChange({
name: 'seriesType',
value: selectedSeries.seriesType
});
}
} }
// //
@ -69,6 +79,7 @@ ImportSeriesSelectSeriesConnector.propTypes = {
items: PropTypes.arrayOf(PropTypes.object), items: PropTypes.arrayOf(PropTypes.object),
selectedSeries: PropTypes.object, selectedSeries: PropTypes.object,
isSelected: PropTypes.bool, isSelected: PropTypes.bool,
onInputChange: PropTypes.func.isRequired,
queueLookupSeries: PropTypes.func.isRequired, queueLookupSeries: PropTypes.func.isRequired,
setImportSeriesValue: PropTypes.func.isRequired setImportSeriesValue: PropTypes.func.isRequired
}; };

@ -1,11 +1,12 @@
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import React from 'react'; import React from 'react';
import * as seriesTypes from 'Utilities/Series/seriesTypes';
import SelectInput from './SelectInput'; import SelectInput from './SelectInput';
const seriesTypeOptions = [ const seriesTypeOptions = [
{ key: 'standard', value: 'Standard' }, { key: seriesTypes.STANDARD, value: 'Standard' },
{ key: 'daily', value: 'Daily' }, { key: seriesTypes.DAILY, value: 'Daily' },
{ key: 'anime', value: 'Anime' } { key: seriesTypes.ANIME, value: 'Anime' }
]; ];
function SeriesTypeSelectInput(props) { function SeriesTypeSelectInput(props) {

@ -6,6 +6,7 @@ import getSectionState from 'Utilities/State/getSectionState';
import updateSectionState from 'Utilities/State/updateSectionState'; import updateSectionState from 'Utilities/State/updateSectionState';
import createAjaxRequest from 'Utilities/createAjaxRequest'; import createAjaxRequest from 'Utilities/createAjaxRequest';
import getNewSeries from 'Utilities/Series/getNewSeries'; import getNewSeries from 'Utilities/Series/getNewSeries';
import * as seriesTypes from 'Utilities/Series/seriesTypes';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer'; import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer';
import createHandleActions from './Creators/createHandleActions'; import createHandleActions from './Creators/createHandleActions';
@ -34,7 +35,7 @@ export const defaultState = {
monitor: monitorOptions[0].key, monitor: monitorOptions[0].key,
qualityProfileId: 0, qualityProfileId: 0,
languageProfileId: 0, languageProfileId: 0,
seriesType: 'standard', seriesType: seriesTypes.STANDARD,
seasonFolder: true, seasonFolder: true,
tags: [] tags: []
} }

@ -5,6 +5,7 @@ import createAjaxRequest from 'Utilities/createAjaxRequest';
import getSectionState from 'Utilities/State/getSectionState'; import getSectionState from 'Utilities/State/getSectionState';
import updateSectionState from 'Utilities/State/updateSectionState'; import updateSectionState from 'Utilities/State/updateSectionState';
import getNewSeries from 'Utilities/Series/getNewSeries'; import getNewSeries from 'Utilities/Series/getNewSeries';
import * as seriesTypes from 'Utilities/Series/seriesTypes';
import { createThunk, handleThunks } from 'Store/thunks'; import { createThunk, handleThunks } from 'Store/thunks';
import createHandleActions from './Creators/createHandleActions'; import createHandleActions from './Creators/createHandleActions';
import { set, removeItem, updateItem } from './baseActions'; import { set, removeItem, updateItem } from './baseActions';
@ -149,7 +150,9 @@ export const actionHandlers = handleThunks({
abortCurrentLookup = abortRequest; abortCurrentLookup = abortRequest;
request.done((data) => { request.done((data) => {
dispatch(updateItem({ const selectedSeries = queued.selectedSeries || data[0];
const itemProps = {
section, section,
id: queued.id, id: queued.id,
isFetching: false, isFetching: false,
@ -157,9 +160,15 @@ export const actionHandlers = handleThunks({
error: null, error: null,
items: data, items: data,
isQueued: false, isQueued: false,
selectedSeries: queued.selectedSeries || data[0], selectedSeries,
updateOnly: true updateOnly: true
})); };
if (selectedSeries.seriesType !== seriesTypes.STANDARD) {
itemProps.seriesType = selectedSeries.seriesType;
}
dispatch(updateItem(itemProps));
}); });
request.fail((xhr) => { request.fail((xhr) => {

@ -0,0 +1,3 @@
export const ANIME = 'anime';
export const DAILY = 'daily';
export const STANDARD = 'standard';

@ -7,6 +7,7 @@ using NLog;
using NzbDrone.Common.Cloud; using NzbDrone.Common.Cloud;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Http; using NzbDrone.Common.Http;
using NzbDrone.Core.DataAugmentation.DailySeries;
using NzbDrone.Core.Exceptions; using NzbDrone.Core.Exceptions;
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.SkyHook.Resource; using NzbDrone.Core.MetadataSource.SkyHook.Resource;
@ -19,14 +20,20 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
private readonly IHttpClient _httpClient; private readonly IHttpClient _httpClient;
private readonly Logger _logger; private readonly Logger _logger;
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly IDailySeriesService _dailySeriesService;
private readonly IHttpRequestBuilderFactory _requestBuilder; private readonly IHttpRequestBuilderFactory _requestBuilder;
public SkyHookProxy(IHttpClient httpClient, ISonarrCloudRequestBuilder requestBuilder, ISeriesService seriesService, Logger logger) public SkyHookProxy(IHttpClient httpClient,
ISonarrCloudRequestBuilder requestBuilder,
ISeriesService seriesService,
IDailySeriesService dailySeriesService,
Logger logger)
{ {
_httpClient = httpClient; _httpClient = httpClient;
_requestBuilder = requestBuilder.SkyHookTvdb; _requestBuilder = requestBuilder.SkyHookTvdb;
_logger = logger; _logger = logger;
_seriesService = seriesService; _seriesService = seriesService;
_dailySeriesService = dailySeriesService;
_requestBuilder = requestBuilder.SkyHookTvdb; _requestBuilder = requestBuilder.SkyHookTvdb;
} }
@ -127,8 +134,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
private Series MapSeries(ShowResource show) private Series MapSeries(ShowResource show)
{ {
var series = new Series(); var series = new Series();
series.TvdbId = show.TvdbId; series.TvdbId = show.TvdbId;
@ -176,7 +181,12 @@ namespace NzbDrone.Core.MetadataSource.SkyHook
{ {
series.Certification = show.ContentRating.ToUpper(); series.Certification = show.ContentRating.ToUpper();
} }
if (_dailySeriesService.IsDailySeries(series.TvdbId))
{
series.SeriesType = SeriesTypes.Daily;
}
series.Actors = show.Actors.Select(MapActors).ToList(); series.Actors = show.Actors.Select(MapActors).ToList();
series.Seasons = show.Seasons.Select(MapSeason).ToList(); series.Seasons = show.Seasons.Select(MapSeason).ToList();
series.Images = show.Images.Select(MapImage).ToList(); series.Images = show.Images.Select(MapImage).ToList();

@ -6,7 +6,6 @@ using NLog;
using NzbDrone.Common.Extensions; using NzbDrone.Common.Extensions;
using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Common.Instrumentation.Extensions;
using NzbDrone.Core.Configuration; using NzbDrone.Core.Configuration;
using NzbDrone.Core.DataAugmentation.DailySeries;
using NzbDrone.Core.Exceptions; using NzbDrone.Core.Exceptions;
using NzbDrone.Core.MediaFiles; using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Messaging.Commands; using NzbDrone.Core.Messaging.Commands;
@ -23,7 +22,6 @@ namespace NzbDrone.Core.Tv
private readonly ISeriesService _seriesService; private readonly ISeriesService _seriesService;
private readonly IRefreshEpisodeService _refreshEpisodeService; private readonly IRefreshEpisodeService _refreshEpisodeService;
private readonly IEventAggregator _eventAggregator; private readonly IEventAggregator _eventAggregator;
private readonly IDailySeriesService _dailySeriesService;
private readonly IDiskScanService _diskScanService; private readonly IDiskScanService _diskScanService;
private readonly ICheckIfSeriesShouldBeRefreshed _checkIfSeriesShouldBeRefreshed; private readonly ICheckIfSeriesShouldBeRefreshed _checkIfSeriesShouldBeRefreshed;
private readonly IConfigService _configService; private readonly IConfigService _configService;
@ -33,7 +31,7 @@ namespace NzbDrone.Core.Tv
ISeriesService seriesService, ISeriesService seriesService,
IRefreshEpisodeService refreshEpisodeService, IRefreshEpisodeService refreshEpisodeService,
IEventAggregator eventAggregator, IEventAggregator eventAggregator,
IDailySeriesService dailySeriesService,
IDiskScanService diskScanService, IDiskScanService diskScanService,
ICheckIfSeriesShouldBeRefreshed checkIfSeriesShouldBeRefreshed, ICheckIfSeriesShouldBeRefreshed checkIfSeriesShouldBeRefreshed,
IConfigService configService, IConfigService configService,
@ -43,7 +41,6 @@ namespace NzbDrone.Core.Tv
_seriesService = seriesService; _seriesService = seriesService;
_refreshEpisodeService = refreshEpisodeService; _refreshEpisodeService = refreshEpisodeService;
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_dailySeriesService = dailySeriesService;
_diskScanService = diskScanService; _diskScanService = diskScanService;
_checkIfSeriesShouldBeRefreshed = checkIfSeriesShouldBeRefreshed; _checkIfSeriesShouldBeRefreshed = checkIfSeriesShouldBeRefreshed;
_configService = configService; _configService = configService;
@ -101,11 +98,6 @@ namespace NzbDrone.Core.Tv
series.Genres = seriesInfo.Genres; series.Genres = seriesInfo.Genres;
series.Certification = seriesInfo.Certification; series.Certification = seriesInfo.Certification;
if (_dailySeriesService.IsDailySeries(series.TvdbId))
{
series.SeriesType = SeriesTypes.Daily;
}
try try
{ {
series.Path = new DirectoryInfo(series.Path).FullName; series.Path = new DirectoryInfo(series.Path).FullName;

Loading…
Cancel
Save