Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor and enrich media streaming protocols #12

Merged
merged 4 commits into from
Dec 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ msgid "Password"
msgstr ""

msgctxt "#50004"
msgid "Show scores"
msgid "Show records and scores"
msgstr ""

msgctxt "#50005"
Expand Down
2 changes: 1 addition & 1 deletion resources/language/Hebrew/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ msgid "Password"
msgstr "סיסמה"

msgctxt "#50004"
msgid "Show scores"
msgid "Show records and scores"
msgstr "הצג ניקוד"

msgctxt "#50005"
Expand Down
2 changes: 1 addition & 1 deletion resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<setting id="email" type="text" label="50001" default="" />
<setting id="password" type="text" label="50002" option="hidden" default="" />
<setting type="sep" />
<setting id="scores" type="bool" label="50004" default="false" />
<setting id="records_and_scores" type="bool" label="50004" default="false" />
<setting id="local_timezone" type="bool" label="50007" default="true" />
<setting id="fav_team" type="select" label="50009" values="None|Hawks|Celtics|Nets|Hornets|Bulls|Cavaliers|Mavericks|Nuggets|Pistons|Warriors|Rockets|Pacers|Clippers|Lakers|Grizzlies|Heat|Bucks|Timberwolves|Pelicans|Knicks|Thunder|Magic|76ers|Suns|Trail Blazers|Kings|Spurs|Raptors|Jazz|Wizards" default="None" />
<setting type="sep" />
Expand Down
32 changes: 17 additions & 15 deletions src/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,37 @@
import xbmc
import xbmcaddon
import xbmcgui
import re
from xml.dom.minidom import parseString

import vars
from utils import *


PROTOCOL = 'mpd' # TODO Handle other INPUTSTREAM_PROTOCOLS
PROTOCOLS = {
'mpd': {'extensions': ['mpd'], 'mimetype': 'application/dash+xml'},
'hls': {'extensions': ['m3u8', 'm3u'], 'mimetype': 'application/vnd.apple.mpegurl'},
}
DRM = 'com.widevine.alpha' # TODO Handle other DRM_SCHEMES
MIME_TYPE = 'application/dash+xml'
LICENSE_URL = 'https://shield-twoproxy.imggaming.com/proxy'


def play(video):
item = None
if 'url' in video:
item = xbmcgui.ListItem(path=video['url'])
if '.%s' % PROTOCOL in video['url']:
from inputstreamhelper import Helper
is_helper = Helper(PROTOCOL, drm=DRM)
if is_helper.check_inputstream():
item.setMimeType(MIME_TYPE)
item.setContentLookup(False)
item.setProperty('inputstreamaddon', is_helper.inputstream_addon) # TODO Kodi version dep
item.setProperty('inputstream.adaptive.manifest_type', PROTOCOL)
item.setProperty('inputstream.adaptive.license_type', DRM)
item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full')
license_key = '%s|authorization=bearer %s|R{SSM}|' % (LICENSE_URL, video['drm'])
item.setProperty('inputstream.adaptive.license_key', license_key)
for protocol, protocol_info in PROTOCOLS.items():
if any(".%s" % extension in video['url'] for extension in protocol_info['extensions']):
from inputstreamhelper import Helper
is_helper = Helper(protocol, drm=DRM)
if is_helper.check_inputstream():
item.setMimeType(protocol_info['mimetype'])
item.setContentLookup(False)
item.setProperty('inputstreamaddon', is_helper.inputstream_addon) # TODO Kodi version dep
item.setProperty('inputstream.adaptive.manifest_type', protocol)
item.setProperty('inputstream.adaptive.license_type', DRM)
item.setProperty('inputstream.adaptive.manifest_update_parameter', 'full')
license_key = '%s|authorization=bearer %s|R{SSM}|' % (LICENSE_URL, video['drm'])
item.setProperty('inputstream.adaptive.license_key', license_key)

if item is not None:
xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=True, listitem=item)
Expand Down
2 changes: 1 addition & 1 deletion src/favteam.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def addFavTeamGameLinks(fromDate, favTeamAbbrs, video_type='archive'):

# Add the teams' names and the scores if needed
name += ' %s vs %s' % (visitor_name, host_name)
if vars.show_scores and not future_video:
if vars.show_records_and_scores and not future_video:
name += ' %s:%s' % (str(vs), str(hs))

thumbnail_url = generateCombinedThumbnail(v, h)
Expand Down
12 changes: 5 additions & 7 deletions src/games.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,14 @@ def addGamesLinks(date='', video_type="archive"):
if video_type == "live":
name = utils.toLocalTimezone(game_start_datetime_est).strftime("%Y-%m-%d (at %I:%M %p)")

name += " %s" % visitor_name
if vars.show_scores:
name += " (%s)" % vr
name += " vs. %s" % host_name
if vars.show_scores:
name += " (%s)" % hr
name += " %s%s vs %s%s" % (visitor_name,
" (%s)" % vr if vars.show_records_and_scores else '',
host_name,
" (%s)" % hr if vars.show_records_and_scores else '')

if playoff_game_number != 0:
name += ' (game %d)' % (playoff_game_number)
if vars.show_scores and not future_video:
if vars.show_records_and_scores and not future_video:
name += ' %s:%s' % (vs, hs)

if playoff_status:
Expand Down
2 changes: 1 addition & 1 deletion src/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

# Global variables
settings = xbmcaddon.Addon(id=__addon_id__)
show_scores = json.loads(settings.getSetting(id="scores"))
show_records_and_scores = json.loads(settings.getSetting(id="records_and_scores"))
debug = json.loads(settings.getSetting(id="debug"))
use_cached_thumbnails = json.loads(settings.getSetting(id="cached_thumbnails"))
use_local_timezone = json.loads(settings.getSetting(id="local_timezone"))
Expand Down