Invidious is an alternative front-end to YouTube
Update info extractor
Omar Rothe8c9641548f2
diff --git a/src/invidious/comments.cr b/src/invidious/comments.crindex ba5d6f08..f4398b58 100644--- a/src/invidious/comments.cr+++ b/src/invidious/comments.cr@@ -58,7 +58,7 @@ enddef fetch_youtube_comments(id, continuation, proxies, format)client = make_client(YT_URL)- html = client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")+ html = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")headers = HTTP::Headers.newheaders["cookie"] = html.cookies.add_request_headers(headers)["cookie"]body = html.body@@ -83,7 +83,7 @@ def fetch_youtube_comments(id, continuation, proxies, format)proxy = HTTPProxy.new(proxy_host: proxy[:ip], proxy_port: proxy[:port])proxy_client.set_proxy(proxy)- response = proxy_client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")+ response = proxy_client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")proxy_headers = HTTP::Headers.newproxy_headers["cookie"] = response.cookies.add_request_headers(headers)["cookie"]proxy_html = response.body@@ -140,8 +140,8 @@ def fetch_youtube_comments(id, continuation, proxies, format)headers["content-type"] = "application/x-www-form-urlencoded"headers["x-client-data"] = "CIi2yQEIpbbJAQipncoBCNedygEIqKPKAQ=="- headers["x-spf-previous"] = "https://www.youtube.com/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1"- headers["x-spf-referer"] = "https://www.youtube.com/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1"+ headers["x-spf-previous"] = "https://www.youtube.com/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999"+ headers["x-spf-referer"] = "https://www.youtube.com/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999"headers["x-youtube-client-name"] = "1"headers["x-youtube-client-version"] = "2.20180719"diff --git a/src/invidious/mixes.cr b/src/invidious/mixes.crindex 66f7371d..688a8622 100644--- a/src/invidious/mixes.cr+++ b/src/invidious/mixes.cr@@ -26,7 +26,7 @@ def fetch_mix(rdid, video_id, cookies = nil)if cookiesheaders = cookies.add_request_headers(headers)end- response = client.get("/watch?v=#{video_id}&list=#{rdid}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en", headers)+ response = client.get("/watch?v=#{video_id}&list=#{rdid}&gl=US&hl=en&has_verified=1&bpctr=9999999999", headers)yt_data = response.body.match(/window\["ytInitialData"\] = (?<data>.*);/)if yt_datadiff --git a/src/invidious/playlists.cr b/src/invidious/playlists.crindex cc149ea8..c1adb1d9 100644--- a/src/invidious/playlists.cr+++ b/src/invidious/playlists.cr@@ -30,7 +30,7 @@ def fetch_playlist_videos(plid, page, video_count, continuation = nil)client = make_client(YT_URL)if continuation- html = client.get("/watch?v=#{continuation}&list=#{plid}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")+ html = client.get("/watch?v=#{continuation}&list=#{plid}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")html = XML.parse_html(html.body)index = html.xpath_node(%q(//span[@id="playlist-current-index"])).try &.content.to_i?diff --git a/src/invidious/videos.cr b/src/invidious/videos.crindex eaf2e17a..a0fb7f22 100644--- a/src/invidious/videos.cr+++ b/src/invidious/videos.cr@@ -546,7 +546,7 @@ def fetch_video(id, proxies)spawn doclient = make_client(YT_URL)- html = client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1")+ html = client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999")if md = html.headers["location"]?.try &.match(/v=(?<id>[a-zA-Z0-9_-]{11})/)next html_channel.send(md["id"])@@ -620,7 +620,7 @@ def fetch_video(id, proxies)client.connect_timeout = 10.secondsclient.set_proxy(proxy)- html = XML.parse_html(client.get("/watch?v=#{id}&bpctr=#{Time.new.to_unix + 2000}&gl=US&hl=en&disable_polymer=1").body)+ html = XML.parse_html(client.get("/watch?v=#{id}&gl=US&hl=en&disable_polymer=1&has_verified=1&bpctr=9999999999").body)info = HTTP::Params.parse(client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body)if info["reason"]?@@ -641,7 +641,19 @@ def fetch_video(id, proxies)endif info["reason"]?- raise info["reason"]+ html_info = html.to_s.match(/ytplayer\.config = (?<info>.*?);ytplayer\.load/).try &.["info"]+ if html_info+ html_info = JSON.parse(html_info)["args"].as_h+ info.delete("reason")++ html_info.each do |k, v|+ info[k] = v.to_s+ end+ end++ if info["reason"]?+ raise info["reason"]+ endendtitle = info["title"]