From d9b95587768676599602c1a91d5e983444d40b48 Mon Sep 17 00:00:00 2001 From: Lasse Vang Gravesen Date: Sat, 10 Aug 2013 01:22:29 +0200 Subject: [PATCH 1/2] tvdb.py: When there's a next episode date, provide a time until in the return string. --- plugins/tvdb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/tvdb.py b/plugins/tvdb.py index 75c1212..df15c11 100644 --- a/plugins/tvdb.py +++ b/plugins/tvdb.py @@ -9,7 +9,7 @@ from zipfile import ZipFile from cStringIO import StringIO from lxml import etree -from util import hook, http +from util import hook, http, timesince base_url = "http://thetvdb.com/api/" @@ -110,7 +110,7 @@ def tv_next(inp): (first_aired, airdate, episode_desc) = ep_info if airdate > today: - next_eps = ['%s (%s)' % (first_aired, episode_desc)] + next_eps = ['%s (%s) (%s)' % (first_aired, timesince.timeuntil(datetime.datetime.strptime(first_aired, "%Y-%m-%d")), episode_desc)] elif airdate == today: next_eps = ['Today (%s)' % episode_desc] + next_eps else: From 8c47b0c2e130cc20055fe6f380e446d3c9386f18 Mon Sep 17 00:00:00 2001 From: Lasse Vang Gravesen Date: Sat, 10 Aug 2013 02:27:06 +0200 Subject: [PATCH 2/2] Renamed first_aired variable to episode_air_date in tvdb plugin. --- plugins/tvdb.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/tvdb.py b/plugins/tvdb.py index df15c11..14aeb5a 100644 --- a/plugins/tvdb.py +++ b/plugins/tvdb.py @@ -60,10 +60,10 @@ def get_episodes_for_series(seriesname): def get_episode_info(episode): - first_aired = episode.findtext("FirstAired") + episode_air_date = episode.findtext("FirstAired") try: - airdate = datetime.date(*map(int, first_aired.split('-'))) + airdate = datetime.date(*map(int, episode_air_date.split('-'))) except (ValueError, TypeError): return None @@ -79,7 +79,7 @@ def get_episode_info(episode): episode_desc = '%s' % episode_num if episode_name: episode_desc += ' - %s' % episode_name - return (first_aired, airdate, episode_desc) + return (episode_air_date, airdate, episode_desc) @hook.command @@ -107,10 +107,10 @@ def tv_next(inp): if ep_info is None: continue - (first_aired, airdate, episode_desc) = ep_info + (episode_air_date, airdate, episode_desc) = ep_info if airdate > today: - next_eps = ['%s (%s) (%s)' % (first_aired, timesince.timeuntil(datetime.datetime.strptime(first_aired, "%Y-%m-%d")), episode_desc)] + next_eps = ['%s (%s) (%s)' % (episode_air_date, timesince.timeuntil(datetime.datetime.strptime(episode_air_date, "%Y-%m-%d")), episode_desc)] elif airdate == today: next_eps = ['Today (%s)' % episode_desc] + next_eps else: @@ -150,12 +150,12 @@ def tv_last(inp): if ep_info is None: continue - (first_aired, airdate, episode_desc) = ep_info + (episode_air_date, airdate, episode_desc) = ep_info if airdate < today: #iterating in reverse order, so the first episode encountered #before today was the most recently aired - prev_ep = '%s (%s)' % (first_aired, episode_desc) + prev_ep = '%s (%s)' % (episode_air_date, episode_desc) break if not prev_ep: