Skip to content

Commit b061c21

Browse files
committed
Improve YouTube URL recognition
1 parent f498d68 commit b061c21

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/com/joelchristophel/sourceradio/Song.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void initialize(HttpRequest request) throws IOException {
324324

325325
private static String getYoutubeIdFromUrl(String text) {
326326
Pattern pattern = Pattern
327-
.compile("^(?:http(?:s?):\\/\\/)?(?:www\\.)?(?:youtube\\.com\\/watch\\?v=|youtu\\.be\\/)([^?\\/]+).*$");
327+
.compile("^(?:http(?:s?):\\/\\/)?(?:www\\.|m\\.)?(?:youtube\\.com\\/(?:watch\\?(?:.+&)?v=|v\\/|embed\\/ )|youtu\\.be\\/)([a-zA-Z0-9_-]{11,}).*$");
328328
Matcher matcher = pattern.matcher(text);
329329
if (matcher.find()) {
330330
return matcher.group(1);

0 commit comments

Comments
 (0)