Class: Porni::Hubs::Parser::PornhubParser

Inherits:
Base
  • Object
show all
Defined in:
lib/porni/hubs/parser/pornhub_parser.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #invalid_attributes, parse_video

Constructor Details

This class inherits a constructor from Porni::Hubs::Parser::Base

Instance Method Details

#parse_videoObject



8
9
10
11
12
13
14
# File 'lib/porni/hubs/parser/pornhub_parser.rb', line 8

def parse_video
  if @body["video"]
    Porni::Video.new(valid_attributes)
  else
    Porni::Video.new(invalid_attributes)
  end
end

#valid_attributesObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/porni/hubs/parser/pornhub_parser.rb', line 16

def valid_attributes
  video = @body["video"]

  {
    duration: video["duration"],
    title: video["title"],
    thumb: video["default_thumb"] || video["thumb"],
    views: video["views"],
    channel: nil,
    tags: tags(video),
    pornstars: pornstars(video),
    valid: true,
    raw: @body
  }
end