summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Smith <LS80@users.noreply.github.com>2017-12-14 22:43:23 +0000
committerRechi <Rechi@users.noreply.github.com>2017-12-14 23:43:23 +0100
commit9b1f805af94d8800efa8d51a49e6bcd3fdb4bda0 (patch)
tree6cd1bff75506f22f8f1bb9117ce099b5ca4aa35b
parentf0364004f3af2c8e3ad8b87c36b0e9b040a7711f (diff)
[plugin.video.btsportvideo] 0.2.0 (#1555)
-rw-r--r--plugin.video.btsportvideo/addon.py43
-rw-r--r--plugin.video.btsportvideo/addon.xml8
-rw-r--r--plugin.video.btsportvideo/resources/language/resource.language.en_gb/strings.po4
-rw-r--r--plugin.video.btsportvideo/resources/lib/api.py4
-rw-r--r--plugin.video.btsportvideo/resources/screenshot001.pngbin0 -> 2092760 bytes
-rw-r--r--plugin.video.btsportvideo/resources/screenshot002.pngbin0 -> 1277125 bytes
-rw-r--r--plugin.video.btsportvideo/resources/screenshot003.pngbin0 -> 947806 bytes
7 files changed, 46 insertions, 13 deletions
diff --git a/plugin.video.btsportvideo/addon.py b/plugin.video.btsportvideo/addon.py
index d671ea6..ac0db52 100644
--- a/plugin.video.btsportvideo/addon.py
+++ b/plugin.video.btsportvideo/addon.py
@@ -26,10 +26,11 @@
import traceback
# Workaround for 'Failed to import _strptime because the import lock is held by another thread.'
+from datetime import datetime
+import operator
import _strptime # pylint: disable=unused-import
from kodiswift import Plugin
-import rollbar.kodi
from resources.lib import api
@@ -40,9 +41,9 @@ plugin = Plugin(addon_id='plugin.video.btsportvideo')
def categories():
- yield {'label': '[B]{}[/B]'.format(plugin.get_string(30002)),
+ yield {'label': u'[B]{}[/B]'.format(plugin.get_string(30002)),
'path': plugin.url_for('search')}
- yield {'label': '[B]{}[/B]'.format(plugin.get_string(30001)),
+ yield {'label': u'[B]{}[/B]'.format(plugin.get_string(30001)),
'path': plugin.url_for('show_videos_by_category_first_page', category='all')}
for category in api.categories():
yield {'label': category,
@@ -85,6 +86,16 @@ def show_videos(func, route, page, update_listing, **kwargs):
)
+def previous_search_items():
+ for search_term, _timestamp in sorted(plugin.get_storage('searches').items(),
+ key=operator.itemgetter(1),
+ reverse=True):
+ yield {
+ 'label': search_term,
+ 'path': plugin.url_for('show_search_results_first_page', term=search_term)
+ }
+
+
@plugin.cached_route('/')
def index():
return list(categories())
@@ -98,30 +109,44 @@ def show_videos_by_category(category, page='1', update_listing=True):
update_listing, category=category)
-@plugin.route('/search/<term>', name='show_search_results_first_page',
+@plugin.route('/search/term/<term>', name='show_search_results_first_page',
options={'update_listing': False})
-@plugin.route('/search/<term>/<page>')
+@plugin.route('/search/term/<term>/<page>')
def show_search_results(term, page='1', update_listing=True):
+ plugin.get_storage('searches')[term] = datetime.now()
return show_videos(api.search_results, 'show_search_results', int(page),
update_listing, term=term)
-@plugin.route('/search')
-def search():
+@plugin.route('/search/input')
+def new_search():
term = plugin.keyboard(heading=plugin.get_string(30002))
if term:
url = plugin.url_for('show_search_results_first_page', term=term)
- plugin.redirect(url)
+ plugin.request.url = url
+ return plugin.redirect(url)
+ return plugin.redirect(plugin.url_for('search'))
+
+
+@plugin.route('/search')
+def search():
+ yield {
+ 'label': u'[B]{}[/B]'.format(plugin.get_string(30005)),
+ 'path': plugin.url_for('new_search')
+ }
+ for item in previous_search_items():
+ yield item
if __name__ == '__main__':
+ import rollbar.kodi
try:
plugin.run()
except Exception as exc:
+ plugin.log.error(traceback.format_exc())
if rollbar.kodi.error_report_requested(exc):
rollbar.kodi.report_error(
access_token='cc56a52c62c5418ebc87f97b1aa44669',
version=plugin.addon.getAddonInfo('version'),
url=plugin.request.url
)
- plugin.log.error(traceback.format_exc())
diff --git a/plugin.video.btsportvideo/addon.xml b/plugin.video.btsportvideo/addon.xml
index ecf24d7..7ef46dc 100644
--- a/plugin.video.btsportvideo/addon.xml
+++ b/plugin.video.btsportvideo/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.btsportvideo" name="BT Sport Video" version="0.1.1" provider-name="Leopold">
+<addon id="plugin.video.btsportvideo" name="BT Sport Video" version="0.2.0" provider-name="Leopold">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.kodiswift" version="0.0.8" optional="false"/>
@@ -18,10 +18,14 @@
<website>https://sport.bt.com</website>
<source>https://github.com/LS80/plugin.video.btsportvideo.git</source>
<license>MIT</license>
+ <forum>https://forum.kodi.tv/showthread.php?tid=325188</forum>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
+ <screenshot>resources/screenshot001.png</screenshot>
+ <screenshot>resources/screenshot002.png</screenshot>
+ <screenshot>resources/screenshot003.png</screenshot>
</assets>
- <news></news>
+ <news>Added a search history</news>
</extension>
</addon>
diff --git a/plugin.video.btsportvideo/resources/language/resource.language.en_gb/strings.po b/plugin.video.btsportvideo/resources/language/resource.language.en_gb/strings.po
index 850394c..e7355e7 100644
--- a/plugin.video.btsportvideo/resources/language/resource.language.en_gb/strings.po
+++ b/plugin.video.btsportvideo/resources/language/resource.language.en_gb/strings.po
@@ -31,3 +31,7 @@ msgstr ""
msgctxt "#30004"
msgid "Next Page"
msgstr ""
+
+msgctxt "#30005"
+msgid "New Search"
+msgstr ""
diff --git a/plugin.video.btsportvideo/resources/lib/api.py b/plugin.video.btsportvideo/resources/lib/api.py
index f8c4f5a..22a8e10 100644
--- a/plugin.video.btsportvideo/resources/lib/api.py
+++ b/plugin.video.btsportvideo/resources/lib/api.py
@@ -82,8 +82,8 @@ def _videos(videos_response):
title=video['h1title'],
url=video.get('hlsurl') or video.get('streamingurl'),
thumbnail=video.get('imageurl') or video.get('thumbnailURL'),
- date=_date_from_str(video['publicationdate']),
- duration=int(video['duration'])
+ date=video.get('publicationdate') and _date_from_str(video['publicationdate']),
+ duration=video.get('duration') and int(video['duration'])
)
diff --git a/plugin.video.btsportvideo/resources/screenshot001.png b/plugin.video.btsportvideo/resources/screenshot001.png
new file mode 100644
index 0000000..40d008a
--- /dev/null
+++ b/plugin.video.btsportvideo/resources/screenshot001.png
Binary files differ
diff --git a/plugin.video.btsportvideo/resources/screenshot002.png b/plugin.video.btsportvideo/resources/screenshot002.png
new file mode 100644
index 0000000..f76eddb
--- /dev/null
+++ b/plugin.video.btsportvideo/resources/screenshot002.png
Binary files differ
diff --git a/plugin.video.btsportvideo/resources/screenshot003.png b/plugin.video.btsportvideo/resources/screenshot003.png
new file mode 100644
index 0000000..1acdade
--- /dev/null
+++ b/plugin.video.btsportvideo/resources/screenshot003.png
Binary files differ