mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Parse response to JSON instead of using regex
This commit is contained in:
parent
e248e7ebaf
commit
c5ccefe6f7
1 changed files with 8 additions and 4 deletions
|
@ -358,16 +358,20 @@ end
|
|||
def fetch_channel_playlists(ucid, author, continuation, sort_by)
|
||||
if continuation
|
||||
response_json = request_youtube_api_browse(continuation)
|
||||
result = JSON.parse(response_json.match(/"continuationItems": (?<items>\[.*\]),/m).try &.["items"] || "{}")
|
||||
# result = JSON.parse(response_json.match(/"continuationItems": (?<items>\[.*\]),/m).try &.["items"] || "{}")
|
||||
result = JSON.parse(response_json)
|
||||
continuationItems = result["onResponseReceivedActions"]?
|
||||
.try &.[0]["appendContinuationItemsAction"]["continuationItems"]
|
||||
|
||||
return [] of SearchItem, nil if result.size == 0
|
||||
return [] of SearchItem, nil if !continuationItems
|
||||
|
||||
items = [] of SearchItem
|
||||
result.as_a.select(&.as_h.has_key?("gridPlaylistRenderer")).each { |item|
|
||||
continuationItems.as_a.select(&.as_h.has_key?("gridPlaylistRenderer")).each { |item|
|
||||
extract_item(item, author, ucid).try { |t| items << t }
|
||||
}
|
||||
|
||||
continuation = result.as_a.last["continuationItemRenderer"]?.try &.["continuationEndpoint"]["continuationCommand"]["token"].as_s
|
||||
continuation = continuationItems.as_a.last["continuationItemRenderer"]?
|
||||
.try &.["continuationEndpoint"]["continuationCommand"]["token"].as_s
|
||||
else
|
||||
url = "/channel/#{ucid}/playlists?flow=list&view=1"
|
||||
|
||||
|
|
Loading…
Reference in a new issue