예제 #1
0
파일: sony.py 프로젝트: DiR3Wolf/PSVueProxy
    def set_profile(self):

        # If default profile is not set, then ask the user
        if not globals.get_setting("default_profile"):
            profile_id = self.get_user_profile()

        url = "https://sentv-user-ext.totsuko.tv/sentv_user_ext/ws/v2/profile/" + globals.get_setting(
            "default_profile")

        headers = {
            "User-Agent": globals.UA_ANDROID_TV,
            "reqPayload": self.reqPayload,
            "Accept": "*/*",
            "Origin": "https://themis.dl.playstation.net",
            "Host": "sentv-user-ext.totsuko.tv",
            "Connection": "Keep-Alive",
            "Accept-Encoding": "gzip",
            "X-Requested-With": "com.snei.vue.atv"
        }

        r = requests.get(url, headers=headers, verify=self.verify)
        self.EPGreqPayload = str(r.headers['reqPayload'])
        globals.save_setting("EPGreqPayload", self.EPGreqPayload)
        auth_time = r.json()['header']['time_stamp']
        globals.save_setting("last_auth", auth_time)
예제 #2
0
파일: sony.py 프로젝트: DiR3Wolf/PSVueProxy
    def parse_settings_file(self):

        dataFile = open(globals.DATA_FILE, "a+")
        settingsFileJson = "{}"

        try:
            dataFileContents = json.load(dataFile)
        except:
            print(TAG + "No valid JSON found, probably a first run")
            dataFile.seek(0, 0)
            dataFile.truncate()
            dataFile.write("{}")
            dataFile.close()

        if not globals.get_setting("device_id"):
            self.create_device_id()
        else:
            self.device_id = globals.get_setting("device_id")

        if not globals.get_setting("username"):
            globals.save_setting("username", raw_input("Username: "******"username")

        if not globals.get_setting("password"):
            globals.save_setting("password", getpass.getpass("Password: "******"password")

        if globals.get_setting("npsso"):
            self.npsso = globals.get_setting("npsso")

        if globals.get_setting("reqPayload"):
            self.reqPayload = globals.get_setting("reqPayload")
예제 #3
0
파일: sony.py 프로젝트: DiR3Wolf/PSVueProxy
    def get_json(self, url):
        #TODO: Check to see if cookie is expired and re-authenticate to get new EPGReqPayload
        headers = {
            "Accept": "*/*",
            "reqPayload": globals.get_setting("EPGreqPayload"),
            "User-Agent": globals.UA_ANDROID_TV,
            "Accept-Encoding": "gzip, deflate, br",
            "Accept-Language": "en-US,en;q=0.5",
            "X-Requested-With": "com.snei.vue.android",
            "Connection": "keep-alive"
        }

        r = requests.get(url,
                         headers=headers,
                         cookies=globals.load_cookies(),
                         verify=self.verify)

        if r.status_code != 200:
            print(TAG + "ERROR - could not complete json request: ")
            try:
                json_source = r.json()
                print(TAG + "\t" + json_source['header']['error']['message'])
            except:
                pass
            sys.exit()

        return r.json()
예제 #4
0
파일: sony.py 프로젝트: DiR3Wolf/PSVueProxy
    def write_req_payload(self):
        # save of the current epg req payload
        save_dir = os.path.dirname(os.path.realpath(__file__))
        req_payload_file = open(os.path.join(save_dir, "reqPayload.dat"), "w")

        contents = "COOKIE=\""
        contents += globals.get_setting("EPGreqPayload")
        contents += "\""

        req_payload_file.write(contents)
        req_payload_file.close()
예제 #5
0
파일: sony.py 프로젝트: DiR3Wolf/PSVueProxy
    def epg_get_stream(self, url):
        headers = {
            "Accept": "*/*",
            "Content-type": "application/x-www-form-urlencoded",
            "Origin": "https://vue.playstation.com",
            "Accept-Language": "en-US,en;q=0.8",
            "Referer": "https://vue.playstation.com/watch/live",
            "Accept-Encoding": "gzip, deflate, br",
            "User-Agent": globals.UA_ANDROID_TV,
            "Connection": "Keep-Alive",
            "Host": "media-framework.totsuko.tv",
            "reqPayload": globals.get_setting("EPGreqPayload"),
            "X-Requested-With": "com.snei.vue.android"
        }

        r = requests.get(url,
                         headers=headers,
                         cookies=globals.load_cookies(),
                         verify=globals.VERIFY)
        json_source = r.json()
        stream_url = json_source['body']['video']

        return stream_url
예제 #6
0
    def send_redirect(self, stream_url):

        print(TAG + "Redirecting to: " + stream_url)

        self.send_response(303)

        headers = {
            "Content-type": "text/html;charset=utf-8",
            "Connection": "close",
            #"Host": "media-framework.totsuko.tv",
            "Location": stream_url,
            "Set-Cookie": 'reqPayload=' + '"' + globals.get_setting("EPGreqPayload") + '"' + '; Domain=totsuko.tv; Path=/'
        }

        for key in headers:
            try:
                value = headers[key]
                self.send_header(key, value)
            except Exception as e:
                pass

        self.end_headers()

        self.wfile.close()