class Ripper
Module for all ripping methods
Public Class Methods
Method for converting stuff This method smells of :reek:TooManyStatements This method smells of :reek:LongParameterList This method smells of :reek:ControlParameter @param [String] ogg_file_accept OGG file as result accepted? @param [String] ffmpeg_binary Path to the ffmpeg binary @param [String] filenamein The original file @param [String] filename The transcoded file @return [String] ext
# File lib/youtube_dlhelper/ripper.rb, line 75 def self.convert(ogg_file_accept, ffmpeg_binary, filenamein, filename) # @note Transcoding the file to MP3 if ogg_file_accept == 'true' system("#{ffmpeg_binary} -i #{filenamein} -acodec vorbis -vn -ac 2 -aq 60 -strict -2 #{filename}.ogg") ext = 'ogg' #puts ext else system("#{ffmpeg_binary} -i #{filenamein} -acodec libmp3lame -ac 2 -ab 192k #{filename}.mp3") ext = 'mp3' #puts ext end return ext end
rubocop:disable Metrics/LineLength This method smells of :reek:TooManyStatements This method smells of :reek:LongParameterList Method for transcoding the *.m4a file to *.mp3. Output should be a valid MP3 file. @param [String] filename The filename @param [String] ext The file extension @param [String] ogg_file_accept OGG file as end file accepted? (true/false) @param [String] ffmpeg_binary Path to the ffmpeg binary @return [String] filename, ext
# File lib/youtube_dlhelper/ripper.rb, line 51 def self.rip(filename, ext, ogg_file_accept, ffmpeg_binary) # @note Initialize the file FFMPEG.ffmpeg_binary = ffmpeg_binary filenamein = "#{filename}.#{ext}" audio = FFMPEG::Movie.new(filenamein) puts 'Initializing finished'.colour(:green) # @note Checking if valid puts 'Checking if the movie is valid.'.colour(:yellow) audio.valid? puts 'Validated'.colour(:green) ext = convert(ogg_file_accept, ffmpeg_binary, filenamein, filename) puts 'Transcoded'.colour(:green) [filename, ext] end
rubocop:disable Metrics/AbcSize This method smells of :reek:TooManyStatements Checking which fileformat is present @param [String] filename The filename @param [String] ogg_file_accept OGG file as end file accepted? (true/false) @param [String] ffmpeg_binary Path to the ffmpeg binary
# File lib/youtube_dlhelper/ripper.rb, line 23 def self.rip_prepare(filename, ogg_file_accept, ffmpeg_binary) # @note Checks if a *.m4a file is present. Then it routes to Ripper.rip puts 'Checking if transcoding is needed. Depends on ogg_file_accept.'.colour(:yellow) if File.exist?("#{filename}.m4a") puts 'TRANSCODING TO MP3'.colour(:yellow) ext = 'm4a' rip(filename, ext, ogg_file_accept, ffmpeg_binary) elsif File.exist?("#{filename}.ogg") && ogg_file_accept == 'false' puts 'TRANSCODING TO MP3'.colour(:yellow) ext = 'ogg' rip(filename, ext, ogg_file_accept, ffmpeg_binary) elsif File.exist?("#{filename}.ogg") puts 'Already a ogg file. No transcoding needed'.colour(:green) else puts 'No transcoding needed'.colour(:green) end end