FEATURE: Youtube Short onebox support (#19335)
* FEATURE: Youtube Shorts onebox support Co-authored-by: Canapin <canapin@gmail.com>
This commit is contained in:
parent
57fe57e7ce
commit
d247e5d37c
|
@ -103,6 +103,11 @@ module Onebox
|
|||
id ||= uri.path[/\/embed\/([\w\-]+)/, 1]
|
||||
end
|
||||
|
||||
# https://www.youtube.com/shorts/wi2jAtpBl0Y
|
||||
if uri.path["/shorts/"]
|
||||
id ||= uri.path[/\/shorts\/([\w\-]+)/, 1]
|
||||
end
|
||||
|
||||
# https://www.youtube.com/watch?v=Z0UISCEe52Y
|
||||
id ||= params['v']
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -14,6 +14,8 @@ RSpec.describe Onebox::Engine::YoutubeOnebox do
|
|||
stub_request(:get, "https://www.youtube.com/playlist?list=PL5308B2E5749D1696").to_return(status: 200, body: onebox_response("youtube-playlist"))
|
||||
|
||||
stub_request(:get, "https://www.youtube.com/embed/KCyIfcevExE").to_return(status: 200, body: onebox_response("youtube-embed"))
|
||||
|
||||
stub_request(:get, "https://www.youtube.com/embed/VvoFuaLAslw").to_return(status: 200, body: onebox_response("youtube-shorts"))
|
||||
end
|
||||
|
||||
it "adds wmode=opaque" do
|
||||
|
@ -103,4 +105,10 @@ RSpec.describe Onebox::Engine::YoutubeOnebox do
|
|||
preview.to match(/Delvon/)
|
||||
preview.to match(/hqdefault/)
|
||||
end
|
||||
|
||||
it "can parse youtube shorts results" do
|
||||
preview = expect(Onebox.preview('https://youtube.com/shorts/VvoFuaLAslw').placeholder_html)
|
||||
preview.to match(/POMBO/)
|
||||
preview.to match(/hqdefault/)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue