summaryrefslogtreecommitdiff
path: root/plugin.video.psvue/resources
diff options
context:
space:
mode:
authoreracknaphobia <eracknaphobia@hotmail.com>2017-07-01 12:05:00 -0400
committereracknaphobia <eracknaphobia@hotmail.com>2017-07-01 12:05:00 -0400
commitee7c806b2cdfe4bf5a5ffc4bbf8140a2022bb418 (patch)
tree7726a24ecbf8cfcf26acfcef1ce816d98f113f26 /plugin.video.psvue/resources
parentfac89d75f34d6f7ffebf622b5cfeec8e9e1cb531 (diff)
[plugin.video.psvue] 2017.7.1
Diffstat (limited to 'plugin.video.psvue/resources')
-rw-r--r--plugin.video.psvue/resources/language/resource.language.en_gb/strings.po12
-rw-r--r--plugin.video.psvue/resources/lib/ps_vue.py46
-rw-r--r--plugin.video.psvue/resources/lib/sony.py37
-rw-r--r--plugin.video.psvue/resources/settings.xml1
4 files changed, 62 insertions, 34 deletions
diff --git a/plugin.video.psvue/resources/language/resource.language.en_gb/strings.po b/plugin.video.psvue/resources/language/resource.language.en_gb/strings.po
index a636d27..65ca71d 100644
--- a/plugin.video.psvue/resources/language/resource.language.en_gb/strings.po
+++ b/plugin.video.psvue/resources/language/resource.language.en_gb/strings.po
@@ -36,6 +36,18 @@ msgctxt "#30004"
msgid "Change Profile"
msgstr ""
+msgctxt "#30005"
+msgid "Reset Device ID"
+msgstr ""
+
+msgctxt "#30006"
+msgid "Logout Succesful"
+msgstr ""
+
+msgctxt "#30007"
+msgid "You have been successfully logged out."
+msgstr ""
+
msgctxt "#30100"
msgid "Timeline"
msgstr ""
diff --git a/plugin.video.psvue/resources/lib/ps_vue.py b/plugin.video.psvue/resources/lib/ps_vue.py
index 71de268..51b52f4 100644
--- a/plugin.video.psvue/resources/lib/ps_vue.py
+++ b/plugin.video.psvue/resources/lib/ps_vue.py
@@ -61,7 +61,11 @@ def featured():
def list_timeline():
url = 'https://sentv-user-ext.totsuko.tv/sentv_user_ext/ws/v2/profile/ids'
- airing_id = get_json(url)['body']['launch_program']['airing_id']
+ json_source = get_json(url)
+ try:
+ airing_id = json_source['body']['launch_program']['airing_id']
+ except:
+ sys.exit()
json_source = get_json(EPG_URL + '/timeline/' + str(airing_id))
@@ -172,8 +176,8 @@ def list_episode(show):
# channel_url = CHANNEL_URL+'/'+show_id
show_url = 'https://media-framework.totsuko.tv/media-framework/media/v2.1/stream/airing/' + airing_id
- info = {'plot': plot, 'tvshowtitle': show_title, 'title': title, 'originaltitle': title, 'genre': genre,
- 'aired': airing_date.strftime('%Y-%m-%d'), 'premiered': broadcast_date.strftime('%Y-%m-%d')}
+ info = {'plot': plot, 'tvshowtitle': show_title, 'title': title, 'originaltitle': title, 'genre': genre, 'aired': airing_date.strftime('%Y-%m-%d')}
+ if broadcast_date != '': info['premiered'] = broadcast_date.strftime('%Y-%m-%d')
addStream(title, show_url, title, icon, fanart, info)
@@ -232,13 +236,15 @@ def get_stream(url):
"Accept-Encoding": "deflate",
"User-Agent": UA_ANDROID,
"Connection": "Keep-Alive",
- #'reqPayload': ADDON.getSetting(id='reqPayload')
+ 'reqPayload': ADDON.getSetting(id='reqPayload')
}
r = requests.get(url, headers=headers, cookies=load_cookies(), verify=VERIFY)
json_source = r.json()
stream_url = json_source['body']['video']
- stream_url = stream_url + '|User-Agent=Dalvik/2.1.0 (Linux; U; Android 6.0.1 Build/MOB31H)&Cookie=reqPayload=' + urllib.quote('"' + ADDON.getSetting(id='reqPayload') + '"')
+ stream_url += '|User-Agent='
+ stream_url += 'Adobe Primetime/1.4 Dalvik/2.1.0 (Linux; U; Android 6.0.1 Build/MOB31H)'
+ stream_url += '&Cookie=reqPayload=' + urllib.quote('"' + ADDON.getSetting(id='reqPayload') + '"')
listitem = xbmcgui.ListItem(path=stream_url)
# listitem.setProperty('ResumeTime', '600')
@@ -303,10 +309,10 @@ def stringToDate(string, date_format):
def create_device_id():
android_id = ''.join(random.choice('0123456789abcdef') for i in range(16))
android_id = android_id.rjust(30, '0')
- manufacturer = 'ASUS'
+ manufacturer = 'Asus'
model = 'Nexus 7'
manf_model = ":%s:%s" % (manufacturer.rjust(10, ' '), model.rjust(10, ' '))
- manf_model = manf_model.encode("hex")
+ manf_model = manf_model.encode("hex").upper()
zero = '0'
device_id = "0000%s%s01a8%s%s" % ("0007", "0002", android_id, manf_model + zero.ljust(32, '0'))
@@ -378,6 +384,22 @@ def get_params():
return param
+def check_device_id():
+ DEVICE_ID = ADDON.getSetting(id='deviceId')
+ amazon_device = 'Amazon'
+ amazon_device = amazon_device.encode("hex")
+ old_asus = 'ASUS'
+ old_asus = old_asus.encode("hex")
+ if amazon_device in DEVICE_ID or old_asus in DEVICE_ID:
+ sony = SONY()
+ sony.logout()
+ DEVICE_ID = ''
+
+ if DEVICE_ID == '':
+ create_device_id()
+ DEVICE_ID = ADDON.getSetting(id='deviceId')
+
+
addon_handle = int(sys.argv[1])
ADDON = xbmcaddon.Addon()
@@ -387,16 +409,6 @@ FANART = os.path.join(ROOTDIR, "resources", "fanart.jpg")
ICON = os.path.join(ROOTDIR, "resources", "icon.png")
ADDON_PATH_PROFILE = xbmc.translatePath(ADDON.getAddonInfo('profile'))
-DEVICE_ID = ADDON.getSetting(id='deviceId')
-
-amazon_device = 'Amazon'
-amazon_device = amazon_device.encode("hex")
-if amazon_device in DEVICE_ID: DEVICE_ID = ''
-
-if DEVICE_ID == '':
- create_device_id()
- DEVICE_ID = ADDON.getSetting(id='deviceId')
-
UA_ANDROID = 'Mozilla/5.0 (Linux; Android 6.0.1; Build/MOB31H; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/44.0.2403.119 Safari/537.36'
CHANNEL_URL = 'https://media-framework.totsuko.tv/media-framework/media/v2.1/stream/channel'
EPG_URL = 'https://epg-service.totsuko.tv/epg_service_sony/service/v2'
diff --git a/plugin.video.psvue/resources/lib/sony.py b/plugin.video.psvue/resources/lib/sony.py
index da339ab..b8708bc 100644
--- a/plugin.video.psvue/resources/lib/sony.py
+++ b/plugin.video.psvue/resources/lib/sony.py
@@ -1,4 +1,4 @@
-import os, xbmc, xbmcaddon, xbmcgui
+import sys, os, xbmc, xbmcaddon, xbmcgui
import cookielib, requests, urllib
from datetime import datetime
@@ -90,11 +90,11 @@ class SONY():
self.two_step_verification(ticket_uuid)
elif 'error_description' in json_source:
msg = json_source['error_description']
- self.error_msg(self.localized(30200), msg)
+ self.notification_msg(self.localized(30200), msg)
sys.exit()
else:
# Something went wrong during login
- self.error_msg(self.localized(30200), self.localized(30201))
+ self.notification_msg(self.localized(30200), self.localized(30201))
sys.exit()
@@ -125,11 +125,11 @@ class SONY():
self.addon.setSetting(id='npsso', value=npsso)
elif 'error_description' in json_source:
msg = json_source['error_description']
- self.error_msg(self.localized(30200), msg)
+ self.notification_msg(self.localized(30200), msg)
sys.exit()
else:
# Something went wrong during login
- self.error_msg(self.localized(30200), self.localized(30201))
+ self.notification_msg(self.localized(30200), self.localized(30201))
sys.exit()
@@ -143,6 +143,7 @@ class SONY():
}
r = requests.delete(url, headers=headers, cookies=self.load_cookies(), verify=self.verify)
+ self.save_cookies(r.cookies)
# Clear addon settings
self.addon.setSetting(id='reqPayload', value='')
self.addon.setSetting(id='last_auth', value='')
@@ -171,8 +172,9 @@ class SONY():
r = requests.get(url, headers=headers, allow_redirects=False, cookies=self.load_cookies(), verify=self.verify)
if 'X-NP-GRANT-CODE' in r.headers:
code = r.headers['X-NP-GRANT-CODE']
+ self.save_cookies(r.cookies)
else:
- self.error_msg(self.localized(30207), self.localized(30208))
+ self.notification_msg(self.localized(30207), self.localized(30208))
sys.exit()
return code
@@ -203,7 +205,7 @@ class SONY():
auth_time = r.json()['header']['time_stamp']
self.addon.setSetting(id='last_auth', value=auth_time)
else:
- self.error_msg(self.localized(30207), self.localized(30209))
+ self.notification_msg(self.localized(30207), self.localized(30209))
sys.exit()
@@ -235,7 +237,7 @@ class SONY():
else:
sys.exit()
else:
- self.error_msg(self.localized(30205), self.localized(30206))
+ self.notification_msg(self.localized(30205), self.localized(30206))
sys.exit()
@@ -306,29 +308,30 @@ class SONY():
def save_cookies(self, cookiejar):
addon_profile_path = xbmc.translatePath(self.addon.getAddonInfo('profile'))
- filename = os.path.join(addon_profile_path, 'cookies.lwp')
- lwp_cookiejar = cookielib.LWPCookieJar()
+ cookie_file = os.path.join(addon_profile_path, 'cookies.lwp')
+ cj = cookielib.LWPCookieJar()
+ cj.load(cookie_file,ignore_discard=True)
for c in cookiejar:
args = dict(vars(c).items())
args['rest'] = args['_rest']
del args['_rest']
c = cookielib.Cookie(**args)
- lwp_cookiejar.set_cookie(c)
- lwp_cookiejar.save(filename, ignore_discard=True)
+ cj.set_cookie(c)
+ cj.save(cookie_file, ignore_discard=True)
def load_cookies(self):
addon_profile_path = xbmc.translatePath(self.addon.getAddonInfo('profile'))
- filename = os.path.join(addon_profile_path, 'cookies.lwp')
- lwp_cookiejar = cookielib.LWPCookieJar()
+ cookie_file = os.path.join(addon_profile_path, 'cookies.lwp')
+ cj = cookielib.LWPCookieJar()
try:
- lwp_cookiejar.load(filename, ignore_discard=True)
+ cj.load(cookie_file, ignore_discard=True)
except:
pass
- return lwp_cookiejar
+ return cj
- def error_msg(self, title, msg):
+ def notification_msg(self, title, msg):
dialog = xbmcgui.Dialog()
dialog.notification(title, msg, xbmcgui.NOTIFICATION_INFO, 5000)
diff --git a/plugin.video.psvue/resources/settings.xml b/plugin.video.psvue/resources/settings.xml
index 2628d20..2e79c26 100644
--- a/plugin.video.psvue/resources/settings.xml
+++ b/plugin.video.psvue/resources/settings.xml
@@ -6,6 +6,7 @@
<setting id="password" type="text" label="30002" option="hidden" default=""/>
<setting id="logout" type="action" label="30003" action="RunPlugin(plugin://plugin.video.psvue/?mode=999)" option="close" />
<setting id="change_profile" type="action" label="30004" action="RunPlugin(plugin://plugin.video.psvue/?mode=800)" option="close" />
+ <setting id="reset_device_id" type="action" label="30005" action="RunPlugin(plugin://plugin.video.psvue/?mode=1000)" option="close" />
</category>
<!-- Hidden -->