forked from midou/invidious
Optimize fetch_video
This commit is contained in:
parent
56e35def8a
commit
5c3494006f
@ -221,20 +221,34 @@ def elapsed_text(elapsed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_video(id, client)
|
def fetch_video(id, client)
|
||||||
info = client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body
|
info_channel = Channel(HTTP::Params).new
|
||||||
html = client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&disable_polymer=1").body
|
html_channel = Channel(XML::Node).new
|
||||||
|
|
||||||
html = XML.parse_html(html)
|
spawn do
|
||||||
info = HTTP::Params.parse(info)
|
html = client.get("/watch?v=#{id}&bpctr=#{Time.new.epoch + 2000}&disable_polymer=1").body
|
||||||
|
html = XML.parse_html(html)
|
||||||
|
|
||||||
if info["reason"]?
|
html_channel.send(html)
|
||||||
info = client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body
|
|
||||||
info = HTTP::Params.parse(info)
|
|
||||||
if info["reason"]?
|
|
||||||
raise info["reason"]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
spawn do
|
||||||
|
info = client.get("/get_video_info?video_id=#{id}&el=detailpage&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body
|
||||||
|
info = HTTP::Params.parse(info)
|
||||||
|
|
||||||
|
if info["reason"]?
|
||||||
|
info = client.get("/get_video_info?video_id=#{id}&ps=default&eurl=&gl=US&hl=en&disable_polymer=1").body
|
||||||
|
info = HTTP::Params.parse(info)
|
||||||
|
if info["reason"]?
|
||||||
|
raise info["reason"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
info_channel.send(info)
|
||||||
|
end
|
||||||
|
|
||||||
|
html = html_channel.receive
|
||||||
|
info = info_channel.receive
|
||||||
|
|
||||||
title = info["title"]
|
title = info["title"]
|
||||||
views = info["view_count"].to_i64
|
views = info["view_count"].to_i64
|
||||||
author = info["author"]
|
author = info["author"]
|
||||||
|
Loading…
Reference in New Issue
Block a user