Skip to content

Commit

Permalink
v2.4.3_v4
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusz89B committed Mar 5, 2023
1 parent b795c16 commit 31445b6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 170 deletions.
84 changes: 10 additions & 74 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,10 @@ def run():
pass

def watched(guid, program=False):
params = {
'profileId': helper.vp.get_setting('profileid'),
}

if program:
if guid == 'no_guid':
message = helper.language(30072)
Expand All @@ -212,26 +216,7 @@ def watched(guid, program=False):
else:
guid = guid.split('-')[0]

params = {
'deviceId': helper.vp.get_deviceid(),
'deviceName': 'web',
'deviceType': 'pc',
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41',
'deviceKey': helper.vp.device_key,
'cse': 'true',
'guid': guid,
}

response = helper.vp.make_request(url=helper.vp.play_api + '/api/stream/byguid', method='get', params=params)

params = {
'profileId': response['socket']['userId'],
}

if response['product'].get('series'):
program_guid = response['product']['content']['series']['seriesGuid']
else:
program_guid = guid
program_guid = guid

if not guid[1:].isnumeric():
message = helper.language(30072)
Expand All @@ -240,10 +225,6 @@ def watched(guid, program=False):

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'),
}

response = helper.vp.make_request(url=url, method='post', params=params, status=True)

sql_remove_watched(program_guid)
Expand All @@ -254,6 +235,10 @@ def watched(guid, program=False):
helper.dialog(dialog_type='notification', heading=helper.language(30017), message=message)

def favourite(guid, program=False, remove=False):
params = {
'profileId': helper.vp.get_setting('profileid'),
}

if program:
if guid == 'no_guid':
message = helper.language(30072)
Expand All @@ -262,59 +247,10 @@ def favourite(guid, program=False, remove=False):

program_guid = guid

http_session = requests.Session()

cookie_file = os.path.join(helper.vp.addon_profile, 'cookie_file')

cookie_jar = cookielib.LWPCookieJar(cookie_file)

try:
cookie_jar.load(ignore_discard=True, ignore_expires=True)
except IOError:
pass

http_session.cookies = cookie_jar

for cookie in http_session.cookies:
if cookie.name == 'session':
value = unquote(cookie.value)

json_regex = re.compile(r'[{\[]{1}([,:{}\[\]0-9.\-+A-zr-u \n\r\t]|".*:?")+[}\]]{1}')

r = json_regex.search(value)
json_str = r.group(0) if r else ''

data = json.loads(json_str)

profileId = data['userId']

params = {
'profileId': profileId,
}

else:
guid = guid.split('-')[0]

params = {
'deviceId': helper.vp.get_deviceid(),
'deviceName': 'web',
'deviceType': 'pc',
'userAgent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36 Edg/110.0.1587.41',
'deviceKey': helper.vp.device_key,
'cse': 'true',
'guid': guid,
}

response = helper.vp.make_request(url=helper.vp.play_api + '/stream/byguid', method='get', params=params)

params = {
'profileId': response['socket']['userId'],
}

if response['product'].get('series'):
program_guid = response['product']['content']['series']['seriesGuid']
else:
program_guid = guid
program_guid = guid

if not guid[1:].isnumeric():
message = helper.language(30072)
Expand Down
102 changes: 6 additions & 96 deletions resources/lib/viaplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ 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']
Expand All @@ -372,21 +369,20 @@ def get_stream(self, guid, pincode=None, tve='false', url=''):

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

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

params = {
'sessionId': session,
}

"""
payload = {
'contentDataArray': [
{
'availability': 'available',
'context': 'view',
'creatives': [
'no-background-type',
'no-background',
'promo',
'dynamic-background',
'page',
'x-large'
],
Expand Down Expand Up @@ -443,9 +439,8 @@ def get_stream(self, guid, pincode=None, tve='false', url=''):
'resolution': '411x659'
},
'streamData': {
'offline': False,
'offline': True,
'progress': 0,
'sessionGuid': session_guid,
'startMethod': 'manual',
'state': 'default'
},
Expand All @@ -459,95 +454,10 @@ def get_stream(self, guid, pincode=None, tve='false', url=''):
'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)
response = self.make_request(url=url, method='post', payload=json.dumps(payload), params=params, profile=False, status=True)

print('TEST1')
print(payload)
print('PRINT RESPONSE:')
print(response)

if 'viaplay:media' in data['_links']:
Expand Down

0 comments on commit 31445b6

Please sign in to comment.