diff --git a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContent.js b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContent.js index 3d2b9f76a..b035f1d06 100644 --- a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContent.js +++ b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContent.js @@ -14,6 +14,7 @@ import ModalBody from 'Components/Modal/ModalBody'; import ModalFooter from 'Components/Modal/ModalFooter'; import Popover from 'Components/Tooltip/Popover'; import SeriesPoster from 'Series/SeriesPoster'; +import * as seriesTypes from 'Utilities/Series/seriesTypes'; import SeriesMonitoringOptionsPopoverContent from 'AddSeries/SeriesMonitoringOptionsPopoverContent'; import SeriesTypePopoverContent from 'AddSeries/SeriesTypePopoverContent'; import styles from './AddNewSeriesModalContent.css'; @@ -27,10 +28,19 @@ class AddNewSeriesModalContent extends Component { super(props, context); this.state = { + seriesType: props.initialSeriesType === seriesTypes.STANDARD ? + props.seriesType.value : + props.initialSeriesType, searchForMissingEpisodes: false }; } + componentDidUpdate(prevProps) { + if (this.props.seriesType.value !== prevProps.seriesType.value) { + this.setState({ seriesType: this.props.seriesType.value }); + } + } + // // Listeners @@ -47,7 +57,12 @@ class AddNewSeriesModalContent extends Component { } 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" onChange={onInputChange} {...seriesType} + value={this.state.seriesType} /> @@ -262,6 +278,7 @@ AddNewSeriesModalContent.propTypes = { title: PropTypes.string.isRequired, year: PropTypes.number.isRequired, overview: PropTypes.string, + initialSeriesType: PropTypes.string.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, isAdding: PropTypes.bool.isRequired, addError: PropTypes.object, diff --git a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContentConnector.js b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContentConnector.js index df7c3d5bd..84595ef76 100644 --- a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContentConnector.js +++ b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesModalContentConnector.js @@ -55,14 +55,13 @@ class AddNewSeriesModalContentConnector extends Component { this.props.setAddSeriesDefault({ [name]: value }); } - onAddSeriesPress = (searchForMissingEpisodes) => { + onAddSeriesPress = (searchForMissingEpisodes, seriesType) => { const { tvdbId, rootFolderPath, monitor, qualityProfileId, languageProfileId, - seriesType, seasonFolder, tags } = this.props; @@ -73,7 +72,7 @@ class AddNewSeriesModalContentConnector extends Component { monitor: monitor.value, qualityProfileId: qualityProfileId.value, languageProfileId: languageProfileId.value, - seriesType: seriesType.value, + seriesType, seasonFolder: seasonFolder.value, tags: tags.value, searchForMissingEpisodes diff --git a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesSearchResult.js b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesSearchResult.js index 3afb67546..31dfa3f5e 100644 --- a/frontend/src/AddSeries/AddNewSeries/AddNewSeriesSearchResult.js +++ b/frontend/src/AddSeries/AddNewSeries/AddNewSeriesSearchResult.js @@ -58,6 +58,7 @@ class AddNewSeriesSearchResult extends Component { statistics, ratings, folder, + seriesType, images, isExistingSeries, isSmallScreen @@ -191,6 +192,7 @@ class AddNewSeriesSearchResult extends Component { year={year} overview={overview} folder={folder} + initialSeriesType={seriesType} images={images} onModalClose={this.onAddSeriesModalClose} /> @@ -210,6 +212,7 @@ AddNewSeriesSearchResult.propTypes = { statistics: PropTypes.object.isRequired, ratings: PropTypes.object.isRequired, folder: PropTypes.string.isRequired, + seriesType: PropTypes.string.isRequired, images: PropTypes.arrayOf(PropTypes.object).isRequired, isExistingSeries: PropTypes.bool.isRequired, isSmallScreen: PropTypes.bool.isRequired diff --git a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesRow.js b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesRow.js index a9dad2af0..509cda2a8 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesRow.js +++ b/frontend/src/AddSeries/ImportSeries/Import/ImportSeriesRow.js @@ -90,6 +90,7 @@ function ImportSeriesRow(props) { diff --git a/frontend/src/AddSeries/ImportSeries/Import/SelectSeries/ImportSeriesSelectSeriesConnector.js b/frontend/src/AddSeries/ImportSeries/Import/SelectSeries/ImportSeriesSelectSeriesConnector.js index a460d6caf..0222d88e4 100644 --- a/frontend/src/AddSeries/ImportSeries/Import/SelectSeries/ImportSeriesSelectSeriesConnector.js +++ b/frontend/src/AddSeries/ImportSeries/Import/SelectSeries/ImportSeriesSelectSeriesConnector.js @@ -1,10 +1,10 @@ -import _ from 'lodash'; import PropTypes from 'prop-types'; import React, { Component } from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; import { queueLookupSeries, setImportSeriesValue } from 'Store/Actions/importSeriesActions'; import createImportSeriesItemSelector from 'Store/Selectors/createImportSeriesItemSelector'; +import * as seriesTypes from 'Utilities/Series/seriesTypes'; import ImportSeriesSelectSeries from './ImportSeriesSelectSeries'; function createMapStateToProps() { @@ -41,13 +41,23 @@ class ImportSeriesSelectSeriesConnector extends Component { onSeriesSelect = (tvdbId) => { const { id, - items + items, + onInputChange } = this.props; + const selectedSeries = items.find((item) => item.tvdbId === tvdbId); + this.props.setImportSeriesValue({ 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), selectedSeries: PropTypes.object, isSelected: PropTypes.bool, + onInputChange: PropTypes.func.isRequired, queueLookupSeries: PropTypes.func.isRequired, setImportSeriesValue: PropTypes.func.isRequired }; diff --git a/frontend/src/Components/Form/SeriesTypeSelectInput.js b/frontend/src/Components/Form/SeriesTypeSelectInput.js index 7b0d0056d..5c9ad0cac 100644 --- a/frontend/src/Components/Form/SeriesTypeSelectInput.js +++ b/frontend/src/Components/Form/SeriesTypeSelectInput.js @@ -1,11 +1,12 @@ import PropTypes from 'prop-types'; import React from 'react'; +import * as seriesTypes from 'Utilities/Series/seriesTypes'; import SelectInput from './SelectInput'; const seriesTypeOptions = [ - { key: 'standard', value: 'Standard' }, - { key: 'daily', value: 'Daily' }, - { key: 'anime', value: 'Anime' } + { key: seriesTypes.STANDARD, value: 'Standard' }, + { key: seriesTypes.DAILY, value: 'Daily' }, + { key: seriesTypes.ANIME, value: 'Anime' } ]; function SeriesTypeSelectInput(props) { diff --git a/frontend/src/Store/Actions/addSeriesActions.js b/frontend/src/Store/Actions/addSeriesActions.js index 934e412dc..76a4c65b6 100644 --- a/frontend/src/Store/Actions/addSeriesActions.js +++ b/frontend/src/Store/Actions/addSeriesActions.js @@ -6,6 +6,7 @@ import getSectionState from 'Utilities/State/getSectionState'; import updateSectionState from 'Utilities/State/updateSectionState'; import createAjaxRequest from 'Utilities/createAjaxRequest'; import getNewSeries from 'Utilities/Series/getNewSeries'; +import * as seriesTypes from 'Utilities/Series/seriesTypes'; import { createThunk, handleThunks } from 'Store/thunks'; import createSetSettingValueReducer from './Creators/Reducers/createSetSettingValueReducer'; import createHandleActions from './Creators/createHandleActions'; @@ -34,7 +35,7 @@ export const defaultState = { monitor: monitorOptions[0].key, qualityProfileId: 0, languageProfileId: 0, - seriesType: 'standard', + seriesType: seriesTypes.STANDARD, seasonFolder: true, tags: [] } diff --git a/frontend/src/Store/Actions/importSeriesActions.js b/frontend/src/Store/Actions/importSeriesActions.js index e8ac97d3a..82378a079 100644 --- a/frontend/src/Store/Actions/importSeriesActions.js +++ b/frontend/src/Store/Actions/importSeriesActions.js @@ -5,6 +5,7 @@ import createAjaxRequest from 'Utilities/createAjaxRequest'; import getSectionState from 'Utilities/State/getSectionState'; import updateSectionState from 'Utilities/State/updateSectionState'; import getNewSeries from 'Utilities/Series/getNewSeries'; +import * as seriesTypes from 'Utilities/Series/seriesTypes'; import { createThunk, handleThunks } from 'Store/thunks'; import createHandleActions from './Creators/createHandleActions'; import { set, removeItem, updateItem } from './baseActions'; @@ -149,7 +150,9 @@ export const actionHandlers = handleThunks({ abortCurrentLookup = abortRequest; request.done((data) => { - dispatch(updateItem({ + const selectedSeries = queued.selectedSeries || data[0]; + + const itemProps = { section, id: queued.id, isFetching: false, @@ -157,9 +160,15 @@ export const actionHandlers = handleThunks({ error: null, items: data, isQueued: false, - selectedSeries: queued.selectedSeries || data[0], + selectedSeries, updateOnly: true - })); + }; + + if (selectedSeries.seriesType !== seriesTypes.STANDARD) { + itemProps.seriesType = selectedSeries.seriesType; + } + + dispatch(updateItem(itemProps)); }); request.fail((xhr) => { diff --git a/frontend/src/Utilities/Series/seriesTypes.js b/frontend/src/Utilities/Series/seriesTypes.js new file mode 100644 index 000000000..bd3248312 --- /dev/null +++ b/frontend/src/Utilities/Series/seriesTypes.js @@ -0,0 +1,3 @@ +export const ANIME = 'anime'; +export const DAILY = 'daily'; +export const STANDARD = 'standard'; diff --git a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs index 0c9cb03ab..9f7c978ca 100644 --- a/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs +++ b/src/NzbDrone.Core/MetadataSource/SkyHook/SkyHookProxy.cs @@ -7,6 +7,7 @@ using NLog; using NzbDrone.Common.Cloud; using NzbDrone.Common.Extensions; using NzbDrone.Common.Http; +using NzbDrone.Core.DataAugmentation.DailySeries; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaCover; using NzbDrone.Core.MetadataSource.SkyHook.Resource; @@ -19,14 +20,20 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private readonly IHttpClient _httpClient; private readonly Logger _logger; private readonly ISeriesService _seriesService; + private readonly IDailySeriesService _dailySeriesService; 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; _requestBuilder = requestBuilder.SkyHookTvdb; _logger = logger; _seriesService = seriesService; + _dailySeriesService = dailySeriesService; _requestBuilder = requestBuilder.SkyHookTvdb; } @@ -127,8 +134,6 @@ namespace NzbDrone.Core.MetadataSource.SkyHook private Series MapSeries(ShowResource show) { - - var series = new Series(); series.TvdbId = show.TvdbId; @@ -176,7 +181,12 @@ namespace NzbDrone.Core.MetadataSource.SkyHook { series.Certification = show.ContentRating.ToUpper(); } - + + if (_dailySeriesService.IsDailySeries(series.TvdbId)) + { + series.SeriesType = SeriesTypes.Daily; + } + series.Actors = show.Actors.Select(MapActors).ToList(); series.Seasons = show.Seasons.Select(MapSeason).ToList(); series.Images = show.Images.Select(MapImage).ToList(); diff --git a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs b/src/NzbDrone.Core/Tv/RefreshSeriesService.cs index 08dbfb71d..4cd6ca656 100644 --- a/src/NzbDrone.Core/Tv/RefreshSeriesService.cs +++ b/src/NzbDrone.Core/Tv/RefreshSeriesService.cs @@ -6,7 +6,6 @@ using NLog; using NzbDrone.Common.Extensions; using NzbDrone.Common.Instrumentation.Extensions; using NzbDrone.Core.Configuration; -using NzbDrone.Core.DataAugmentation.DailySeries; using NzbDrone.Core.Exceptions; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Messaging.Commands; @@ -23,7 +22,6 @@ namespace NzbDrone.Core.Tv private readonly ISeriesService _seriesService; private readonly IRefreshEpisodeService _refreshEpisodeService; private readonly IEventAggregator _eventAggregator; - private readonly IDailySeriesService _dailySeriesService; private readonly IDiskScanService _diskScanService; private readonly ICheckIfSeriesShouldBeRefreshed _checkIfSeriesShouldBeRefreshed; private readonly IConfigService _configService; @@ -33,7 +31,7 @@ namespace NzbDrone.Core.Tv ISeriesService seriesService, IRefreshEpisodeService refreshEpisodeService, IEventAggregator eventAggregator, - IDailySeriesService dailySeriesService, + IDiskScanService diskScanService, ICheckIfSeriesShouldBeRefreshed checkIfSeriesShouldBeRefreshed, IConfigService configService, @@ -43,7 +41,6 @@ namespace NzbDrone.Core.Tv _seriesService = seriesService; _refreshEpisodeService = refreshEpisodeService; _eventAggregator = eventAggregator; - _dailySeriesService = dailySeriesService; _diskScanService = diskScanService; _checkIfSeriesShouldBeRefreshed = checkIfSeriesShouldBeRefreshed; _configService = configService; @@ -101,11 +98,6 @@ namespace NzbDrone.Core.Tv series.Genres = seriesInfo.Genres; series.Certification = seriesInfo.Certification; - if (_dailySeriesService.IsDailySeries(series.TvdbId)) - { - series.SeriesType = SeriesTypes.Daily; - } - try { series.Path = new DirectoryInfo(series.Path).FullName;