Skip to content

Commit

Permalink
v2.4.3_v3
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz89B committed Mar 5, 2023
1 parent 2ae76b1 commit b795c16
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 16 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.viaplay" version="2.4.3-beta.2" name="Viaplay" provider-name="mariusz89b, emilsvennesson, heppen-dev">
<addon id="plugin.video.viaplay" version="2.4.3-beta.3" name="Viaplay" provider-name="mariusz89b, emilsvennesson, heppen-dev">
<requires>
<import addon="script.module.requests" version="2.9.1" />
<import addon="script.module.iso8601" version="0.1.11" />
Expand All @@ -24,7 +24,7 @@
<platform>all</platform>
<license>GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 and MIT LICENSE.</license>
<source>https://github.com/Mariusz89B/plugin.video.viaplay</source>
<news>v2.4.3 (2023-02-26)
<news>v2.4.3 (2023-03-05)
- Added profile selector.
- Added supported countries.

Expand Down
2 changes: 1 addition & 1 deletion changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v2.4.3 (2023-02-26)
v2.4.3 (2023-03-05)
- Added profile selector.
- Added supported countries.

Expand Down
14 changes: 6 additions & 8 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def watched(guid, program=False):
'guid': guid,
}

response = helper.vp.make_request(url='https://play.viaplay.{0}/api/stream/byguid'.format(helper.vp.country), method='get', params=params)
response = helper.vp.make_request(url=helper.vp.play_api + '/api/stream/byguid', method='get', params=params)

params = {
'profileId': response['socket']['userId'],
Expand All @@ -238,7 +238,7 @@ def watched(guid, program=False):
helper.dialog(dialog_type='notification', heading=helper.language(30017), message=message)
return

url = 'https://content.viaplay.{0}/pcdash-{0}/deleteAllProgress/default/{1}/{2}'.format(helper.vp.country, program_guid, helper.vp.get_user_id()['id'])
url = helper.vp.base_url + '/deleteAllProgress/default/{0}/{1}'.format(program_guid, helper.vp.get_user_id()['id'])

params = {
'profileId': helper.vp.get_setting('profileid'),
Expand Down Expand Up @@ -305,7 +305,7 @@ def favourite(guid, program=False, remove=False):
'guid': guid,
}

response = helper.vp.make_request(url='https://play.viaplay.{0}/api/stream/byguid'.format(helper.vp.country), method='get', params=params)
response = helper.vp.make_request(url=helper.vp.play_api + '/stream/byguid', method='get', params=params)

params = {
'profileId': response['socket']['userId'],
Expand All @@ -327,7 +327,7 @@ def favourite(guid, program=False, remove=False):
'action': 'remove',
}

response = helper.vp.make_request(url='https://content.viaplay.{0}/pcdash-{0}/myList'.format(helper.vp.country), method='put', params=params, payload=json_data, status=True)
response = helper.vp.make_request(url=helper.vp.base_url + '/myList', method='put', params=params, payload=json_data, status=True)

xbmc.executebuiltin('Container.Refresh')

Expand All @@ -340,7 +340,7 @@ def favourite(guid, program=False, remove=False):
'action': 'add',
}

response = helper.vp.make_request(url='https://content.viaplay.{0}/pcdash-{0}/myList'.format(helper.vp.country), method='put', params=params, payload=json_data, status=True)
response = helper.vp.make_request(url=helper.vp.base_url + '/myList', method='put', params=params, payload=json_data, status=True)

message = helper.language(30071)
helper.dialog(dialog_type='notification', heading=helper.language(30017), message=message)
Expand All @@ -361,8 +361,6 @@ def generate_m3u():

data = '#EXTM3U\n'

country_code = helper.get_country_code()
tld = helper.get_tld()
country_id = helper.get_setting('site')
if country_id == '0':
chann = 'kanaler'
Expand All @@ -375,7 +373,7 @@ def generate_m3u():
elif country_id == '4':
chann = 'channels'

url = 'https://content.viaplay.{c1}/xdk-{c2}/{chann}'.format(c1=tld, c2=country_code, chann=chann)
url = helper.vp.base_url + '/{0}'.format(chann)

response = helper.vp.make_request(url=url, method='get')
channels_block = response['_embedded']['viaplay:blocks'][0]['_embedded']['viaplay:blocks']
Expand Down
207 changes: 202 additions & 5 deletions resources/lib/viaplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ def __init__(self, settings_folder, country, debug=False):
os.makedirs(self.tempdir)
self.deviceid_file = os.path.join(settings_folder, 'deviceId')
self.http_session = requests.Session()
self.device_key = 'xdk-%s' % self.country
self.device_key = 'xdk-{0}'.format(self.country)
self.profile_url = 'https://viaplay.mtg-api.com'
self.base_url = 'https://content.viaplay.{0}/{1}'.format(self.tld, self.device_key)
self.login_api = 'https://login.viaplay.%s/api' % self.tld
self.cronos_url = 'https://cronos-events.viaplay.{0}'.format(self.tld)
self.socket_url = 'https://socket.viaplay.{0}'.format(self.tld)
self.play_api = 'https://play.viaplay.{0}/api'.format(self.tld)
self.login_api = 'https://login.viaplay.{0}/api'.format(self.tld)

