xvideos_helper 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c8866829e8139d2674b4b928ac83a929253ff867
4
+ data.tar.gz: 66341f52dec434d92e03eabe8c8336bf1382f629
5
+ SHA512:
6
+ metadata.gz: 82ab7f947d46f710249f1f1f2fbc11b3425de2938381c28118c23d8c189ca3f29a486396c9b8b419b9615bbca363642ddaf4173e88ffbb0a0ffd84dbda66d182
7
+ data.tar.gz: 11cb38a443852ceaa98281f00635aedde22dc137a4449969513e758fd3bb5817845ea40fe853b39789413d1ad84362e559818ea8d7305ae32c5bc3fff1d443ee
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ /vendor
data/README.md CHANGED
@@ -1,12 +1,21 @@
1
1
  # XvideosHelper
2
2
 
3
- XvideosHelper is a gem to support for adult site creater.This gem provides xvideo's data like movie url or movie page url for you with scraping the site easily.
3
+ XvideosHelper is a gem to support for adult site creater.
4
+
5
+ This gem provides xvideo's data like movie url or movie page url for you with scraping the site easily.
6
+
7
+ So, if you use this gem in production, please cache the results.
8
+
9
+ ### Notice
10
+
11
+ Now, there is the html difference between www.xvideos.com and **.xvideos.com.
12
+
13
+ XvideosHelper only supports www.xvideos.com.
4
14
 
5
15
  ## Installation
6
16
 
7
17
  Add this line to your application's Gemfile:
8
18
 
9
- gem 'nokogiri'
10
19
  gem 'xvideos_helper'
11
20
 
12
21
  And then execute:
