diff options
author | LS80 <github@lee-smith.me.uk> | 2017-01-09 07:30:10 +0000 |
---|---|---|
committer | LS80 <github@lee-smith.me.uk> | 2017-01-09 07:32:33 +0000 |
commit | c92a14c7455630ec841e070052baf97647f9d930 (patch) | |
tree | 271e48c5f325f2ec3bef9bb8ccb02ab24824d4f9 /plugin.video.spurs-tv | |
parent | f5e966f91c77dde6516858a6e2f03899b7578f77 (diff) |
[plugin.video.spurs-tv] 2.13.0
Diffstat (limited to 'plugin.video.spurs-tv')
-rw-r--r-- | plugin.video.spurs-tv/addon.py | 58 | ||||
-rw-r--r-- | plugin.video.spurs-tv/addon.xml | 4 | ||||
-rw-r--r-- | plugin.video.spurs-tv/changelog.txt | 5 | ||||
-rw-r--r-- | plugin.video.spurs-tv/icon.png | bin | 8364 -> 26314 bytes | |||
-rw-r--r-- | plugin.video.spurs-tv/resources/language/English/strings.po | 14 | ||||
-rw-r--r-- | plugin.video.spurs-tv/resources/lib/new_stadium.py | 41 |
6 files changed, 92 insertions, 30 deletions
diff --git a/plugin.video.spurs-tv/addon.py b/plugin.video.spurs-tv/addon.py index f520c92..acaa08b 100644 --- a/plugin.video.spurs-tv/addon.py +++ b/plugin.video.spurs-tv/addon.py @@ -21,6 +21,7 @@ import os import re from urlparse import urlparse, urlunparse, urljoin +from urllib import urlencode from datetime import timedelta from functools import partial import xml.etree.ElementTree as ET @@ -36,6 +37,7 @@ import rollbar from resources.lib import utils from resources.lib import youtube +from resources.lib import new_stadium HOST = "http://www.tottenhamhotspur.com" BASE_URL = HOST @@ -234,22 +236,12 @@ def get_search_result_videos(soup, query): form_data['viewstate'] = get_viewstate(soup) -def get_stadium_cams(): - soup = get_soup(urljoin(HOST, "/new-scheme/stadium-tv/")) - js = requests.get(urljoin(HOST, "/components/js/stadium-tv.js")).text - entry_ids = re.findall('"entry_id":\s+"(\w+)"', js) - for entry_id, video in zip(entry_ids, soup('div', 'video-new')): - title = video.find_previous('h2').get_text().strip() - yield title, entry_id - def get_stadium_index(): - for title, entry_id in get_stadium_cams(): - yield {'label': title, - 'path': plugin.url_for('play_video', entry_id=entry_id), - 'is_playable': True} + for title, entry_id in new_stadium.get_cams(): + yield video_item(entry_id, title) yield {'label': plugin.get_string(30019), - 'path': plugin.url_for('show_playlist', playlist_id='0_n8hezta2')} + 'path': plugin.url_for('show_stadium_video_gallery')} def get_categories(path): yield {'label': "[B]{}[/B]".format(plugin.get_string(30010)), @@ -273,12 +265,9 @@ def get_categories(path): plugin_path = plugin.url_for('show_playlist', playlist_id='0_2nmzot3u') elif title == "The Vault": plugin_path = plugin.url_for('show_playlist', playlist_id='0_32nxk7s7') - elif title == "A Question of Spurs": - playable = True - plugin_path = plugin.url_for('play_video', entry_id='0_52u0px90') elif title == "Live Audio Commentary": playable = True - plugin_path = plugin.url_for('play_video', entry_id='0_7nqzdt52') + plugin_path = plugin.url_for('play_live_audio_commentary') elif 'children' in a.parent['class']: plugin_path = plugin.url_for('show_subcategories', path=href) else: @@ -298,6 +287,17 @@ def get_subcategories(path): yield {'label': li.a['title'], 'path': plugin.url_for('show_video_list', path=li.a['href'].strip('/'))} +def live_audio_commentary_id(): + url = urljoin(HOST, "audio-commentary/live/") + RE_EMBED = re.compile(r'kWidget\.embed\((.*?)\)', re.MULTILINE|re.DOTALL) + video_vars = json.loads(RE_EMBED.search(requests.get(url).text).group(1)) + return video_vars['entry_id'] + +def is_live(entry_id): + qs = urlencode(dict(id=entry_id, service='liveStream', action='islive', + protocol='applehttp', partnerId=PARTNER_ID, format=1)) + url = urlunparse((MEDIA_SCHEME, MEDIA_HOST, "/api_v3/index.php", None, qs, None)) + return requests.get(url).text == 'true' def get_youtube_index(): for playlist, stringid in (("latest", 30010), @@ -334,11 +334,6 @@ def get_youtube_video_items(generator): @plugin.route('/') def show_index(): - try: - youtube_icon = Plugin(addon_id="plugin.video.youtube").addon.getAddonInfo('icon') - except: - youtube_icon = None - categories = list(get_categories("spurs-tv")) search = {'label': "[B]{}[/B]".format(plugin.get_string(30011)), @@ -346,9 +341,9 @@ def show_index(): categories.insert(1, search) youtube = {'label': "[B]{}[/B]".format(plugin.get_string(30001)), - 'thumbnail': youtube_icon, + 'thumbnail': "https://www.youtube.com/yt/brand/media/image/YouTube-logo-light.png", 'path': plugin.url_for('show_youtube_index')} - categories.append(youtube) + categories.insert(2, youtube) return categories @@ -364,6 +359,21 @@ def show_subcategories(path): def show_stadium_index(): return list(get_stadium_index()) +@plugin.route('/stadium/video-gallery') +def show_stadium_video_gallery(): + return (video_item(entry_id, title) + for title, entry_id in new_stadium.get_video_gallery()) + +@plugin.route('/live-audio-commentary') +def play_live_audio_commentary(): + entry_id = live_audio_commentary_id() + if is_live(entry_id): + url = get_media_url(entry_id) + else: + xbmcgui.Dialog().ok('Live Audio Commentary', plugin.get_string(30050)) + url = None + return plugin.set_resolved_url(url) + @plugin.route('/videos/path/<path>') def show_video_list(path): url = urljoin(BASE_URL, path) diff --git a/plugin.video.spurs-tv/addon.xml b/plugin.video.spurs-tv/addon.xml index 9261242..5ee0f5e 100644 --- a/plugin.video.spurs-tv/addon.xml +++ b/plugin.video.spurs-tv/addon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<addon id="plugin.video.spurs-tv" name="Spurs TV" version="2.12.1" provider-name="Leopold"> +<addon id="plugin.video.spurs-tv" name="Spurs TV" version="2.13.0" provider-name="Leopold"> <requires> <import addon="xbmc.python" version="2.25.0"/> <import addon="script.module.xbmcswift2" version="2.4.0" optional="false"/> @@ -21,6 +21,6 @@ <forum>http://forum.kodi.tv/showthread.php?tid=235234</forum> <source>https://github.com/LS80/plugin.video.spurs-tv.git</source> <license>GNU GENERAL PUBLIC LICENSE. Version 3, 29 June 2007</license> - <news>Fixed KANE50 category and YouTube channel</news> + <news>Fixed New Stadium category</news> </extension> </addon> diff --git a/plugin.video.spurs-tv/changelog.txt b/plugin.video.spurs-tv/changelog.txt index cedaaa2..e1b7c3c 100644 --- a/plugin.video.spurs-tv/changelog.txt +++ b/plugin.video.spurs-tv/changelog.txt @@ -1,3 +1,8 @@ +v2.13.0 (2017-01-08) + - Fixed New Stadium category after new site launch + - Fixed error when Live Audio Commentary is offline + - Update icon + v2.12.1 (2016-10-03) - Fixed YouTube channel diff --git a/plugin.video.spurs-tv/icon.png b/plugin.video.spurs-tv/icon.png Binary files differindex e85de75..1f37f27 100644 --- a/plugin.video.spurs-tv/icon.png +++ b/plugin.video.spurs-tv/icon.png diff --git a/plugin.video.spurs-tv/resources/language/English/strings.po b/plugin.video.spurs-tv/resources/language/English/strings.po index a4abefc..3a4f157 100644 --- a/plugin.video.spurs-tv/resources/language/English/strings.po +++ b/plugin.video.spurs-tv/resources/language/English/strings.po @@ -4,10 +4,10 @@ # Addon Provider: Leopold msgid "" msgstr "" -"Project-Id-Version: XBMC Addons\n" +"Project-Id-Version: Kodi Addons\n" "POT-Creation-Date: 2016-08-01 05:35+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Language-Team: teamxbmc\n" +"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -61,7 +61,14 @@ msgstr "" #. List item to show videos from a particular category such as "Stadium TV" msgctxt "#30019" -msgid "Video Library" +msgid "Video Gallery" +msgstr "" + +#. Message dialog for off line audio commentary +msgctxt "#30050" +msgid "" +"There is no live audio commentary available at this time. " +"Please try again 5 minutes before kick-off." msgstr "" #. Settings category for advanced options @@ -116,4 +123,3 @@ msgid "Send error report?" #. Notification message that an error report was sent msgctxt "#30134" msgid "Error report sent" - diff --git a/plugin.video.spurs-tv/resources/lib/new_stadium.py b/plugin.video.spurs-tv/resources/lib/new_stadium.py new file mode 100644 index 0000000..32b4ded --- /dev/null +++ b/plugin.video.spurs-tv/resources/lib/new_stadium.py @@ -0,0 +1,41 @@ +''' + This module contains functions for scraping video links from + http://new-stadium.tottenhamhotspur.com +''' + +from urlparse import urljoin +import json +import re +from collections import namedtuple + +from bs4 import BeautifulSoup as BS +import requests + +URL_ROOT = "http://new-stadium.tottenhamhotspur.com/" + +RE_EMBED = re.compile(r'kWidget\.embed\((.*)\)') + +Video = namedtuple('Video', ['title', 'entry_id']) + + +def get_soup(path): + '''Return a BeautifulSoup tree for the provided new stadium path''' + response = requests.get(urljoin(URL_ROOT, path)) + return BS(response.text, 'html.parser') + + +def get_cams(): + '''Generator for live stadium cameras''' + soup = get_soup("interact") + div = soup.find('div', {'data-player-id': 'player2'}) + for tab in json.loads(div['data-tabs']): + yield Video(title=tab['title'], entry_id=tab['entryId']) + + +def get_video_gallery(): + '''Generator for the new stadium video gallery videos''' + soup = get_soup("video-gallery") + for video in soup('div', 'video-new'): + video_vars = json.loads(RE_EMBED.search(video.find(text=RE_EMBED)).group(1)) + yield Video(title=video.find_next_sibling('p').get_text().strip(), + entry_id=video_vars['entry_id']) |