Skip to content

Commit

Permalink
Replace NonEmptyDict with normal dict, use x-nullable
Browse files Browse the repository at this point in the history
medusa/tv/series.py
  • Loading branch information
sharkykh committed Jul 26, 2018
1 parent a6b209f commit 946a393
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
3 changes: 2 additions & 1 deletion dredd/api-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,7 @@ definitions:
type: string
format: date-time
description: Next episode air date
x-nullable: true
runtime:
type: integer
minimum: 1
Expand Down Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions medusa/tv/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 946a393

Please sign in to comment.