Skip to content

Commit

Permalink
Fixes #2 (new shows)
Browse files Browse the repository at this point in the history
  • Loading branch information
Znuff committed Sep 29, 2015
1 parent ece81ae commit da2cca9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,16 @@ def tv(self, irc, msg, args, opts, tvshow):
show = fetch(tvshow)

if show:
if show['premiered']:
premiered = show['premiered']
else:
premiered = "SOON"

show_state = format('%s %s (%s).',
ircutils.bold(ircutils.underline(show['name'])),
show['premiered'][:4], show['status'])
premiered[:4], show['status'])

if 'previousepisode' in show['_embedded']:
if ( '_embedded' in show and 'previousepisode' in show['_embedded']):
airtime = parse(show['_embedded']['previousepisode']['airstamp'])
timedelta = datetime.datetime.now(tzlocal()) - airtime
relative_time = format_timedelta(timedelta,
Expand All @@ -70,7 +75,7 @@ def tv(self, irc, msg, args, opts, tvshow):
else:
last_episode = ''

if 'nextepisode' in show['_embedded']:
if ('_embedded' in show and 'nextepisode' in show['_embedded']):
airtime = parse(show['_embedded']['nextepisode']['airstamp'])
timedelta = datetime.datetime.now(tzlocal()) - airtime
relative_time = format_timedelta(timedelta, granularity='minutes')
Expand Down

0 comments on commit da2cca9

Please sign in to comment.