mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Add support for '/embed/live_stream'
This commit is contained in:
parent
6215259565
commit
607d6125fc
1 changed files with 22 additions and 2 deletions
|
@ -559,7 +559,8 @@ get "/embed/:id" do |env|
|
||||||
|
|
||||||
# YouTube embed supports `videoseries` with either `list=PLID`
|
# YouTube embed supports `videoseries` with either `list=PLID`
|
||||||
# or `playlist=VIDEO_ID,VIDEO_ID`
|
# or `playlist=VIDEO_ID,VIDEO_ID`
|
||||||
if id == "videoseries"
|
case id
|
||||||
|
when "videoseries"
|
||||||
url = ""
|
url = ""
|
||||||
|
|
||||||
if plid
|
if plid
|
||||||
|
@ -584,7 +585,26 @@ get "/embed/:id" do |env|
|
||||||
end
|
end
|
||||||
|
|
||||||
next env.redirect url
|
next env.redirect url
|
||||||
elsif id.size > 11
|
when "live_stream"
|
||||||
|
client = make_client(YT_URL)
|
||||||
|
response = client.get("/embed/live_stream?channel=#{env.params.query["channel"]? || ""}")
|
||||||
|
video_id = response.body.match(/"video_id":"(?<video_id>[a-zA-Z0-9_-]{11})"/).try &.["video_id"]
|
||||||
|
|
||||||
|
env.params.query.delete_all("channel")
|
||||||
|
|
||||||
|
if !video_id || video_id == "live_stream"
|
||||||
|
error_message = "Video is unavailable."
|
||||||
|
next templated "error"
|
||||||
|
end
|
||||||
|
|
||||||
|
url = "/embed/#{video_id}"
|
||||||
|
|
||||||
|
if env.params.query.size > 0
|
||||||
|
url += "?#{env.params.query}"
|
||||||
|
end
|
||||||
|
|
||||||
|
next env.redirect url
|
||||||
|
when id.size > 11
|
||||||
url = "/embed/#{id[0, 11]}"
|
url = "/embed/#{id[0, 11]}"
|
||||||
|
|
||||||
if env.params.query.size > 0
|
if env.params.query.size > 0
|
||||||
|
|
Loading…
Reference in a new issue