change youtube thumb source url to https.

This commit is contained in:
BoHung Chiu 2023-04-10 17:22:44 +08:00
parent 16b573bf1e
commit 9e9f2959bc
1 changed files with 9 additions and 2 deletions

View File

@ -71,8 +71,15 @@ class VideoImage
end
if self.is_youtube
begin
youtube_img_url = "http:"+self.youtube_thumb
snapshot_content = Net::HTTP.get_response(URI.parse(youtube_img_url)).body rescue nil
youtube_img_url = "https:"+self.youtube_thumb
uri = URI.parse(youtube_img_url)
req = Net::HTTP::Get.new(uri.path)
res = Net::HTTP.start( uri.host, uri.port,
:use_ssl => (uri.scheme == 'https'),
:verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https|
https.request(req)
end
snapshot_content = res.body rescue nil #Net::HTTP.get_response(URI.parse(youtube_img_url)).body rescue nil
if snapshot_content
self[:video_snapshot] = '0.jpg'
snapshot_file_path = self.video_snapshot.file.path