From 34c4f9dbc8c31bce85ec0106cb2179ad7fe85507 Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Sun, 3 Oct 2021 17:57:33 +0200 Subject: [PATCH 1/5] got html res --- .clj-kondo/.cache/2021.09.25/lock | 0 components/rowListContent.brs | 12 ++++++++---- components/rowListScene.brs | 3 --- components/tasks/httpTask.brs | 31 +++++++++++++++---------------- components/tasks/httpTask.xml | 1 + components/tasks/req.txt | 0 6 files changed, 24 insertions(+), 23 deletions(-) create mode 100644 .clj-kondo/.cache/2021.09.25/lock create mode 100644 components/tasks/req.txt diff --git a/.clj-kondo/.cache/2021.09.25/lock b/.clj-kondo/.cache/2021.09.25/lock new file mode 100644 index 0000000..e69de29 diff --git a/components/rowListContent.brs b/components/rowListContent.brs index a37fbf2..a8cc591 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -1,11 +1,15 @@ sub init() - m.global.http.request = { payload: { + m.http = createObject("roSGNode", "httpTask") + m.http.control = "RUN" + m.http.request = { payload: { userId: 1, title: "WOW, IT WORKED ^_^", - }, url: "https://jsonplaceholder.typicode.com/albums", requestType: "GET"} - m.global.http.observeFieldScoped("response", "useResponse") + }, url: "https://www.youtube.com/watch?v=a3UzkajLu7A", requestType: "GET" } + m.http.observeFieldScoped("response", "useResponse") end sub sub useResponse() - ?m.global.http.response + initialPlayerResponseRegEx = createObject("roRegex", "ytInitialPlayerResponse\s*=\s*({.+?})\s*;", "m") + matches = initialPlayerResponseRegEx.match(m.http.response.body) + ?ParseJson(matches[1]).streamingData.formats[0] end sub diff --git a/components/rowListScene.brs b/components/rowListScene.brs index 22d7821..fd43c17 100644 --- a/components/rowListScene.brs +++ b/components/rowListScene.brs @@ -1,8 +1,5 @@ sub init() - m.global.addField("http", "node", FALSE) m.global.addField("ratio", "float", FALSE) - m.global.http = createObject("roSGNode", "httpTask") - m.global.http.control = "RUN" m.global.ratio = 1 m.rowList = m.top.findNode("mainRowList") m.rowList.content = createObject("roSGNode", "RowListContent") diff --git a/components/tasks/httpTask.brs b/components/tasks/httpTask.brs index aee48f2..0c5d862 100644 --- a/components/tasks/httpTask.brs +++ b/components/tasks/httpTask.brs @@ -14,15 +14,15 @@ function handleCalls() as Object response = fire(msg.getData()) end if else if msgType = "roUrlEvent" - if msg.getInt() = 1 - if msg.getResponseCode() > 0 - response = handleResponse(msg.getString(),msg,true) - else - response = handleResponse(msg.getFailureReason(),msg,false) - end if + if msg.getInt() = 1 + if msg.getResponseCode() > 0 + response = handleResponse(msg.getString(), msg, true) + else + response = handleResponse(msg.getFailureReason(), msg, false) end if - m.top.response = response - return response + end if + m.top.response = response + return response end if end while end function @@ -31,7 +31,7 @@ function fire(request as Object) as Object httpRequest = initiateHttpClient(request.url) requestId = httpRequest.getIdentity().ToStr() m.urlRequest[requestId] = { - request:httpRequest + request: httpRequest } if checkRequestType(request.requestType) httpRequest.AsyncPostFromString(formatJson(request.payload)) @@ -42,15 +42,15 @@ end function function handleResponse(responseString as String, message as Object, isOk as Boolean) as Object if isOk - body = parseJson(responseString) + body = responseString else body = "An Error has Occurred!!" end if - requestId = message.GetSourceIdentity().ToStr() - m.urlRequest[requestId] = invalid + requestId = message.GetSourceIdentity().ToStr() + m.urlRequest[requestId] = invalid return { requestId: requestId - body:body + body: body } end function @@ -60,9 +60,8 @@ function initiateHttpClient(url as String) as Object httpRequest.InitClientCertificates() httpRequest.SetPort(m.port) httpRequest.SetUrl(url) - httpRequest.RetainBodyOnError(true) - httpRequest.addHeader("Content-Type", "application/json") - httpRequest.addHeader("Accept", "application/json") + httpRequest.RetainBodyOnError(false) + httpRequest.addHeader("Context", "client:{clientName:'WEB',clientVersion:'2.20201021.03.00'}") return httpRequest end function diff --git a/components/tasks/httpTask.xml b/components/tasks/httpTask.xml index d3c075c..c6f5eb5 100644 --- a/components/tasks/httpTask.xml +++ b/components/tasks/httpTask.xml @@ -5,4 +5,5 @@ + \ No newline at end of file diff --git a/components/tasks/req.txt b/components/tasks/req.txt new file mode 100644 index 0000000..e69de29 From 8325ed7952ed76e8b6f76e1cb3d57beb160f3454 Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Sun, 3 Oct 2021 18:08:58 +0200 Subject: [PATCH 2/5] handled returning a URL for the non ciphered videos --- components/rowListContent.brs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/rowListContent.brs b/components/rowListContent.brs index a8cc591..ce56822 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -4,12 +4,12 @@ sub init() m.http.request = { payload: { userId: 1, title: "WOW, IT WORKED ^_^", - }, url: "https://www.youtube.com/watch?v=a3UzkajLu7A", requestType: "GET" } + }, url: "https://www.youtube.com/watch?v=cwttM41xVBY", requestType: "GET" } m.http.observeFieldScoped("response", "useResponse") end sub sub useResponse() initialPlayerResponseRegEx = createObject("roRegex", "ytInitialPlayerResponse\s*=\s*({.+?})\s*;", "m") matches = initialPlayerResponseRegEx.match(m.http.response.body) - ?ParseJson(matches[1]).streamingData.formats[0] + ?ParseJson(matches[1]).streamingData.formats[0].url end sub From d950406cf69f8d13fe83d67cdd0d10ec45055186 Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Mon, 4 Oct 2021 12:36:43 +0200 Subject: [PATCH 3/5] changed .formats to .adaptiveFormats --- components/rowListContent.brs | 4 ++-- components/tasks/httpTask.brs | 1 - components/tasks/req.txt | 0 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 components/tasks/req.txt diff --git a/components/rowListContent.brs b/components/rowListContent.brs index ce56822..978cc54 100644 --- a/components/rowListContent.brs +++ b/components/rowListContent.brs @@ -4,12 +4,12 @@ sub init() m.http.request = { payload: { userId: 1, title: "WOW, IT WORKED ^_^", - }, url: "https://www.youtube.com/watch?v=cwttM41xVBY", requestType: "GET" } + }, url: "https://www.youtube.com/watch?v=1FL22N1EXDo", requestType: "GET" } m.http.observeFieldScoped("response", "useResponse") end sub sub useResponse() initialPlayerResponseRegEx = createObject("roRegex", "ytInitialPlayerResponse\s*=\s*({.+?})\s*;", "m") matches = initialPlayerResponseRegEx.match(m.http.response.body) - ?ParseJson(matches[1]).streamingData.formats[0].url + ?ParseJson(matches[1]).streamingData.adaptiveFormats[0].url end sub diff --git a/components/tasks/httpTask.brs b/components/tasks/httpTask.brs index 0c5d862..508f50f 100644 --- a/components/tasks/httpTask.brs +++ b/components/tasks/httpTask.brs @@ -61,7 +61,6 @@ function initiateHttpClient(url as String) as Object httpRequest.SetPort(m.port) httpRequest.SetUrl(url) httpRequest.RetainBodyOnError(false) - httpRequest.addHeader("Context", "client:{clientName:'WEB',clientVersion:'2.20201021.03.00'}") return httpRequest end function diff --git a/components/tasks/req.txt b/components/tasks/req.txt deleted file mode 100644 index e69de29..0000000 From 9b3e8c70ee173e5e375e4d710203c426d7d2bd72 Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Tue, 5 Oct 2021 17:41:12 +0200 Subject: [PATCH 4/5] Delete .clj-kondo/.cache/2021.09.25 directory --- .clj-kondo/.cache/2021.09.25/lock | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .clj-kondo/.cache/2021.09.25/lock diff --git a/.clj-kondo/.cache/2021.09.25/lock b/.clj-kondo/.cache/2021.09.25/lock deleted file mode 100644 index e69de29..0000000 From 2d8668cb995f59dc10cc48e5c41bd18f762f9a7b Mon Sep 17 00:00:00 2001 From: vampirekiddo <33176106+vampirekiddo@users.noreply.github.com> Date: Tue, 5 Oct 2021 17:41:27 +0200 Subject: [PATCH 5/5] Delete .vscode directory --- .vscode/launch.json | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index dca2ab3..0000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "brightscript", - "request": "launch", - "name": "BrightScript Debug: Launch", - "stopOnEntry": false, - "host": "${promptForHost}", - "password": "mega", - "rootDir": "${workspaceFolder}", - "enableDebuggerAutoRecovery": false, - "stopDebuggerOnAppExit": false - } - ] -} \ No newline at end of file