Class: XxxRename::SiteClients::QueryGenerator::Vixen

Inherits:
Base
  • Object
show all
Extended by:
Utils
Defined in:
lib/xxx_rename/site_clients/query_generator/vixen.rb

Constant Summary collapse

PATTERN_1 =
"%actors [T] %title [S] %collection [ID] %id"

Constants included from Utils

Utils::RETRIABLE_ERRORS

Instance Attribute Summary

Attributes inherited from Base

#filename, #processed_file_patterns, #source_pattern

Class Method Summary collapse

Methods included from Utils

adjust_apostrophe, api_error, handle_response!

Methods inherited from Base

generic_generate, #initialize, #parse

Constructor Details

This class inherits a constructor from XxxRename::SiteClients::QueryGenerator::Base

Class Method Details

.generate(filename, source_format) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/xxx_rename/site_clients/query_generator/vixen.rb', line 13

def self.generate(filename, source_format)
  if (data = new(filename, source_format, [PATTERN_1]).parse)
    SearchParameters.new(**data.to_h.slice(:title, :id, :female_actors, :collection, :male_actors, :actors))
  else
    re_match = filename.match(Constants::VIXEN_MEDIA_ORIGINAL_FILE_REGEX_1) ||
               filename.match(Constants::VIXEN_MEDIA_ORIGINAL_FILE_REGEX_2)
    return if re_match.nil?

    SearchParameters.new(id: re_match[:id], collection: re_match[:collection])
  end
end