* Dial+Lounge API PoC * format * Fix for chrome * comments * Rate limit and logger stuff * rename route * remove invalid routes * remove device image * Simplify device description * command test * Lint fix * register pairing code * tv code UI * Lint fix * Avoid creating lots of objects * dpad command * small refactor * tweak * validation * timer * fix * Revert "timer" This reverts commit e349565910882408898c9bddda55dadaa9d743de. * Commands * setVolume command * lounge service timer * Some state messages * Lint fix * player state sync * voice handler * Adjustments, and add a TODO list * Lint fix * comment * play at timestamp * Remote screen UI * UI adjustment * Small refactor * Refactor long polling * Add TODO * Manage logging a bit better to avoid spam in DIAL server * cache dial file * logging * comment * Join lounge lazily * long poller tweak * ui tweak * set shouldQuit field * remote connect notification * Lint fix * Randomize device id, new device on start * Lint fix * Lounge disconnect on start * Speed up lounge by not blocking on sent messages * add version to lounge data saved * dial server fix rendezvous * todo * no message * Display network name * playlist changes * Lint fix * tweak params * tweak * player state * comments * Refactor Video Queue (#295) * Refactor Video Queue * Video queue and playlists * Web app casting * queue playlist notification * VideoQueueView work * restore properties * changes * queue notification and previous/next state * Lint fix * very basic error handling * Update changelog and privacy policy --------- Co-authored-by: github-action linter <githubaction@githubaction.com>
65 lines
1.9 KiB
Plaintext
65 lines
1.9 KiB
Plaintext
import "pkg:/components/Services/LoungeService/LoungeApi.bs"
|
|
import "pkg:/source/services/HttpClient.bs"
|
|
import "pkg:/source/utils/StringUtils.bs"
|
|
|
|
@asynctask
|
|
function LoungeGenerateManualPairingCodeTask(input as object) as object
|
|
loungeService = input.loungeService
|
|
|
|
if StringUtils.IsNullOrEmpty(input.loungeToken)
|
|
messagePort = CreateObject("roMessagePort")
|
|
loungeService.observeFieldScoped("loungeToken", messagePort)
|
|
loungeService.join = true
|
|
message = wait(30000, messagePort)
|
|
loungeService.unobserveFieldScoped("loungeToken")
|
|
if message = invalid or StringUtils.IsNullOrEmpty(message.GetData())
|
|
return {
|
|
"success": false
|
|
"error": "Couldn't join lounge"
|
|
}
|
|
end if
|
|
|
|
input.screenId = loungeService.screenId
|
|
input.loungeToken = loungeService.loungeToken
|
|
end if
|
|
|
|
bodyParams = {
|
|
"lounge_token": input.loungeToken
|
|
"screen_id": input.screenId
|
|
"screen_name": input.screenName
|
|
"device_id": input.deviceId
|
|
}
|
|
|
|
for each key in bodyParams
|
|
if StringUtils.IsNullOrEmpty(bodyParams[key])
|
|
return {
|
|
"success": false
|
|
"error": key + " is empty"
|
|
}
|
|
end if
|
|
end for
|
|
|
|
bodyParams["access_type"] = "permanent"
|
|
bodyParams["app"] = "Playlet"
|
|
|
|
baseUrl = "https://www.youtube.com/api/lounge/pairing/get_pairing_code?ctx=pair"
|
|
|
|
body = UrlUtils.GetUrlEncodedForm(bodyParams)
|
|
request = HttpClient.Post(baseUrl, body)
|
|
request.Header("Content-Type", "application/x-www-form-urlencoded")
|
|
|
|
response = request.Await()
|
|
if not response.IsSuccess()
|
|
return {
|
|
"success": false
|
|
"error": response.ErrorMessage()
|
|
}
|
|
end if
|
|
|
|
code = response.Text()
|
|
return {
|
|
"success": true
|
|
"code": code
|
|
}
|
|
end function
|