summaryrefslogtreecommitdiff
path: root/plugin.video.psvue
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
parentfac89d75f34d6f7ffebf622b5cfeec8e9e1cb531 (diff)
[plugin.video.psvue] 2017.7.1
Diffstat (limited to 'plugin.video.psvue')
-rw-r--r--plugin.video.psvue/addon.xml4
-rw-r--r--plugin.video.psvue/main.py23
-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
6 files changed, 79 insertions, 44 deletions
diff --git a/plugin.video.psvue/addon.xml b/plugin.video.psvue/addon.xml
index 3ab71d0..0ec5096 100644
--- a/plugin.video.psvue/addon.xml
+++ b/plugin.video.psvue/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.psvue" name="PS Vue" version="2017.6.9" provider-name="eracknaphobia">
+<addon id="plugin.video.psvue" name="PS Vue" version="2017.7.1" provider-name="eracknaphobia">
<requires>
<import addon="xbmc.python" version="2.25.0"/>
<import addon="script.module.requests" version="2.9.1"/>
@@ -13,7 +13,7 @@
<description lang="en_GB">PlayStation™Vue is a TV service that streams live TV, movies, and sports on a variety of your favorite devices without a cable or satellite subscription. With powerful features that allow you to save thousands of hours of your favorite shows without recording conflicts, and Premium channels that can be purchased individually or with a multi-channel plan, TV has never been the same. No annual contracts, no conflicts, no problems.</description>
<disclaimer lang="en_GB">Requires a valid subscription to PS Vue which is currently only available in the US</disclaimer>
<news>
-- Another fix for streams not launching
+- Yet another fix for streams not launching
</news>
<language>en</language>
<platform>all</platform>
diff --git a/plugin.video.psvue/main.py b/plugin.video.psvue/main.py
index 0ff2b3d..d6e68b9 100644
--- a/plugin.video.psvue/main.py
+++ b/plugin.video.psvue/main.py
@@ -24,15 +24,17 @@ except:
pass
-sony = SONY()
-if ADDON.getSetting(id='last_auth') != '':
- last_auth = stringToDate(ADDON.getSetting(id='last_auth'), "%Y-%m-%dT%H:%M:%S.%fZ")
- if (datetime.now() - last_auth).total_seconds() >= 5400: sony.check_auth()
-else:
- sony.check_auth()
-
+check_device_id()
-if mode == None:
+sony = SONY()
+if mode < 998:
+ if ADDON.getSetting(id='last_auth') != '':
+ last_auth = stringToDate(ADDON.getSetting(id='last_auth'), "%Y-%m-%dT%H:%M:%S.%fZ")
+ if (datetime.utcnow() - last_auth).total_seconds() > 900: sony.check_auth()
+ else:
+ sony.check_auth()
+
+if mode == None and mode < 998:
if ADDON.getSetting(id='default_profile') == '': sony.get_profiles()
main_menu()
@@ -75,8 +77,13 @@ elif mode == 998:
elif mode == 999:
sony.logout()
+ sony.notification_msg(LOCAL_STRING(30006), LOCAL_STRING(30007))
main_menu()
+elif mode == 1000:
+ sony.logout()
+ ADDON.setSetting(id='deviceId', value='')
+ sony.notification_msg(LOCAL_STRING(30006), LOCAL_STRING(30007))
if mode != None and mode != 800:
xbmcplugin.endOfDirectory(addon_handle, cacheToDisc=False)
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 -->