Class: XxxRename::SiteClients::Goodporn

Inherits:
Base
  • Object
show all
Includes:
HTTParty
Defined in:
lib/xxx_rename/site_clients/goodporn.rb

Constant Summary collapse

HEADLINE_REGEX =

rubocop:disable Style/RegexpLiteral

/
(?<collection>[^-]*)                          # Collection
\s-\s                                         # Separator
(?<scene_title>.*)                            # Scene Title
\s-\s                                         # Separator
(?<date_released>\d\d\/\d\d\/\d\d\d\d)        # Release Date
/x.freeze
BRAZZERS_LIVE_HEADLINE_REGEX =

rubocop:disable Style/RegexpLiteral

/
-\s                                           # Prefix only for Brazzers Live
(?<collection>[^-]*)                          # Collection
:\s?                                          # Scene Separator
(?<scene_title>[^-]*)                         # Scene Title
\s-\s                                         # Separator
(?<date_released>\d\d\/\d\d\/\d\d\d\d)        # Release Date
/x.freeze

Constants included from Utils

Utils::RETRIABLE_ERRORS

Instance Attribute Summary

Attributes inherited from Base

#config, #source_format

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Configuration

included

Methods included from Utils

#adjust_apostrophe, #api_error, #handle_response!

Constructor Details

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

Instance Method Details

#search(filename, **_opts) ⇒ XxxRename::Data::SceneData

rubocop:disable Metrics/CyclomaticComplexity

Parameters:

  • filename (String)

Returns:

Raises:



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/xxx_rename/site_clients/goodporn.rb', line 39

def search(filename, **_opts)
  pattern = pattern(filename) || raise(Errors::NoMatchError.new(Errors::NoMatchError::ERR_NO_METADATA, filename))

  doc = Nokogiri::HTML request_search_html(pattern.gsub("-", " "))
  link = search_result_links(doc).select { |url| url.include? pattern }.first
  raise Errors::NoMatchError.new(Errors::NoMatchError::ERR_NO_METADATA, filename) if link.nil?

  scene = Nokogiri::HTML request_video_html(link)
   = scene.css("#tab_video_info").css(".info").children.select { |x| x.children.length > 1 }
  actors_hash = actors_hash(actors())
  match = headline(scene).match(HEADLINE_REGEX) || headline(scene).match(BRAZZERS_LIVE_HEADLINE_REGEX)
  raise Errors::NoMatchError.new(Errors::NoMatchError::ERR_NO_RESULT, filename) if match.nil? || actors_hash.nil?

  Data::SceneData.new(
    {
      collection: match[:collection],
      collection_tag: "GP",
      title: match[:scene_title],
      id: nil,
      date_released: Time.strptime(match[:date_released], "%m/%d/%Y")
    }.merge(actors_hash)
  )
end