Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
glennguy committed Sep 19, 2018
1 parent bdd05d0 commit 3b4c2f1
Show file tree
Hide file tree
Showing 20 changed files with 1,624 additions and 23 deletions.
26 changes: 3 additions & 23 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# =========================
# Operating System Files
# =========================
*.pyc
*.pyo
*.zip
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: python
env:
global:
- secure: C0Tqtj3OeCT25kIRhSw57eMMjaNn5vFbTqmpj6pvHlObDLqjliv8nbQXQvIZc5jxFhyiGfj+Ym0YNO3NnOk7yiOvHtpqyj0Q3tkev0GdECU7jszJg3FzYqTQ5PmJF1o++ecO9hDRgK2vtvg4lwFtovEj7BHr9Q+/Wph9KoymSTzT2Ufsg+8wQ3mqfC43FdEuiyZxAjbI/jVugs3jafC/7UmV9WlCMqJLebhB+lRLRTqesDOccO1aOwIO7nmWuqWnMX18se9J93aALMAp5rXH7r6LM5h6T/T6FyaZSacIwO+Mx/xYkB8n+b7rSc3eyGcks4wncuGYxBIjVNtLsmlTpr1E9YacQuzCPq4D2ktzEcBlBLJWpabruhetW1w4+tYI9MK8XTJhq1KWKukBjxJlELFReZWUvasQ4YrKox5mIgmCJ/1yiwLH2DkqX06W+Jqq2OHhNaFXcwwoEvMmoFgUtYyq2TOm1XmmV508sUd35gatmMTiT8eoD9zIusSx8NOCVUE91Zrt4j8kAcHipsHpcp1PbUV1jKPXEIeiYsALVd2rJqR1LJLAF6urdf1MVc40nVklBDYz7TjRNW/jesifVWvSeYYrI/LKUa3h86gay0n6ibsEBdoiDAtYhFh4sFSsF41dFbfMSd/tLG+vcf6L6go6yM5v9wGGYvZNaNXHv34=
install:
- pip install GitPython
- export TRAVIS_COMMIT_MSG="$TRAVIS_REPO_SLUG - $(git log --format=%B --no-merges -n 1)"
script:
- test "$TRAVIS_PULL_REQUEST" = "false" || travis_terminate 0
- test "$TRAVIS_BRANCH" = "$TRAVIS_TAG" -o "$TRAVIS_BRANCH" = "master" || travis_terminate 0
- git config --global user.email '[email protected]'
- git config --global user.name 'Aussie Add-ons Bot'
- >
git clone https://github.com/xbmc-catchuptv-au/repo-devel.git $TRAVIS_BUILD_DIR/.deploy-devel &&
cd $TRAVIS_BUILD_DIR/.deploy-devel &&
./manage_repo.py $TRAVIS_BUILD_DIR || travis_terminate 1
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GH_TOKEN}:@github.com" > .git/credentials
- >
git add . &&
git commit --allow-empty -m "$TRAVIS_COMMIT_MSG" &&
git push || travis_terminate 1
- if [ -z "$TRAVIS_TAG" ]; then travis_terminate 0; fi
- >
git clone https://github.com/xbmc-catchuptv-au/repo.git $TRAVIS_BUILD_DIR/.deploy-prod &&
cd $TRAVIS_BUILD_DIR/.deploy-prod &&
./manage_repo.py $TRAVIS_BUILD_DIR || travis_terminate 1
- git config credential.helper "store --file=.git/credentials"
- echo "https://${GH_TOKEN}:@github.com" > .git/credentials
- >
git add . &&
git commit --allow-empty -m "Update $(basename `git -C $TRAVIS_BUILD_DIR rev-parse --show-toplevel`) to $TRAVIS_TAG" &&
git push || travis_terminate 1
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Soccer Live addon for Kodi

## This add-on supports the free Live Pass offer for eligible Telstra customers. In-app subscriptions through the App Store/Google Play are NOT supported.

##Requirements

Kodi v17 is the minimum recommended version. If you are having SSL errors, upgrading Kodi should solve them. On some platforms earlier versions will work fine.

