@ -1,68 +1,31 @@
import _ from 'lodash' ;
function monitorSeasons ( seasons , startingSeason ) {
seasons . forEach ( ( season ) => {
if ( season . seasonNumber >= startingSeason ) {
season . monitored = true ;
} else {
season . monitored = false ;
}
} ) ;
}
function getMonitoringOptions ( albums , monitor ) {
if ( ! albums . length ) {
return {
albums : [ ] ,
options : {
ignoreEpisodesWithFiles : false ,
ignoreEpisodesWithoutFiles : false
}
} ;
}
const firstSeason = _ . minBy ( _ . reject ( albums , { seasonNumber : 0 } ) , 'seasonNumber' ) . seasonNumber ;
const lastSeason = _ . maxBy ( albums , 'seasonNumber' ) . seasonNumber ;
monitorSeasons ( albums , firstSeason ) ;
function getMonitoringOptions ( monitor ) {
const monitoringOptions = {
ignoreEpisodesWithFiles : false ,
ignoreEpisodesWithoutFiles : false
ignoreAlbumsWithFiles : false ,
ignoreAlbumsWithoutFiles : false ,
monitored : true
} ;
switch ( monitor ) {
case 'future' :
monitoringOptions . ignoreEpisodesWithFiles = true ;
monitoringOptions . ignoreEpisodesWithoutFiles = true ;
break ;
case 'latest' :
monitorSeasons ( albums , lastSeason ) ;
break ;
case 'first' :
monitorSeasons ( albums , lastSeason + 1 ) ;
_ . find ( albums , { seasonNumber : firstSeason } ) . monitored = true ;
monitoringOptions . ignoreAlbumsWithFiles = true ;
monitoringOptions . ignoreAlbumsWithoutFiles = true ;
break ;
case 'missing' :
monitoringOptions . ignore Episode sWithFiles = true ;
monitoringOptions . ignoreAlbumsWithFiles = true ;
break ;
case 'existing' :
monitoringOptions . ignore Episode sWithoutFiles = true ;
monitoringOptions . ignoreAlbumsWithoutFiles = true ;
break ;
case 'none' :
monitor Seasons( albums , lastSeason + 1 ) ;
monitoringOptions . monitored = false ;
break ;
default :
break ;
}
return {
seasons : _ . map ( albums , ( season ) => {
return _ . pick ( season , [
'seasonNumber' ,
'monitored'
] ) ;
} ) ,
options : monitoringOptions
} ;
}