class RenameMovies::InfoExtractor

Constants

AUDIO_QUALITIES
AUDIO_QUALITY_MATCHERS
CLEAN_KEYWORDS
CLEAN_NAME_MATCHERS
ENCODING_STANDARDS
L_SEPARATORS
RESOLUTIONS
R_SEPARATORS
STORAGE_FORMATS
VIDEO_QUALITY_MATCHERS
YEAR_MATCHERS

Public Class Methods

extract(movie_data) click to toggle source
# File lib/rename_movies/info_extractor.rb, line 33
def self.extract(movie_data)
  @movie_data = movie_data

  extract_year
  extract_video_quality
  extract_audio_quality
  extract_name

  @movie_data
end

Private Class Methods

extract_audio_quality() click to toggle source
# File lib/rename_movies/info_extractor.rb, line 62
def self.extract_audio_quality
  AUDIO_QUALITY_MATCHERS.each do |format_regex|
    match = format_regex.match(@movie_data[:original_name])
    @movie_data[:audio_quality] = match[:audio_quality] if match
  end
end
extract_name() click to toggle source
# File lib/rename_movies/info_extractor.rb, line 69
def self.extract_name
  @movie_data[:new_name] = @movie_data[:original_name]
  @movie_data[:new_name] = @movie_data[:new_name].gsub(/\W+/, " ")
  CLEAN_NAME_MATCHERS.each do |format_regex|
    @movie_data[:new_name] = @movie_data[:new_name].sub(format_regex, "")
  end
  @movie_data[:new_name] = @movie_data[:new_name].split.join(" ")
end
extract_video_quality() click to toggle source
# File lib/rename_movies/info_extractor.rb, line 53
def self.extract_video_quality
  VIDEO_QUALITY_MATCHERS.each do |format_regex|
    match = format_regex.match(@movie_data[:original_name])
    @movie_data[:encoding_standard] = match[:encoding_standard] if match && (match[:encoding_standard] rescue nil)
    @movie_data[:storage_format] = match[:storage_format] if match && (match[:storage_format] rescue nil)
    @movie_data[:resolution] = match[:resolution] if match && (match[:resolution] rescue nil)
  end
end
extract_year() click to toggle source
# File lib/rename_movies/info_extractor.rb, line 46
def self.extract_year
  YEAR_MATCHERS.each do |format_regex|
    match = format_regex.match(@movie_data[:original_name])
    @movie_data[:year] = match[:year] if match
  end
end