Commit 4fead48c authored by richardARPANET's avatar richardARPANET

adds runtime

parent 4e6c2aff
Pipeline #112 failed with stage
in 9 minutes and 4 seconds
......@@ -30,6 +30,7 @@ Get a title
Returns a ``Title`` object with the following attributes:
- certification
- runtime
- creators
- credits
- directors
......
......@@ -3,17 +3,17 @@
Release History
---------------
5.5.1 (unreleased)
5.6.9 (unreleased)
++++++++++++++++++
- Nothing changed yet.
- Adds ``runtime`` attribute to ``ImdbFacade``.
5.5.0 (2018-05-27)
++++++++++++++++++
- Adds ``get_title_auxiliary`` method to client.
- Adds `ImdbFacade` facade for API.
- Adds ``ImdbFacade`` facade for API.
5.4.5 (2018-04-29)
......
......@@ -21,6 +21,10 @@ class ImdbFacade(object):
def get_title(self, imdb_id):
title_data, title_aux_data = self._get_title_data(imdb_id=imdb_id)
try:
runtime = title_aux_data['runningTimes'][0]['timeMinutes']
except (KeyError, IndexError):
runtime = None
try:
episodes = TitleEpisodes(facade=self, imdb_id=imdb_id)
except LookupError:
......@@ -32,7 +36,8 @@ class ImdbFacade(object):
season = None
episode = None
return Title(
season=season, episode=episode, episodes=episodes, **title_data
season=season, episode=episode, episodes=episodes,
runtime=runtime, **title_data
)
def get_name(self, imdb_id):
......
......@@ -55,6 +55,7 @@ class Title(object):
rating = attr.ib(default=None)
plot_outline = attr.ib(default=None)
release_date = attr.ib(default=None)
runtime = attr.ib(default=None)
def __repr__(self):
return 'Title(imdb_id={0}, title={1})'.format(self.imdb_id, self.title)
......
......@@ -23,6 +23,8 @@ class TestGetTitle(object):
assert isinstance(title, Title)
_check_title(title=title, facade=facade)
assert title.type == 'tvseries'
assert isinstance(title.runtime, int)
assert title.runtime > 0
num_checked = 0
for episode in title.episodes:
......@@ -50,6 +52,8 @@ class TestGetTitle(object):
_check_title(title=title, facade=facade)
assert title.type == 'movie'
assert len(title.episodes) == 0
assert isinstance(title.runtime, int)
assert title.runtime > 0
@pytest.mark.parametrize('imdb_id', [
'tt0795176',
......@@ -62,6 +66,8 @@ class TestGetTitle(object):
_check_title(title=title, facade=facade)
assert title.type in ('tvminiseries', 'movie')
assert isinstance(title.runtime, int)
assert title.runtime > 0
num_checked = 0
for episode in title.episodes:
......@@ -79,6 +85,8 @@ class TestGetTitle(object):
title = facade.get_title(imdb_id=episode_imdb_id)
assert isinstance(title, Title)
assert isinstance(title.runtime, int)
assert title.runtime > 0
assert title.imdb_id == episode_imdb_id
assert len(title.episodes) == 0
assert isinstance(title.season, int)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment