From 984d094fd10b6976e463816205f2d8d7438f3dcf Mon Sep 17 00:00:00 2001 From: sharkykh Date: Thu, 26 Jul 2018 10:51:11 +0300 Subject: [PATCH 1/4] Fix #4633 --- medusa/tv/episode.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/medusa/tv/episode.py b/medusa/tv/episode.py index eb53bb1a55..4a1fd89d76 100644 --- a/medusa/tv/episode.py +++ b/medusa/tv/episode.py @@ -401,6 +401,9 @@ def indexer_name(self): @property def air_date(self): """Return air date from the episode.""" + if self.airdate == date.min: + return None + return sbdatetime.convert_to_setting( network_timezones.parse_date_time( date.toordinal(self.airdate), From a6b209fe477c3c9c04342afd08a7b1d1d2729e34 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Thu, 26 Jul 2018 11:23:32 +0300 Subject: [PATCH 2/4] Replace NonEmptyDict with normal dict, use `x-nullable` medusa/tv/episode.py --- dredd/api-description.yml | 1 + medusa/tv/episode.py | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/dredd/api-description.yml b/dredd/api-description.yml index 9e288173e2..46a7ec78d4 100644 --- a/dredd/api-description.yml +++ b/dredd/api-description.yml @@ -1116,6 +1116,7 @@ definitions: airDate: type: string format: date-time + x-nullable: true title: type: string description: Episode title diff --git a/medusa/tv/episode.py b/medusa/tv/episode.py index 4a1fd89d76..b54a732519 100644 --- a/medusa/tv/episode.py +++ b/medusa/tv/episode.py @@ -58,7 +58,6 @@ NoNFOException, ex, ) -from medusa.helper.mappings import NonEmptyDict from medusa.indexers.indexer_api import indexerApi from medusa.indexers.indexer_config import indexerConfig from medusa.indexers.indexer_exceptions import ( @@ -1047,7 +1046,7 @@ def __str__(self): def to_json(self, detailed=True): """Return the json representation.""" - data = NonEmptyDict() + data = {} data['identifier'] = self.identifier data['id'] = {self.indexer_name: self.indexerid} data['season'] = self.season @@ -1064,19 +1063,19 @@ def to_json(self, detailed=True): data['subtitles'] = self.subtitles data['status'] = self.status_name data['quality'] = self.quality - data['release'] = NonEmptyDict() + data['release'] = {} data['release']['name'] = self.release_name data['release']['group'] = self.release_group data['release']['proper'] = self.is_proper data['release']['version'] = self.version - data['scene'] = NonEmptyDict() + data['scene'] = {} data['scene']['season'] = self.scene_season data['scene']['episode'] = self.scene_episode if self.scene_absolute_number: data['scene']['absoluteNumber'] = self.scene_absolute_number - data['file'] = NonEmptyDict() + data['file'] = {} data['file']['location'] = self.location if self.file_size: data['file']['size'] = self.file_size @@ -1087,8 +1086,8 @@ def to_json(self, detailed=True): data['content'].append('thumbnail') if detailed: - data['statistics'] = NonEmptyDict() - data['statistics']['subtitleSearch'] = NonEmptyDict() + data['statistics'] = {} + data['statistics']['subtitleSearch'] = {} data['statistics']['subtitleSearch']['last'] = self.subtitles_lastsearch data['statistics']['subtitleSearch']['count'] = self.subtitles_searchcount data['wantedQualities'] = self.wanted_quality From 946a39320c63a5f229df7248d83fa20415f220f7 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Thu, 26 Jul 2018 11:50:04 +0300 Subject: [PATCH 3/4] Replace NonEmptyDict with normal dict, use `x-nullable` medusa/tv/series.py --- dredd/api-description.yml | 3 ++- medusa/tv/series.py | 19 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/dredd/api-description.yml b/dredd/api-description.yml index 46a7ec78d4..9f677f5898 100644 --- a/dredd/api-description.yml +++ b/dredd/api-description.yml @@ -942,6 +942,7 @@ definitions: type: string format: date-time description: Next episode air date + x-nullable: true runtime: type: integer minimum: 1 @@ -972,7 +973,7 @@ definitions: votes: 558507 classification: type: string - enum: ['TV-Y', 'TV-Y7', 'TV-G', 'TV-PG', 'TV-14', 'TV-MA'] + enum: ['', 'TV-Y', 'TV-Y7', 'TV-G', 'TV-PG', 'TV-14', 'TV-MA'] description: TV Parental Guidelines cache: type: object diff --git a/medusa/tv/series.py b/medusa/tv/series.py index 4aa55525c2..92e77b6248 100644 --- a/medusa/tv/series.py +++ b/medusa/tv/series.py @@ -61,7 +61,6 @@ ShowNotFoundException, ex, ) -from medusa.helper.mappings import NonEmptyDict from medusa.helpers.anidb import get_release_groups_for_anime, short_group_names from medusa.helpers.externals import get_externals, load_externals_from_db from medusa.helpers.utils import safe_get @@ -1958,8 +1957,8 @@ def to_json(self, detailed=True): """Return JSON representation.""" bw_list = self.release_groups or BlackAndWhiteList(self) - data = NonEmptyDict() - data['id'] = NonEmptyDict() + data = {} + data['id'] = {} data['id'][self.indexer_name] = self.series_id data['id']['imdb'] = text_type(self.imdb_id) data['id']['slug'] = self.identifier.slug @@ -1972,27 +1971,27 @@ def to_json(self, detailed=True): data['language'] = self.lang data['showType'] = self.show_type # e.g. anime, sport, series data['akas'] = self.imdb_akas - data['year'] = NonEmptyDict() + data['year'] = {} data['year']['start'] = self.imdb_year or self.start_year data['nextAirDate'] = self.next_airdate.isoformat() if self.next_airdate else None data['runtime'] = self.imdb_runtime or self.runtime data['genres'] = self.genres - data['rating'] = NonEmptyDict() + data['rating'] = {} if self.imdb_rating and self.imdb_votes: - data['rating']['imdb'] = NonEmptyDict() + data['rating']['imdb'] = {} data['rating']['imdb']['rating'] = self.imdb_rating data['rating']['imdb']['votes'] = self.imdb_votes data['classification'] = self.imdb_certificates - data['cache'] = NonEmptyDict() + data['cache'] = {} data['cache']['poster'] = self.poster data['cache']['banner'] = self.banner data['countries'] = self.countries # e.g. ['ITALY', 'FRANCE'] data['country_codes'] = self.imdb_countries # e.g. ['it', 'fr'] data['plot'] = self.plot or self.imdb_plot - data['config'] = NonEmptyDict() + data['config'] = {} data['config']['location'] = self.raw_location - data['config']['qualities'] = NonEmptyDict() + data['config']['qualities'] = {} data['config']['qualities']['allowed'] = self.qualities_allowed data['config']['qualities']['preferred'] = self.qualities_preferred data['config']['paused'] = bool(self.paused) @@ -2006,7 +2005,7 @@ def to_json(self, detailed=True): data['config']['paused'] = bool(self.paused) data['config']['defaultEpisodeStatus'] = self.default_ep_status_name data['config']['aliases'] = list(self.aliases) - data['config']['release'] = NonEmptyDict() + data['config']['release'] = {} # These are for now considered anime-only options, as they query anidb for available release groups. if self.is_anime: data['config']['release']['blacklist'] = bw_list.blacklist From 297ec0bc876f13a1998646f0402fa7f5e090e4c0 Mon Sep 17 00:00:00 2001 From: sharkykh Date: Thu, 26 Jul 2018 11:56:03 +0300 Subject: [PATCH 4/4] Replace NonEmptyDict with normal dict, use `x-nullable` medusa/server/api/v2/alias.py --- dredd/api-description.yml | 6 ++++-- medusa/server/api/v2/alias.py | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dredd/api-description.yml b/dredd/api-description.yml index 9f677f5898..1c0a9a7589 100644 --- a/dredd/api-description.yml +++ b/dredd/api-description.yml @@ -1463,10 +1463,12 @@ definitions: type: string season: type: integer - minimum: 0 + minimum: 1 + x-nullable: true type: type: string - enum: [local] + enum: [null, local] + x-nullable: true example: series: tvdb301824 name: TheBig diff --git a/medusa/server/api/v2/alias.py b/medusa/server/api/v2/alias.py index f1c38a6bc8..d0a75971d0 100644 --- a/medusa/server/api/v2/alias.py +++ b/medusa/server/api/v2/alias.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from medusa import db -from medusa.helper.mappings import NonEmptyDict from medusa.server.api.v2.base import BaseRequestHandler from medusa.tv.series import SeriesIdentifier @@ -71,7 +70,7 @@ def get(self, identifier, path_param): data = [] for item in sql_results: - d = NonEmptyDict() + d = {} d['id'] = item[0] d['series'] = SeriesIdentifier.from_id(item[1], item[2]).slug d['name'] = item[3]