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

[plugin.video.vrt.nu@krypton] 2.5.27 #4439

Merged
merged 1 commit into from
Jan 3, 2024
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
3 changes: 3 additions & 0 deletions plugin.video.vrt.nu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ leave a message at [our Facebook page](https://facebook.com/kodivrtnu/).
</table>

## Releases
### v2.5.27 (2023-12-27)
- Fix categories listing (@mediaminister)

### v2.5.26 (2023-09-22)
- Fix program listings (@mediaminister)
- Add extra content to program listings (@mediaminister)
Expand Down
5 changes: 4 additions & 1 deletion plugin.video.vrt.nu/addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.vrt.nu" name="VRT MAX" version="2.5.26" provider-name="Martijn Moreel, dagwieers, mediaminister">
<addon id="plugin.video.vrt.nu" name="VRT MAX" version="2.5.27" provider-name="Martijn Moreel, dagwieers, mediaminister">
<requires>
<import addon="resource.images.studios.white" version="0.0.22"/>
<import addon="script.module.beautifulsoup4" version="4.6.2"/>
Expand Down Expand Up @@ -42,6 +42,9 @@
<website>https://github.com/add-ons/plugin.video.vrt.nu/wiki</website>
<source>https://github.com/add-ons/plugin.video.vrt.nu</source>
<news>
v2.5.27 (2023-12-27)
- Fix categories listing

v2.5.26 (2023-09-22)
- Fix program listings
- Add extra content to program listings
Expand Down
4 changes: 2 additions & 2 deletions plugin.video.vrt.nu/resources/lib/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,8 @@ def get_online_categories():
data = dumps(payload).encode('utf-8')
categories_json = get_url_json(url=GRAPHQL_URL, cache=None, headers=headers, data=data, raise_errors='all')
if categories_json is not None:
content_types = find_entry(categories_json.get('data').get('uiSearch'), 'title', 'Aanbod').get('items')
genres = find_entry(categories_json.get('data').get('uiSearch'), 'title', 'Genres').get('items')
content_types = find_entry(categories_json.get('data').get('uiSearch'), 'listId', 'initialsearchcontenttypes').get('items')
genres = find_entry(categories_json.get('data').get('uiSearch'), 'listId', 'initialsearchgenres').get('items')
category_items = content_types + genres
for category in category_items:
# Don't add audio-only categories
Expand Down
5 changes: 3 additions & 2 deletions plugin.video.vrt.nu/resources/lib/helperobjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ def __init__(self, client, media_api_url, video_id, publication_id, is_live_stre
class StreamURLS:
"""This helper object holds all information to be used when playing streams"""

def __init__(self, stream_url, subtitle_url=None, license_key=None, use_inputstream_adaptive=False):
def __init__(self, stream_url, subtitle_url=None, license_url=None, license_headers=None, use_inputstream_adaptive=False):
"""The constructor for the StreamURLS class"""
self.stream_url = stream_url
self.subtitle_url = subtitle_url
self.license_key = license_key
self.license_url = license_url
self.license_headers = license_headers
self.use_inputstream_adaptive = use_inputstream_adaptive
self.video_id = None

Expand Down
24 changes: 21 additions & 3 deletions plugin.video.vrt.nu/resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@
from utils import from_unicode, to_unicode

try: # Python 3
from urllib.parse import quote, urlencode
from urllib.request import HTTPErrorProcessor
except ImportError: # Python 2
from urllib2 import HTTPErrorProcessor
from urllib import urlencode
from urllib2 import quote, HTTPErrorProcessor

ADDON = Addon()
DEFAULT_CACHE_DIR = 'cache'
Expand Down Expand Up @@ -309,12 +311,13 @@ def play(stream, video=None):
play_item.setProperty('inputstream.adaptive.manifest_type', 'hls')
play_item.setMimeType('application/vnd.apple.mpegurl')

if stream.license_key is not None:
if stream.license_url is not None:
import inputstreamhelper
is_helper = inputstreamhelper.Helper('mpd', drm='com.widevine.alpha')
if is_helper.check_inputstream():
play_item.setProperty('inputstream.adaptive.license_type', 'com.widevine.alpha')
play_item.setProperty('inputstream.adaptive.license_key', stream.license_key)
license_key = generate_ia_license_key(stream.license_url, license_headers=stream.license_headers)
play_item.setProperty('inputstream.adaptive.license_key', license_key)

subtitles_visible = get_setting_bool('showsubtitles', default=True)
# Separate subtitle url for hls-streams
Expand All @@ -339,6 +342,21 @@ def get_search_string(search_string=None):
return search_string


def generate_ia_license_key(license_url, license_headers='', postdata_type='R', postdata_value='', response_type=''):
"""Generates an InputStream Adaptive license_key"""
if license_headers:
license_headers = urlencode(license_headers)

if postdata_type in ('A', 'R', 'B'):
postdata_value = postdata_type + '{SSM}'
elif postdata_type == 'D':
if 'D{SSM}' not in postdata_value:
raise ValueError('Missing D{SSM} placeholder')
postdata_value = quote(postdata_value)

return '{}|{}|{}|{}'.format(license_url, license_headers, postdata_value, response_type)


def ok_dialog(heading='', message=''):
"""Show Kodi's OK dialog"""
from xbmcgui import Dialog
Expand Down
63 changes: 13 additions & 50 deletions plugin.video.vrt.nu/resources/lib/streamservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

try: # Python 3
from urllib.error import HTTPError
from urllib.parse import quote, urlencode
from urllib.parse import quote
except ImportError: # Python 2
from urllib import urlencode
from urllib2 import quote, HTTPError

from helperobjects import ApiData, StreamURLS
Expand Down Expand Up @@ -56,46 +55,6 @@ def _create_settings_dir():
if not exists(settingsdir):
mkdir(settingsdir)

@staticmethod
def _get_license_key(key_url, key_type='R', key_headers=None, key_value=None):
"""Generates a proper Widevine license key value

# A{SSM} -> not implemented
# R{SSM} -> raw format
# B{SSM} -> base64 format
# D{SSM} -> decimal format

The generic format for a LicenseKey is:
|<url>|<headers>|<key with placeholders|

The Widevine Decryption Key Identifier (KID) can be inserted via the placeholder {KID}

@type key_url: str
@param key_url: the URL where the license key can be obtained

@type key_type: str
@param key_type: the key type (A, R, B or D)

@type key_headers: dict
@param key_headers: A dictionary that contains the HTTP headers to pass

@type key_value: str
@param key_value: i
@return:
"""
header = ''
if key_headers:
header = urlencode(key_headers)

if key_type in ('A', 'R', 'B'):
key_value = key_type + '{SSM}'
elif key_type == 'D':
if 'D{SSM}' not in key_value:
raise ValueError('Missing D{SSM} placeholder')
key_value = quote(key_value)

return '{key_url}|{header}|{key_value}|'.format(key_url=key_url, header=header, key_value=key_value)

def _get_api_data(self, video):
"""Create api data object from video dictionary"""
api_data = None
Expand Down Expand Up @@ -261,15 +220,19 @@ def get_stream(self, video, roaming=False, api_data=None):
if protocol == 'mpeg_dash' and drm_stream:
log(2, 'Protocol: mpeg_dash drm')
if vudrm_token:
encryption_json = '{{"token":"{0}","drm_info":[D{{SSM}}],"kid":"{{KID}}"}}'.format(vudrm_token)
license_key = self._get_license_key(key_url=vualto_license_url,
key_type='D',
key_value=encryption_json,
key_headers={'Content-Type': 'text/plain;charset=UTF-8'})
stream = StreamURLS(
manifest_url,
license_url=vualto_license_url,
license_headers={'X-VUDRM-TOKEN': vudrm_token},
use_inputstream_adaptive=True
)
else:
license_key = self._get_license_key(key_url=self._UPLYNK_LICENSE_URL, key_type='R')

stream = StreamURLS(manifest_url, license_key=license_key, use_inputstream_adaptive=True)
stream = StreamURLS(
manifest_url,
license_url=self._UPLYNK_LICENSE_URL,
license_headers={},
use_inputstream_adaptive=True
)
elif protocol == 'mpeg_dash':
log(2, 'Protocol: mpeg_dash')
stream = StreamURLS(manifest_url, use_inputstream_adaptive=True)
Expand Down
Loading