@ -22,6 +22,8 @@ class CollectionBuilder:
self . posters = [ ]
self . posters = [ ]
self . backgrounds = [ ]
self . backgrounds = [ ]
self . schedule = None
self . schedule = None
current_time = datetime . now ( )
current_year = current_time . year
if " template " in data :
if " template " in data :
if not self . library . templates :
if not self . library . templates :
@ -113,7 +115,6 @@ class CollectionBuilder:
skip_collection = False
skip_collection = False
else :
else :
schedule_list = util . get_list ( data [ " schedule " ] )
schedule_list = util . get_list ( data [ " schedule " ] )
current_time = datetime . now ( )
next_month = current_time . replace ( day = 28 ) + timedelta ( days = 4 )
next_month = current_time . replace ( day = 28 ) + timedelta ( days = 4 )
last_day = next_month - timedelta ( days = next_month . day )
last_day = next_month - timedelta ( days = next_month . day )
for schedule in schedule_list :
for schedule in schedule_list :
@ -316,10 +317,24 @@ class CollectionBuilder:
logger . warning ( f " Collection Warning: { f } filter will run as { filter_method } " )
logger . warning ( f " Collection Warning: { f } filter will run as { filter_method } " )
else :
else :
filter_method = f
filter_method = f
if filter_method in util . movie_only_filters and self . library . is_show : raise Failed ( f " Collection Error: { filter_method } filter only works for movie libraries " )
if filter_method in util . movie_only_filters and self . library . is_show :
elif data [ m ] [ f ] is None : raise Failed ( f " Collection Error: { filter_method } filter is blank " )
raise Failed ( f " Collection Error: { filter_method } filter only works for movie libraries " )
elif filter_method in util . all_filters : self . filters . append ( ( filter_method , data [ m ] [ f ] ) )
elif data [ m ] [ f ] is None :
else : raise Failed ( f " Collection Error: { filter_method } filter not supported " )
raise Failed ( f " Collection Error: { filter_method } filter is blank " )
elif filter_method == " year " :
self . filters . append ( ( filter_method , util . get_year_list ( data [ m ] [ f ] , f " { filter_method } filter " ) ) )
elif filter_method in [ " max_age " , " duration.gte " , " duration.lte " ] :
self . filters . append ( ( filter_method , util . check_number ( data [ m ] [ f ] , f " { filter_method } filter " , minimum = 1 ) ) )
elif filter_method in [ " year.gte " , " year.lte " ] :
self . filters . append ( ( filter_method , util . check_number ( data [ m ] [ f ] , f " { filter_method } filter " , minimum = 1800 , maximum = current_year ) ) )
elif filter_method in [ " rating.gte " , " rating.lte " ] :
self . filters . append ( ( filter_method , util . check_number ( data [ m ] [ f ] , f " { filter_method } filter " , number_type = " float " , minimum = 0.1 , maximum = 10 ) ) )
elif filter_method in [ " originally_available.gte " , " originally_available.lte " ] :
self . filters . append ( ( filter_method , util . check_date ( data [ m ] [ f ] , f " { filter_method } filter " ) ) )
elif filter_method in util . all_filters :
self . filters . append ( ( filter_method , data [ m ] [ f ] ) )
else :
raise Failed ( f " Collection Error: { filter_method } filter not supported " )
elif method_name == " plex_collectionless " :
elif method_name == " plex_collectionless " :
new_dictionary = { }
new_dictionary = { }
prefix_list = [ ]
prefix_list = [ ]
@ -396,24 +411,11 @@ class CollectionBuilder:
if attr_data is True :
if attr_data is True :
new_dictionary [ attr ] = attr_data
new_dictionary [ attr ] = attr_data
elif attr in [ " primary_release_date.gte " , " primary_release_date.lte " , " release_date.gte " , " release_date.lte " , " air_date.gte " , " air_date.lte " , " first_air_date.gte " , " first_air_date.lte " ] :
elif attr in [ " primary_release_date.gte " , " primary_release_date.lte " , " release_date.gte " , " release_date.lte " , " air_date.gte " , " air_date.lte " , " first_air_date.gte " , " first_air_date.lte " ] :
if re . compile ( " [0-1]?[0-9][/-][0-3]?[0-9][/-][1-2][890][0-9][0-9] " ) . match ( str ( attr_data ) ) :
new_dictionary [ attr ] = util . check_date ( attr_data , f " { m } attribute { attr } " , return_string = True )
the_date = str ( attr_data ) . split ( " / " ) if " / " in str ( attr_data ) else str ( attr_data ) . split ( " - " )
new_dictionary [ attr ] = f " { the_date [ 2 ] } - { the_date [ 0 ] } - { the_date [ 1 ] } "
elif re . compile ( " [1-2][890][0-9][0-9][/-][0-1]?[0-9][/-][0-3]?[0-9] " ) . match ( str ( attr_data ) ) :
the_date = str ( attr_data ) . split ( " / " ) if " / " in str ( attr_data ) else str ( attr_data ) . split ( " - " )
new_dictionary [ attr ] = f " { the_date [ 0 ] } - { the_date [ 1 ] } - { the_date [ 2 ] } "
else :
raise Failed ( f " Collection Error: { m } attribute { attr } : { attr_data } must match pattern MM/DD/YYYY e.g. 12/25/2020 " )
elif attr in [ " primary_release_year " , " year " , " first_air_date_year " ] :
elif attr in [ " primary_release_year " , " year " , " first_air_date_year " ] :
if isinstance ( attr_data , int ) and 1800 < attr_data < 2200 :
new_dictionary [ attr ] = util . check_number ( attr_data , f " { m } attribute { attr } " , minimum = 1800 , maximum = current_year + 1 )
new_dictionary [ attr ] = attr_data
else :
raise Failed ( f " Collection Error: { m } attribute { attr } : must be a valid year e.g. 1990 " )
elif attr in [ " vote_count.gte " , " vote_count.lte " , " vote_average.gte " , " vote_average.lte " , " with_runtime.gte " , " with_runtime.lte " ] :
elif attr in [ " vote_count.gte " , " vote_count.lte " , " vote_average.gte " , " vote_average.lte " , " with_runtime.gte " , " with_runtime.lte " ] :
if ( isinstance ( attr_data , int ) or isinstance ( attr_data , float ) ) and 0 < attr_data :
new_dictionary [ attr ] = util . check_number ( attr_data , f " { m } attribute { attr } " , minimum = 1 )
new_dictionary [ attr ] = attr_data
else :
raise Failed ( f " Collection Error: { m } attribute { attr } : must be a valid number greater then 0 " )
elif attr in [ " with_cast " , " with_crew " , " with_people " , " with_companies " , " with_networks " , " with_genres " , " without_genres " , " with_keywords " , " without_keywords " , " with_original_language " , " timezone " ] :
elif attr in [ " with_cast " , " with_crew " , " with_people " , " with_companies " , " with_networks " , " with_genres " , " without_genres " , " with_keywords " , " without_keywords " , " with_original_language " , " timezone " ] :
new_dictionary [ attr ] = attr_data
new_dictionary [ attr ] = attr_data
else :
else :
@ -448,7 +450,6 @@ class CollectionBuilder:
elif data [ m ] [ " sort_by " ] not in util . mal_season_sort : logger . warning ( f " Collection Warning: mal_season sort_by attribute { data [ m ] [ ' sort_by ' ] } invalid must be either ' members ' or ' score ' using members as default " )
elif data [ m ] [ " sort_by " ] not in util . mal_season_sort : logger . warning ( f " Collection Warning: mal_season sort_by attribute { data [ m ] [ ' sort_by ' ] } invalid must be either ' members ' or ' score ' using members as default " )
else : new_dictionary [ " sort_by " ] = util . mal_season_sort [ data [ m ] [ " sort_by " ] ]
else : new_dictionary [ " sort_by " ] = util . mal_season_sort [ data [ m ] [ " sort_by " ] ]
current_time = datetime . now ( )
if current_time . month in [ 1 , 2 , 3 ] : new_dictionary [ " season " ] = " winter "
if current_time . month in [ 1 , 2 , 3 ] : new_dictionary [ " season " ] = " winter "
elif current_time . month in [ 4 , 5 , 6 ] : new_dictionary [ " season " ] = " spring "
elif current_time . month in [ 4 , 5 , 6 ] : new_dictionary [ " season " ] = " spring "
elif current_time . month in [ 7 , 8 , 9 ] : new_dictionary [ " season " ] = " summer "
elif current_time . month in [ 7 , 8 , 9 ] : new_dictionary [ " season " ] = " summer "