xclient 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 921a9aaf3a66bb78050d7a4181388594c2b4f09a
4
+ data.tar.gz: 3d017060ecc16321305abcfa16747ce9ae1c4e55
5
+ SHA512:
6
+ metadata.gz: 0c400d965c3244c6b9d890e502ccd1da18079e77e45fb29a7eb78cca5fee7e820520e84c446e8bba9237dd4e990fedc1a9f79985ecb788f13f574552c1e6bd4d
7
+ data.tar.gz: 3f51480bfbd96fd5a437b48f520a0b611abf1362b14741c2770eb963994b34dcbd3cc91ae794a86600b69c077b439b639116f75f33262594d7ec5c513a89f89d
@@ -0,0 +1,17 @@
1
+ require "xclient/version"
2
+ require "xclient/client"
3
+ require "xclient/passer_error"
4
+
5
+ require "xclient/xvideos"
6
+
7
+ require 'nokogiri'
8
+ require 'open-uri'
9
+
10
+ module Xclient
11
+ XVIDEOS_HOST = "xvideos.com"
12
+
13
+ def self.open(url)
14
+ return Xvideos.parse(url) if url.include?(XVIDEOS_HOST)
15
+ raise PasserError, "unkown host to #{url}"
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module Xclient
2
+ class Client
3
+ attr_accessor :embed, :thumbs, :title, :tags, :host, :url
4
+
5
+ def initialize(params = {})
6
+ params.each do |key, value|
7
+ self.send("#{key}=", value)
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ module Xclient
2
+ class PasserError < StandardError
3
+ def initialize(message)
4
+ super(message)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module Xclient
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,47 @@
1
+ module Xclient
2
+ module Xvideos
3
+ def self.parse(url)
4
+ begin
5
+ @doc = Nokogiri::HTML(open(url))
6
+ Client.new(
7
+ title: title,
8
+ thumbs: thumbs,
9
+ tags: tags,
10
+ embed: embed,
11
+ host: Xclient::XVIDEOS_HOST,
12
+ url: url
13
+ )
14
+ rescue
15
+ raise PasserError, "passer error"
16
+ end
17
+ end
18
+
19
+ private
20
+ def self.title
21
+ @doc.css('#main > h2').first.children.first.text.strip
22
+ end
23
+
24
+ def self.thumbs
25
+ thumb = []
26
+ embed_attrs = @doc.css('embed').first.attr('flashvars').split('&')
27
+ main_thumb_index = embed_attrs.index{|s| s.include?("url_bigthumb=")}
28
+ main_thumb = embed_attrs[main_thumb_index].split("=").last
29
+
30
+ thumb << main_thumb
31
+ end
32
+
33
+ def self.embed
34
+ @doc.css('#tabEmbed > input').first.attr :value
35
+ end
36
+
37
+ def self.tags
38
+ tags = []
39
+ @doc.css('.video-tags > a').each do |link_tag|
40
+ tags << link_tag.text
41
+ end
42
+ # remove 'more tags'
43
+ tags.pop
44
+ tags
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xclient
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Gilderlan Braz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.4'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.3
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.3
41
+ description: Ruby interface for porn sites
42
+ email: contato@gilderlanbraz.net
43
+ executables: []
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/xclient.rb
48
+ - lib/xclient/client.rb
49
+ - lib/xclient/passer_error.rb
50
+ - lib/xclient/version.rb
51
+ - lib/xclient/xvideos.rb
52
+ homepage: https://github.com/gilderlanbraz/xclient
53
+ licenses:
54
+ - MIT
55
+ metadata: {}
56
+ post_install_message:
57
+ rdoc_options: []
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubyforge_project:
72
+ rubygems_version: 2.6.2
73
+ signing_key:
74
+ specification_version: 4
75
+ summary: Xvideos Client
76
+ test_files: []