mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
fix youtube urls validation
This commit is contained in:
parent
bdc63b4c35
commit
ac7bc02ec5
|
@ -181,7 +181,9 @@ module Youtube
|
||||||
|
|
||||||
# is it a video on youtube, with a query
|
# is it a video on youtube, with a query
|
||||||
query = uri.query
|
query = uri.query
|
||||||
if uri.host != "www.youtube.com" || uri.path != "/watch" || !query
|
|
||||||
|
if !uri || !query || !uri.host || uri.path != "/watch" ||
|
||||||
|
!uri.host.not_nil!.ends_with?("youtube.com")
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -204,8 +206,9 @@ module Youtube
|
||||||
|
|
||||||
|
|
||||||
# this is an internal endpoint to validate the video ID
|
# this is an internal endpoint to validate the video ID
|
||||||
response = HTTP::Client.get "https://www.youtube.com/get_video_info?video_id=#{vID}"
|
|
||||||
|
|
||||||
return response.body.includes?("status=ok")
|
response = HTTP::Client.get "https://www.youtube.com/oembed?format=json&url=#{url}"
|
||||||
|
|
||||||
|
return response.success?
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in a new issue