Skip to content

Commit

Permalink
Recognize live and shorts YouTube URLs (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
siasmj authored Mar 17, 2024
1 parent 597dc3c commit e1fa9cf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/video_info/providers/youtube.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def thumbnail_maxres
private

def _url_regex
%r{(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?)/|
%r{(?:youtube(?:-nocookie)?\.com/(?:[^/]+/.+/|(?:v|e(?:mbed)?|live|shorts)/|
.*[?&]v=)|youtu\.be/)([^"&?/ ]{11})}x
end

Expand Down
15 changes: 15 additions & 0 deletions spec/lib/video_info/providers/youtube_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,21 @@
it { is_expected.to be_truthy }
end

context "with embed url" do
let(:url) { "https://www.youtube.com/embed/JM9NgvjjVng" }
it { is_expected.to be_truthy }
end

context "with live url" do
let(:url) { "https://www.youtube.com/live/SMhkA07Fbfs" }
it { is_expected.to be_truthy }
end

context "with shorts url" do
let(:url) { "https://youtube.com/shorts/MOcigdHkzhE" }
it { is_expected.to be_truthy }
end

context "with other url" do
let(:url) { "http://google.com/video1" }
it { is_expected.to be_falsey }
Expand Down

0 comments on commit e1fa9cf

Please sign in to comment.