You will need a Telstra ID account with an eligible service attached to use this add-on. Most Telstra Mobile customers are eligible for a free subscription with their plan. Please see their [website](https://www.telstra.com.au/tv-movies-music/sports-offer) for details.

##How to install

Soccer Live is available from the Catch Up TV AU repository located [here](https://github.com/aussieaddons/repo). Head on over and follow the instructions to install the repo, then install the add-on.

##Settings

You will need to enter your Telstra ID username and password to view videos.

The live streaming bitrates reflect an average bitrate only, you should ideally have twice the bandwidth available to ensure buffer free viewing.

##Issues

Please let us know of any errors by opening an [issue](https://github.com/aussieaddons/plugin.video.soccer-live/issues) ticket. It would be great if you could attach a Kodi debug log file as well. Follow this [guide](http://kodi.wiki/view/Log_file/Easy).
18 changes: 18 additions & 0 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" ?><addon id="plugin.video.soccer-live" name="Soccer Live" provider-name="Aussie Add-ons" version="0.0.0">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.aussieaddonscommon"/>
<import addon="script.module.beautifulsoup4"/>
<import addon="script.module.requests"/>
<import addon="script.common.plugin.cache"/>
</requires>
<extension library="default.py" point="xbmc.python.pluginsource" provides="video">
<provides>video</provides>
</extension>
<extension library="default.py" point="xbmc.addon.metadata">
<summary>Soccer Live add-on</summary>
<description>Soccer Live is an unofficial add-on for Australian soccer content</description>
<provides>video</provides>
<platform>all</platform>
</extension>
</addon>
56 changes: 56 additions & 0 deletions default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import os
import sys
import xbmc
import xbmcgui
import xbmcaddon
from urlparse import parse_qsl

addon = xbmcaddon.Addon()
cwd = xbmc.translatePath(addon.getAddonInfo('path')).decode("utf-8")
BASE_RESOURCE_PATH = os.path.join(cwd, 'resources', 'lib')
sys.path.append(BASE_RESOURCE_PATH)

import play # noqa: E402
import menus # noqa: E402
import ooyalahelper # noqa: E402
import categories # noqa: E402

_url = sys.argv[0]
_handle = int(sys.argv[1])
addonname = addon.getAddonInfo('name')
addonPath = xbmcaddon.Addon().getAddonInfo("path")
fanart = os.path.join(addonPath, 'fanart.jpg')


def router(paramstring):
"""
Router function that calls other functions
depending on the provided paramstring
:param paramstring:
"""
params = dict(parse_qsl(paramstring))
if params:
if params['action'] == 'listcategories':
if params['category'] == 'Live Matches':
menus.make_live_list(params)
elif params['category'] == 'Videos':
menus.make_video_list(params)
elif params['category'] == 'Settings':
addon.openSettings()
elif params['action'] == 'listvideos':
play.play_video(params)
elif params['action'] == 'cleartoken':
ooyalahelper.clear_token()
else:
categories.list_categories()


if __name__ == '__main__':
if addon.getSetting('firstrun') == 'true':
xbmcgui.Dialog().ok(addonname, ('Please enter your My Football Live '
'Pass (Telstra ID) username and '
'password to access the content '
'in this service.'))
addon.openSettings()
addon.setSetting('firstrun', 'false')
router(sys.argv[2][1:])
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions resources/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
14 changes: 14 additions & 0 deletions resources/language/English/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
<string id="32000">Telstra Live Pass</string>
<string id="32001">Streaming Settings</string>
<string id="32002">Debugging</string>
<string id="32010">Settings</string>

<string id="32031">firstrun</string>
<string id="32032">Remove stored login ticket</string>
<string id="32043">Live Match Stream Quality</string>
<string id="32044">Replay Stream Quality</string>
<string id="32020">Telstra ID Username</string>
<string id="32030">Telstra ID Password</string>
</strings>
1 change: 1 addition & 0 deletions resources/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Dummy file to make this directory a package.
25 changes: 25 additions & 0 deletions resources/lib/categories.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import xbmcgui
import xbmcplugin
import config
import sys
from aussieaddonscommon import utils

_handle = int(sys.argv[1])
_url = sys.argv[0]


def list_categories():
try:
listing = []
categories = config.CATEGORIES
for category in categories:
li = xbmcgui.ListItem(category)
urlString = '{0}?action=listcategories&category={1}'
url = urlString.format(_url, category)
is_folder = True
listing.append((url, li, is_folder))

xbmcplugin.addDirectoryItems(_handle, listing, len(listing))
xbmcplugin.endOfDirectory(_handle)
except Exception:
utils.handle_error('Unable to display categories')
76 changes: 76 additions & 0 deletions resources/lib/classes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import datetime
import time
import urlparse
import unicodedata
import urllib


class Video():
def __init__(self):
self.video_id = None
self.thumb = None
self.title = None
self.live = None
self.time = None
self.desc = None
self.dummy = None
self.account_id = None
self.url = None
self.home = None
self.away = None
self.ooyala_id = None
self.start_date = None

def make_kodi_url(self):
d = self.__dict__
for key, value in d.iteritems():
if isinstance(value, unicode):
d[key] = unicodedata.normalize('NFKD', value).encode('ascii',
'ignore')
url = ''
if d['thumb']:
d['thumb'] = urllib.quote_plus(d['thumb'])
for item in d.keys():
url += '&{0}={1}'.format(item, d[item])
return url

def parse_kodi_url(self, url):
params = urlparse.parse_qsl(url)
for item in params.keys():
setattr(self, item, urllib.unquote_plus(params[item]))

def parse_params(self, params):
for item in params.keys():
setattr(self, item, urllib.unquote_plus(params[item]))

def get_live_title(self):
if self.home and self.away:
return '[COLOR green][LIVE NOW][/COLOR] {0} v {1}'.format(
self.home, self.away)

def get_airtime(self):
try:
delta = ((time.mktime(time.localtime()) -
time.mktime(time.gmtime())) / 3600)
if time.localtime().tm_isdst:
delta += 1
ts_format = "%Y-%m-%dT%H:%M:%S+00:00"
ts = datetime.datetime.fromtimestamp(
time.mktime(time.strptime(self.start_date, ts_format)))
ts += datetime.timedelta(hours=delta)
return ts.strftime("%A %d %b @ %I:%M %p").replace(' 0', ' ')
except OverflowError:
return timestamp

def make_time_string(self):
try:
timestamp = time.mktime(time.strptime(self.start_date,
'%Y-%m-%dT%H:%M:%S+00:00'))
video.date = datetime.date.fromtimestamp(timestamp)
except Exception:
pass

def get_upcoming_title(self):
if self.home and self.away:
return '[COLOR red][Upcoming][/COLOR] {0} v {1} - {2}'.format(
self.home, self.away, self.get_airtime())
75 changes: 75 additions & 0 deletions resources/lib/comm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import classes
import config
import json

from aussieaddonscommon import utils
from aussieaddonscommon import session


def fetch_url(url, headers=None):
"""
HTTP GET on url, remove byte order mark
"""
with session.Session() as sess:
if headers:
sess.headers = headers
resp = sess.get(url)
return resp.text.encode("utf-8")


def list_videos(params):
data = json.loads(fetch_url(config.VIDEOS_URL))
listing = []
for video in data:
v = classes.Video()
v.title = video.get('name')
v.desc = video.get('name')
v.thumb = video.get('poster_small').get('url')
v.fanart = video.get('poster').get('url')
v.video_id = video.get('video_id')
v.account_id = video.get('account_id')
listing.append(v)
return listing


def list_live(params):
data = json.loads(fetch_url(config.HOME_URL))
listing = []
for match in data.get('upcoming_matches'):
match_data = match.get('match')
if not match:
continue
if match_data.get('status') == 'FullTime':
continue
broadcasters = match_data.get('broadcasters')
if not broadcasters:
continue
v = classes.Video()
v.home = match_data.get('home_team').get('name')
v.away = match_data.get('away_team').get('name')
if match_data.get('status') == 'Live':
v.live = True
v.title = v.get_live_title()
for broadcast in broadcasters:
if 'Telstra' in broadcast.get('name'):
v.ooyala_id = broadcast.get('stream_name')
#v.thumb = broadcast.get('logo')
break
else:
v.dummy = True
v.start_date = match_data.get('start_date')
v.title = v.get_upcoming_title()
listing.append(v)
return listing


def get_stream_url(account_id, video_id):
policy = config.BC_POLICYS[account_id]
bc_url = config.BC_URL.format(account_id, video_id)
data = json.loads(fetch_url(bc_url, {'BCOV-POLICY': policy}))
for source in data.get('sources'):
ext_ver = source.get('ext_x_version')
src = source.get('src')
if ext_ver == '4' and src:
if src.startswith('https'):
return src
Loading

0 comments on commit 3b4c2f1

Please sign in to comment.