diff options
| author | Omar Roth <omarroth@protonmail.com> | 2019-12-05 15:47:35 -0500 |
|---|---|---|
| committer | Omar Roth <omarroth@protonmail.com> | 2019-12-05 15:47:35 -0500 |
| commit | 88a538e71bd9810a8b47524b2ddc865ec6326285 (patch) | |
| tree | 59d3d9a1fd3e08685e2c192883c5eb1df604cdf9 /src | |
| parent | 513363504f28d32c9bfb0d325296701f660b766a (diff) | |
| download | invidious-88a538e71bd9810a8b47524b2ddc865ec6326285.tar.gz invidious-88a538e71bd9810a8b47524b2ddc865ec6326285.tar.bz2 invidious-88a538e71bd9810a8b47524b2ddc865ec6326285.zip | |
Minor refactor for channel playlists
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/channels.cr | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/invidious/channels.cr b/src/invidious/channels.cr index ccb87d6f..433fe074 100644 --- a/src/invidious/channels.cr +++ b/src/invidious/channels.cr @@ -383,7 +383,7 @@ def fetch_channel(ucid, db, pull_all_videos = true, locale = nil) end def fetch_channel_playlists(ucid, author, auto_generated, continuation, sort_by) - if continuation + if continuation || auto_generated url = produce_channel_playlists_url(ucid, continuation, sort_by, auto_generated) response = YT_POOL.client &.get(url) @@ -402,13 +402,6 @@ def fetch_channel_playlists(ucid, author, auto_generated, continuation, sort_by) html = XML.parse_html(json["content_html"].as_s) nodeset = html.xpath_nodes(%q(//li[contains(@class, "feed-item-container")])) - elsif auto_generated - url = "/channel/#{ucid}" - - response = YT_POOL.client &.get(url) - html = XML.parse_html(response.body) - - nodeset = html.xpath_nodes(%q(//ul[@id="browse-items-primary"]/li[contains(@class, "feed-item-container")])) else url = "/channel/#{ucid}/playlists?disable_polymer=1&flow=list&view=1" @@ -504,10 +497,10 @@ def produce_channel_playlists_url(ucid, cursor, sort = "newest", auto_generated }, } - if !auto_generated - cursor = Base64.urlsafe_encode(cursor, false) + if cursor + cursor = Base64.urlsafe_encode(cursor, false) if !auto_generated + object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = cursor end - object["80226972:embedded"]["3:base64"].as(Hash)["15:string"] = cursor if auto_generated object["80226972:embedded"]["3:base64"].as(Hash)["4:varint"] = 0x32_i64 @@ -807,7 +800,7 @@ def produce_channel_community_continuation(ucid, cursor) object = { "80226972:embedded" => { "2:string" => ucid, - "3:string" => cursor, + "3:string" => cursor || "", }, } |
