This commit is contained in:
BoHung Chiu 2022-05-22 19:02:20 +08:00
parent c3cfada5d7
commit bf6234cdbc
1 changed files with 9 additions and 7 deletions

View File

@ -1,13 +1,15 @@
Rails.application.routes.draw do
require 'fileutils'
get 'ad_banners/widget'
Thread.new do
ad_images = AdImage.where(:video_file.ne=>nil,:video_snapshot=>nil).to_a
ad_images.each do |ad_image|
ad_image[:video_snapshot] = File.basename(ad_image.video_file.file.path).split(/\.[^.]+$/)[0] + ".jpg"
FileUtils.mkdir_p(File.dirname(ad_image.video_snapshot.file.path))
system("tmp/ffmpeg/ffmpeg -i #{ad_image.video_file.file.path} -vframes 1 #{ad_image.video_snapshot.file.path}")
ad_image.save
if ENV['worker_num']=='0' && File.basename($0) != 'rake' && !Rails.const_defined?('Console')
Thread.new do
ad_images = AdImage.where(:video_file.ne=>nil,:video_snapshot=>nil).to_a
ad_images.each do |ad_image|
ad_image[:video_snapshot] = File.basename(ad_image.video_file.file.path).split(/\.[^.]+$/)[0] + ".jpg"
FileUtils.mkdir_p(File.dirname(ad_image.video_snapshot.file.path))
system("tmp/ffmpeg/ffmpeg -i #{ad_image.video_file.file.path} -vframes 1 #{ad_image.video_snapshot.file.path}")
ad_image.save
end
end
end
locales = Site.find_by(site_active: true).in_use_locales rescue I18n.available_locales