Fix bug.
This commit is contained in:
parent
986cca8c5c
commit
1ae2e0b103
|
@ -2,48 +2,57 @@ $:.push File.expand_path("../lib", __FILE__)
|
||||||
|
|
||||||
# Maintain your gem's version:
|
# Maintain your gem's version:
|
||||||
require "ad_banner/version"
|
require "ad_banner/version"
|
||||||
app_path = File.expand_path(__dir__)
|
bundle_update_flag = ARGV[0]=='update' || ARGV[0]=='install'
|
||||||
template_path = ENV['PWD'] + '/app/templates'
|
if bundle_update_flag
|
||||||
all_template = Dir.glob(template_path+'/*/')
|
require "fileutils"
|
||||||
puts 'copying module'
|
app_path = File.expand_path(__dir__)
|
||||||
all_template.each do |folder|
|
template_path = ENV['PWD'] + '/app/templates'
|
||||||
if folder.split('/')[-1] != 'mobile'
|
all_template = Dir.glob(template_path+'/*/')
|
||||||
begin
|
puts 'copying module'
|
||||||
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
all_template.each do |folder|
|
||||||
rescue
|
if folder.split('/')[-1] != 'mobile'
|
||||||
puts 'error copy'
|
begin
|
||||||
end
|
system ('cp -r '+ app_path + '/modules/ ' + folder)
|
||||||
end
|
rescue
|
||||||
end
|
puts 'error copy'
|
||||||
if Dir.exist?(ENV['PWD'] + "/public/uploads/ad_image")
|
|
||||||
puts "Fixing video blocked by ad block..."
|
|
||||||
begin
|
|
||||||
system ("mv #{ENV['PWD']}/public/uploads/ad_image #{ENV['PWD']}/public/uploads/banner_image")
|
|
||||||
rescue
|
|
||||||
puts 'error moving'
|
|
||||||
end
|
|
||||||
puts "Finish fixing!"
|
|
||||||
end
|
|
||||||
#download ffmpeg
|
|
||||||
begin
|
|
||||||
destination = ENV['PWD']+'/tmp/ffmpeg'
|
|
||||||
if Dir[destination].length==0
|
|
||||||
require 'open-uri'
|
|
||||||
download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip')
|
|
||||||
save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip"
|
|
||||||
IO.copy_stream(download, save_zip_name)
|
|
||||||
require 'zip'
|
|
||||||
FileUtils.mkdir_p(destination)
|
|
||||||
Zip::File.open(save_zip_name) do |zip_file|
|
|
||||||
zip_file.each do |f|
|
|
||||||
fpath = File.join(destination, f.name)
|
|
||||||
zip_file.extract(f, fpath) unless File.exist?(fpath)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
rescue => e
|
if Dir.exist?(ENV['PWD'] + "/public/uploads/ad_image")
|
||||||
FileUtils.rmdir(destination) rescue nil
|
puts "Fixing video blocked by ad block..."
|
||||||
puts ["download ffmpeg failed",e]
|
begin
|
||||||
|
system ("mv #{ENV['PWD']}/public/uploads/ad_image #{ENV['PWD']}/public/uploads/banner_image")
|
||||||
|
rescue
|
||||||
|
puts 'error moving'
|
||||||
|
end
|
||||||
|
puts "Finish fixing!"
|
||||||
|
end
|
||||||
|
#download ffmpeg
|
||||||
|
begin
|
||||||
|
destination = ENV['PWD']+'/tmp/ffmpeg'
|
||||||
|
if Dir[destination].length==0
|
||||||
|
FileUtils.mkdir_p("#{ENV['PWD']}/tmp")
|
||||||
|
require 'open-uri'
|
||||||
|
if RUBY_VERSION.to_f >= 2.7
|
||||||
|
download = URI.open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip')
|
||||||
|
else
|
||||||
|
download = open('https://github.com/ffbinaries/ffbinaries-prebuilt/releases/download/v4.2/ffmpeg-4.2-linux-64.zip')
|
||||||
|
end
|
||||||
|
save_zip_name = "#{ENV['PWD']}/tmp/ffmpeg-4.2-linux-64.zip"
|
||||||
|
IO.copy_stream(download, save_zip_name)
|
||||||
|
require 'zip'
|
||||||
|
FileUtils.mkdir_p(destination)
|
||||||
|
Zip::File.open(save_zip_name) do |zip_file|
|
||||||
|
zip_file.each do |f|
|
||||||
|
fpath = File.join(destination, f.name)
|
||||||
|
zip_file.extract(f, fpath) unless File.exist?(fpath)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue => e
|
||||||
|
FileUtils.rmdir(destination) rescue nil
|
||||||
|
puts ["download ffmpeg failed",e]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
#./ffmpeg -i 2.mp4 -c:v libvpx-vp9 -crf 35 -b:v 0 -b:a 96k -c:a libopus -filter:v fps=20 output.webm -cpu-used 4
|
#./ffmpeg -i 2.mp4 -c:v libvpx-vp9 -crf 35 -b:v 0 -b:a 96k -c:a libopus -filter:v fps=20 output.webm -cpu-used 4
|
||||||
# Describe your gem and declare its dependencies:
|
# Describe your gem and declare its dependencies:
|
||||||
|
|
Loading…
Reference in New Issue