@@ -35,7 +44,7 @@ Or install it yourself as:
35
44
  {
36
45
  0 => {
37
46
  "movie_url" => "http://flashservice.xvideos.com/embedframe/6243093",
38
- "movie_page_url"=> "http://jp.xvideos.com/video2017657/0/jp_kyoko_ayana_qc05-02_by_zeus4096_asian_cumshots_asian_swallow_japanese_chinese",
47
+ "movie_page_url"=> "http://www.xvideos.com/video2017657/0/jp_kyoko_ayana_qc05-02_by_zeus4096_asian_cumshots_asian_swallow_japanese_chinese",
39
48
  "movie_thumnail_url"=> "http://img100.xvideos.com/videos/thumbs/46/a0/69/46a069b72731e3c22ddf917d9fb1cbca/46a069b72731e3c22ddf917d9fb1cbca.4.jpg",
40
49
  "movie_id"=>"9750364",
41
50
  "description"=>"Jp Kyoko Ayana Qc05-02 By Zeus4096 asian ...",
@@ -65,7 +74,7 @@ Or install it yourself as:
65
74
  {
66
75
  0 => {
67
76
  tag_name => 'sex'
68
- tag_url => 'http://jp.xvideos.com/tags/sex'
77
+ tag_url => 'http://www.xvideos.com/tags/sex'
69
78
  tag_count => 320165
70
79
  },
71
80
  1 => {
@@ -101,22 +110,23 @@ Or install it yourself as:
101
110
  movie_data = adult.movies_of('http://www.xvideos.com')
102
111
  ```
103
112
 
104
- - Get movie information from all tag pages.
113
+ - Get movie information from 10 tag pages.
105
114
 
106
115
  ```ruby
107
116
  adult = XvideosHelper::Client.new
108
- tags_data = sexy.tag_data_lists
117
+ adult.tags_limit = 10
118
+ tags_data = adult.tag_data_lists
109
119
  tag_movie_data = []
110
- tags_data.each do |tag|
111
- tag_movie_data << adult.movies_of("http://www.xvideos.com/tags/#{tag}")
120
+ tags_data.each do |k,v|
121
+ tag_movie_data << adult.movies_of("http://www.xvideos.com/tags/#{v["tag_name"]}")
112
122
  end
113
123
  ```
114
124
 
115
125
  - Get popular movie information.
116
126
 
117
127
  ```ruby
118
- adult = XvideosHelper::Client.new
119
- movie_data = adult.movies_of("http://www.xvideos.com/hits/")
128
+ adult = XvideosHelper::Client.new
129
+ movie_data = adult.movies_of("http://www.xvideos.com/best/")
120
130
  ```
121
131
 
122
132
  ## Contributing
@@ -1,3 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require "bundler/setup"
3
4
  require 'xvideos_helper'
5
+
6
+ require "pry"
7
+ Pry.start
@@ -7,7 +7,7 @@ module XvideosHelper
7
7
  attr_accessor :domain, :tag_url
8
8
  def initialize
9
9
  @crawler = XvideosHelper::Crawler.new
10
- @domain ||= Env::XVIDES_URL_JP
10
+ @domain ||= Env::XVIDES_URL_WWW
11
11
  @tag_url ||= Env::XVIDES_TAG_URL
12
12
  end
13
13
 
@@ -6,7 +6,7 @@ module XvideosHelper
6
6
  class Crawler
7
7
  attr_accessor :movies_limit,:tags_limit
8
8
  def initialize
9
- @domain ||= Env::XVIDES_URL_JP
9
+ @domain ||= Env::XVIDES_URL_WWW
10
10
  @iframe_url ||= Env::XVIDES_IFRAME_URL
11
11
  @movies_limit ||= -1
12
12
  @tags_limit ||= -1
@@ -41,7 +41,7 @@ private
41
41
  parsed_data = {}
42
42
  index = 0
43
43
 
44
- data.xpath('//div[@class="thumbBlock"]/div[@class="thumbInside"]').each do |post|
44
+ data.search(".thumb-block .thumb-inside").each do |post|
45
45
  begin
46
46
  # limit
47
47
  break if @movies_limit == index
@@ -56,7 +56,6 @@ private
56
56
  post.search('script').each do |elm|
57
57
  parsed_data[index]['movie_page_url'] = @domain + (elm.children[0].content.match(/href="(.+?)">/))[1]
58
58
  parsed_data[index]['movie_thumnail_url'] = (elm.children[0].content.match(/src="(.+?)"/))[1]
59
- parsed_data[index]['description'] = (elm.children[0].content.match(/<p><a href=".+">(.+)<\/a><\/p>/))[1]
60
59
  end
61
60
 
62
61
  # movie_id
@@ -66,6 +65,7 @@ private
66
65
  parsed_data[index]['movie_url'] = @iframe_url + (parsed_data[index]['movie_page_url'].match(/\/video(\d+)\/.*/))[1]
67
66
 
68
67
  # description
68
+ parsed_data[index]['description'] = ''
69
69
  post.search('p/a').each do |a|
70
70
  parsed_data[index]['description'] = a.inner_text
71
71
  end
@@ -1,6 +1,6 @@
1
1
  # coding: utf-8
2
2
  module Env
3
- XVIDES_URL_JP = 'http://jp.xvideos.com'
4
- XVIDES_TAG_URL = "#{XVIDES_URL_JP}/tags"
3
+ XVIDES_URL_WWW = 'http://www.xvideos.com'
4
+ XVIDES_TAG_URL = "#{XVIDES_URL_WWW}/tags"
5
5
  XVIDES_IFRAME_URL = 'http://flashservice.xvideos.com/embedframe/'
6
6
  end
@@ -1,3 +1,3 @@
1
1
  module XvideosHelper
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -1,10 +1,11 @@
1
+ require 'pry'
1
2
  require 'spec_helper'
2
3
 
3
4
  describe "XvideosHelper::Client" do
4
5
  context 'movies_of' do
5
6
  it 'return valid values' do
6
7
  @xh = XvideosHelper::Client.new
7
- lists = @xh.movies_of("http://jp.xvideos.com/")
8
+ lists = @xh.movies_of("http://www.xvideos.com/")
8
9
  lists.count.should > 0
9
10
  lists.each do |key,list|
10
11
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -19,7 +20,7 @@ describe "XvideosHelper::Client" do
19
20
 
20
21
  it 'raises error if invalid url' do
21
22
  @xh = XvideosHelper::Client.new
22
- lambda {@xh.movies_of("invalid://jp.xvideos.com/")}.should raise_error
23
+ lambda {@xh.movies_of("invalid://www.xvideos.com/")}.should raise_error
23
24
  end
24
25
  end
25
26
 
@@ -45,7 +46,7 @@ describe "XvideosHelper::Client" do
45
46
  it 'changes limit to 1' do
46
47
  @xh = XvideosHelper::Client.new
47
48
  @xh.movies_limit = 1
48
- lists = @xh.movies_of("http://jp.xvideos.com/")
49
+ lists = @xh.movies_of("http://www.xvideos.com/")
49
50
  lists.count.should == 1
50
51
  lists.each do |key,list|
51
52
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -61,7 +62,7 @@ describe "XvideosHelper::Client" do
61
62
  it 'changes limit to 0' do
62
63
  @xh = XvideosHelper::Client.new
63
64
  @xh.movies_limit = 0
64
- lists = @xh.movies_of("http://jp.xvideos.com/")
65
+ lists = @xh.movies_of("http://www.xvideos.com/")
65
66
  lists.count.should == 0
66
67
  lists.each do |key,list|
67
68
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -4,7 +4,7 @@ describe "XvideosHelper::Crawler" do
4
4
  context 'get_data_from' do
5
5
  it 'return valid movie information' do
6
6
  @xh = XvideosHelper::Crawler.new
7
- lists = @xh.get_data_from("http://jp.xvideos.com/",'movie')
7
+ lists = @xh.get_data_from("http://www.xvideos.com/",'movie')
8
8
  lists.count.should > 0
9
9
  lists.each do |key,list|
10
10
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -20,7 +20,7 @@ describe "XvideosHelper::Crawler" do
20
20
  it 'return 0 movie information' do
21
21
  @xh = XvideosHelper::Crawler.new
22
22
  @xh.movies_limit = 0
23
- lists = @xh.get_data_from("http://jp.xvideos.com/",'movie')
23
+ lists = @xh.get_data_from("http://www.xvideos.com/",'movie')
24
24
  lists.count.should == 0
25
25
  lists.each do |key,list|
26
26
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -36,7 +36,7 @@ describe "XvideosHelper::Crawler" do
36
36
  it 'return 1 movie information' do
37
37
  @xh = XvideosHelper::Crawler.new
38
38
  @xh.movies_limit = 1
39
- lists = @xh.get_data_from("http://jp.xvideos.com/",'movie')
39
+ lists = @xh.get_data_from("http://www.xvideos.com/",'movie')
40
40
  lists.count.should == 1
41
41
  lists.each do |key,list|
42
42
  list["movie_url"].should match(/^http:\/\/.+\/\d+$/)
@@ -51,7 +51,7 @@ describe "XvideosHelper::Crawler" do
51
51
 
52
52
  it 'return valid tag lists' do
53
53
  @xh = XvideosHelper::Crawler.new
54
- lists = @xh.get_data_from("http://jp.xvideos.com/tags",'taglist')
54
+ lists = @xh.get_data_from("http://www.xvideos.com/tags",'taglist')
55
55
  lists.count.should > 0
56
56
  lists.each do |key,list|
57
57
  list['tag_name'].should_not be_nil
@@ -63,7 +63,7 @@ describe "XvideosHelper::Crawler" do
63
63
  it 'return 0 tag list' do
64
64
  @xh = XvideosHelper::Crawler.new
65
65
  @xh.tags_limit = 0
66
- lists = @xh.get_data_from("http://jp.xvideos.com/tags",'taglist')
66
+ lists = @xh.get_data_from("http://www.xvideos.com/tags",'taglist')
67
67
  lists.count.should == 0
68
68
  lists.each do |key,list|
69
69
  list['tag_name'].should_not be_nil
@@ -75,7 +75,7 @@ describe "XvideosHelper::Crawler" do
75
75
  it 'return 1 tag list' do
76
76
  @xh = XvideosHelper::Crawler.new
77
77
  @xh.tags_limit = 1
78
- lists = @xh.get_data_from("http://jp.xvideos.com/tags",'taglist')
78
+ lists = @xh.get_data_from("http://www.xvideos.com/tags",'taglist')
79
79
  lists.count.should == 1
80
80
  lists.each do |key,list|
81
81
  list['tag_name'].should_not be_nil
@@ -86,17 +86,17 @@ describe "XvideosHelper::Crawler" do
86
86
 
87
87
  it 'return empty object if undifined name or the other objects' do
88
88
  @xh = XvideosHelper::Crawler.new
89
- lists = @xh.get_data_from("http://jp.xvideos.com/",'undifined_name')
89
+ lists = @xh.get_data_from("http://www.xvideos.com/",'undifined_name')
90
90
  lists.should == {}
91
- lists = @xh.get_data_from("http://jp.xvideos.com/",{})
91
+ lists = @xh.get_data_from("http://www.xvideos.com/",{})
92
92
  lists.should == {}
93
- lists = @xh.get_data_from("http://jp.xvideos.com/",[])
93
+ lists = @xh.get_data_from("http://www.xvideos.com/",[])
94
94
  lists.should == {}
95
95
  end
96
96
 
97
97
  it 'raises error if invalid url' do
98
98
  @xh = XvideosHelper::Crawler.new
99
- lambda {@xh.movies_of("invalid://jp.xvideos.com/",'movie')}.should raise_error
99
+ lambda {@xh.movies_of("invalid://www.xvideos.com/",'movie')}.should raise_error
100
100
  end
101
101
  end
102
102
 
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["YuheiNakasaka"]
10
10
  spec.email = ["yuhei.nakasaka@gmail.com"]
11
11
  spec.description = %q{xvideos_helper is a gem to support for adult site creater.}
12
- spec.summary = %q{This gem get movie infomation from xvideo.com.}
12
+ spec.summary = %q{This gem gets movie infomation from www.xvideos.com.}
13
13
  spec.homepage = "https://github.com/YuheiNakasaka/xvideos_helper"
14
14
  spec.license = "MIT"
15
15
 
@@ -18,8 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
+ spec.add_dependency "nokogiri"
21
22
  spec.add_development_dependency "bundler", "~> 1.3"
22
23
  spec.add_development_dependency "rake"
23
24
  spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "nokogiri"
25
+ spec.add_development_dependency "pry"
25
26
  end
metadata CHANGED
@@ -1,78 +1,83 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xvideos_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
5
- prerelease:
4
+ version: 0.0.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - YuheiNakasaka
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-11-30 00:00:00.000000000 Z
11
+ date: 2016-03-22 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: bundler
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
- - - ~>
31
+ - - "~>"
20
32
  - !ruby/object:Gem::Version
21
33
  version: '1.3'
22
34
  type: :development
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
- - - ~>
38
+ - - "~>"
28
39
  - !ruby/object:Gem::Version
29
40
  version: '1.3'
30
41
  - !ruby/object:Gem::Dependency
31
42
  name: rake
32
43
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
44
  requirements:
35
- - - ! '>='
45
+ - - ">="
36
46
  - !ruby/object:Gem::Version
37
47
  version: '0'
38
48
  type: :development
39
49
  prerelease: false
40
50
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
51
  requirements:
43
- - - ! '>='
52
+ - - ">="
44
53
  - !ruby/object:Gem::Version
45
54
  version: '0'
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: rspec
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
- name: nokogiri
70
+ name: pry
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ! '>='
73
+ - - ">="
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ! '>='
80
+ - - ">="
76
81
  - !ruby/object:Gem::Version
77
82
  version: '0'
78
83
  description: xvideos_helper is a gem to support for adult site creater.
@@ -83,9 +88,9 @@ executables:
83
88
  extensions: []
84
89
  extra_rdoc_files: []
85
90
  files:
86
- - .gitignore
87
- - .rspec
88
- - .travis.yml
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
89
94
  - Gemfile
90
95
  - LICENSE.txt
91
96
  - README.md
@@ -104,34 +109,27 @@ files:
104
109
  homepage: https://github.com/YuheiNakasaka/xvideos_helper
105
110
  licenses:
106
111
  - MIT
112
+ metadata: {}
107
113
  post_install_message:
108
114
  rdoc_options: []
109
115
  require_paths:
110
116
  - lib
111
117
  required_ruby_version: !ruby/object:Gem::Requirement
112
- none: false
113
118
  requirements:
114
- - - ! '>='
119
+ - - ">="
115
120
  - !ruby/object:Gem::Version
116
121
  version: '0'
117
- segments:
118
- - 0
119
- hash: 3698011074387602631
120
122
  required_rubygems_version: !ruby/object:Gem::Requirement
121
- none: false
122
123
  requirements:
123
- - - ! '>='
124
+ - - ">="
124
125
  - !ruby/object:Gem::Version
125
126
  version: '0'
126
- segments:
127
- - 0
128
- hash: 3698011074387602631
129
127
  requirements: []
130
128
  rubyforge_project:
131
- rubygems_version: 1.8.24
129
+ rubygems_version: 2.4.5
132
130
  signing_key:
133
- specification_version: 3
134
- summary: This gem get movie infomation from xvideo.com.
131
+ specification_version: 4
132
+ summary: This gem gets movie infomation from www.xvideos.com.
135
133
  test_files:
136
134
  - spec/lib/client_spec.rb
137
135
  - spec/lib/crawler_spec.rb