From e54a5c67f33c81e74715855796f36c52b7d109db Mon Sep 17 00:00:00 2001 From: Rerurate514 Date: Sat, 26 Jul 2025 01:18:54 +0900 Subject: [PATCH 1/2] add live url exp --- lib/src/videos/video_id.dart | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/videos/video_id.dart b/lib/src/videos/video_id.dart index 091ebb4..733c82c 100644 --- a/lib/src/videos/video_id.dart +++ b/lib/src/videos/video_id.dart @@ -13,6 +13,7 @@ abstract class VideoId with _$VideoId { static final _embedMatchExp = RegExp(r'youtube\..+?/embed/(.*?)(?:\?|&|/|$)'); static final _shortsMatchExp = RegExp(r'youtube\..+/shorts/([A-Za-z0-9-_]+$)'); + static final _liveMatchExp = RegExp(r'youtube\..+?/live/(.*?)(?:\?|&|/|$)'); /// Initializes an instance of [VideoId] with a url or video id. factory VideoId(String idOrUrl) { @@ -97,6 +98,13 @@ abstract class VideoId with _$VideoId { if (!shortsMatch.isNullOrWhiteSpace && validateVideoId(shortsMatch!)) { return shortsMatch; } + + // https://www.youtube.com/live/yIVRs6YSbOM + final liveMatch = _liveMatchExp.firstMatch(url)?.group(1); + if (!liveMatch.isNullOrWhiteSpace && validateVideoId(liveMatch!)) { + return liveMatch; + } + return null; } } From 710ef10a7d58a654310da18c48e263c46a650e68 Mon Sep 17 00:00:00 2001 From: Rerurate514 Date: Sat, 26 Jul 2025 01:19:47 +0900 Subject: [PATCH 2/2] add live url exp test --- test/video_id_test.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/video_id_test.dart b/test/video_id_test.dart index 60ac07f..cb0503e 100644 --- a/test/video_id_test.dart +++ b/test/video_id_test.dart @@ -16,6 +16,7 @@ void main() { ['youtube.com/watch?v=yIVRs6YSbOM', 'yIVRs6YSbOM'], ['youtu.be/yIVRs6YSbOM', 'yIVRs6YSbOM'], ['youtube.com/embed/yIVRs6YSbOM', 'yIVRs6YSbOM'], + ['youtube.com/live/yIVRs6YSbOM', 'yIVRs6YSbOM'], }) { test('Video - $val', () { expect(VideoId(val[0]).value, val[1]); @@ -34,6 +35,7 @@ void main() { 'youtube.com/xxx?v=pI2I2zqzeKg', 'youtu.be/watch?v=xxx', 'youtube.com/embed', + 'youtube.com/live' }) { test('VideoURL - $val', () { expect(() => VideoId(val), throwsArgumentError);