From 91f6503b225357723fe728ac71b0c0afb9b61f2e Mon Sep 17 00:00:00 2001 From: meisnate12 Date: Fri, 19 Mar 2021 01:16:37 -0400 Subject: [PATCH] fix for #126 --- modules/builder.py | 2 +- modules/tmdb.py | 4 ++++ modules/util.py | 6 ++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/builder.py b/modules/builder.py index 6f03f599..73bdd0e2 100644 --- a/modules/builder.py +++ b/modules/builder.py @@ -470,7 +470,7 @@ class CollectionBuilder: elif attr in ["include_adult", "include_null_first_air_dates", "screened_theatrically"]: if attr_data is True: 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 util.discover_dates: new_dictionary[attr] = util.check_date(attr_data, f"{m} attribute {attr}", return_string=True) elif attr in ["primary_release_year", "year", "first_air_date_year"]: new_dictionary[attr] = util.check_number(attr_data, f"{m} attribute {attr}", minimum=1800, maximum=current_year + 1) diff --git a/modules/tmdb.py b/modules/tmdb.py index 076ae6d5..da8a98c9 100644 --- a/modules/tmdb.py +++ b/modules/tmdb.py @@ -1,4 +1,5 @@ import logging, tmdbv3api +from datetime import datetime from modules import util from modules.util import Failed from retrying import retry @@ -155,6 +156,9 @@ class TMDbAPI: def get_discover(self, attrs, amount, is_movie): ids = [] count = 0 + for date_attr in util.discover_dates: + if date_attr in attrs: + attrs[date_attr] = datetime.strftime(datetime.strptime(attrs[date_attr], "%m/%d/%Y"), "%Y-%m-%d") self.Discover.discover_movies(attrs) if is_movie else self.Discover.discover_tv_shows(attrs) total_pages = int(self.TMDb.total_pages) total_results = int(self.TMDb.total_results) diff --git a/modules/util.py b/modules/util.py index 8d19debf..f935b2b8 100644 --- a/modules/util.py +++ b/modules/util.py @@ -516,6 +516,12 @@ discover_tv = [ "include_null_first_air_dates", "screened_theatrically" ] +discover_dates = [ + "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" +] discover_movie_sort = [ "popularity.asc", "popularity.desc", "release_date.asc", "release_date.desc",