Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recognize live and shorts YouTube URLs #230

Merged
merged 1 commit into from
Mar 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading