From 53e3b146f583f0566d7ace4b108876e0e3d2b7e0 Mon Sep 17 00:00:00 2001 From: Fabien Freling Date: Thu, 27 Feb 2014 21:27:12 +0100 Subject: [PATCH] Extend youtube regexp. Cheesebot can now recognize youtube urls formatted like this: - http://www.youtube.com - https://www.youtube.com - http://youtube.com - www.youtube.com - youtu.be --- ocaml/main.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ocaml/main.ml b/ocaml/main.ml index 1317303..a04c3ca 100644 --- a/ocaml/main.ml +++ b/ocaml/main.ml @@ -14,12 +14,13 @@ Http_client.Convenience.configure_pipeline (* Regexp required here *) let is_youtube_url url = - let regexp = Str.regexp "https://www.youtube.com/.+" in + let regexp = Str.regexp "\\(https?\\://\\)?\\(www\\.\\)?\\(youtube\\.com\\)\\|\\(youtu\\.be\\)/.+" in Str.string_match regexp url 0 let get_body url = try Http_client.Convenience.http_get url with + | Http_client.Http_error e -> "http error /o\\" | Failure f -> "http fail lol"