try:
self.cookie_jar.load(ignore_discard=True, ignore_expires=True)
Expand Down Expand Up @@ -152,13 +155,13 @@ def parse_url(self, url):

return url

def make_request(self, url, method, params=None, payload=None, headers=None, status=False):
def make_request(self, url, method, params=None, payload=None, headers=None, profile=True, status=False):
"""Make an HTTP request. Return the response."""
if not params:
params = {}

id = self.get_setting('profileid')
if id:
if id and profile:
params['profileId'] = id

try:
Expand Down Expand Up @@ -341,7 +344,7 @@ def get_stream(self, guid, pincode=None, tve='false', url=''):
'deviceName': 'web',
'deviceType': 'pc',
'userAgent': 'Kodi',
'deviceKey': 'chromecast-{cc}'.format(cc=self.country),
'deviceKey': 'chromecast-{0}'.format(country_code),
#'guid': guid
'mediaGuid': guid
}
Expand All @@ -353,6 +356,200 @@ def get_stream(self, guid, pincode=None, tve='false', url=''):

data = self.make_request(url=url, method='get', params=params)

print('TEST0')
print(data)

title = data['product']['content']['title']

session_guid = data['cseReporting']['sessionGuid']

house_id = data['product']['system']['guid']
corr_id = data['cseReporting']['data']['correlationId']

url = self.cronos_url + '/cronos-events/session/viaplay/xdk/5.54.1'

response = self.make_request(url=url, method='get', status=True)

session = response['data']['sessionId']

url = self.cronos_url + '/cronos-events/event/viaplay/{0}/5.54.1/11/view_displayed_content'.format(self.device_key)

params = {
'sessionId': session,
}

"""
payload = {
'contentDataArray': [
{
'availability': 'available',
'context': 'view',
'creatives': [
'no-background-type',
'no-background',
'page',
'x-large'
],
'houseId': house_id,
'position': 2,
'price': 0,
'title': title,
'types': [
'SVOD'
]
}
],
'deviceData': {
'architecture': 'ranchu',
'category': 'Mobile',
'country': country_code.upper(),
'key': self.device_key,
'manufacturer': 'google',
'name': 'sdk_gphone_x86',
'os': 'Android',
'osVersion': '11',
'package': 'com.viaplay.android',
'year': '2020'
},
'environmentData': {
'currency': 'EUR',
'environment': 'production',
'language': 'en',
'market': country_code.upper(),
'name': 'com.viaplay.android',
'touchPoint': 'android',
'variant': 'default',
'version': '5.54.1'
},
'experimentDataArray': [
'gradual_rollouts.client_side_logging',
'kids',
'start_page'
],
'pageData': {
'title': 'Player',
'type': 'player'
},
'profileData': {
'id': self.get_setting('profileid'),
'type': 'adult'
},
'sectionData': {
'id': 'player',
'name': 'player'
},
'stateData': {
'locale': 'en_US',
'resolution': '411x659'
},
'streamData': {
'offline': False,
'progress': 0,
'sessionGuid': session_guid,
'startMethod': 'manual',
'state': 'default'
},
'userData': {
'loggedIn': True,
'userId': self.get_user_id()['id']
},
'viewData': {
'title': 'Player',
'type': 'player',
'virtual': True
}
}
"""

payload = {
'contentDataArray':[
{
'availability':'available',
'context':'view',
'creatives':[
'promo',
'dynamic-background',
'page',
'x-large'
],
'houseId':house_id,
'position':2,
'price':0,
'title': title,
'types':[
'SVOD'
]
}
],
'deviceData':{
'architecture':'ranchu',
'category':'Mobile',
'country': country_code.upper(),
'key': self.device_key,
'manufacturer':'google',
'name':'sdk_gphone_x86',
'os':'Android',
'osVersion':'11',
'package':'com.viaplay.android',
'year':'2020'
},
'environmentData':{
'currency':'EUR',
'environment':'production',
'language':'en',
'market': country_code.upper(),
'name':'com.viaplay.android',
'touchPoint':'android',
'variant':'default',
'version':'5.54.1'
},
'experimentDataArray':[
'gradual_rollouts.client_side_logging',
'kids',
'start_page'
],
'pageData':{
'title':'Filmy',
'type':'product'
},
'profileData':{
'id': self.get_setting('profileid'),
'type':'adult'
},
'sectionData':{
'id': corr_id,
'name':'movie'
},
'stateData':{
'locale':'en_US',
'resolution':'411x659'
},
'userData':{
'loggedIn':True,
'userId':self.get_user_id()['id']
},
'viewContentData':{
'availability':'available',
'context':'view',
'creatives':[
'promo',
'dynamic-background',
'page',
'x-large'
],
'houseId': house_id,
'position':2,
'price':0,
'title': title
}
}

response = self.make_request(url=url, method='post', payload=payload, params=params, profile=False, status=True)

print('TEST1')
print(payload)
print(response)

if 'viaplay:media' in data['_links']:
mpd_url = data['_links']['viaplay:media']['href']
elif 'viaplay:fallbackMedia' in data['_links']:
Expand Down

0 comments on commit b795c16

Please sign in to comment.