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
master
Fabien Freling 2014-02-27 21:27:12 +01:00
parent 0f095addec
commit 53e3b146f5
1 changed files with 2 additions and 1 deletions

View File

@ -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"