nicoscraper 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -13
- data/README.md +37 -27
- data/VERSION +1 -1
- data/lib/classes/connector.rb +43 -161
- data/lib/classes/movie.rb +46 -45
- data/lib/classes/mylist.rb +111 -141
- data/lib/classes/parser.rb +343 -264
- data/lib/classes/searcher.rb +4 -4
- data/lib/classes/tools.rb +11 -0
- data/lib/config/mylist.rb +5 -0
- data/lib/nicoscraper.rb +1 -1
- data/nicoscraper.gemspec +4 -8
- data/test/mylist_getmoreinfo_spec.rb +122 -0
- data/test/mylist_spec.rb +7 -3
- metadata +17 -37
data/lib/classes/tools.rb
CHANGED
@@ -12,4 +12,15 @@ def mixinND(targetObj, overWriteObj)
|
|
12
12
|
output = overWriteObj
|
13
13
|
end
|
14
14
|
return output
|
15
|
+
end
|
16
|
+
|
17
|
+
class Numeric
|
18
|
+
def roundoff(d=0)
|
19
|
+
x = 10**d
|
20
|
+
if self < 0
|
21
|
+
(self * x - 0.5).ceil.quo(x)
|
22
|
+
else
|
23
|
+
(self * x + 0.5).floor.quo(x)
|
24
|
+
end
|
25
|
+
end
|
15
26
|
end
|
data/lib/nicoscraper.rb
CHANGED
data/nicoscraper.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{nicoscraper}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = [%q{Masami Yonehara}]
|
12
|
-
s.date = %q{2011-10-
|
12
|
+
s.date = %q{2011-10-17}
|
13
13
|
s.description = %q{It scrape movies and mylists of Niconico douga.
|
14
14
|
}
|
15
15
|
s.email = %q{zeitdiebe@gmail.com}
|
@@ -34,10 +34,12 @@ Gem::Specification.new do |s|
|
|
34
34
|
"lib/classes/parser.rb",
|
35
35
|
"lib/classes/searcher.rb",
|
36
36
|
"lib/classes/tools.rb",
|
37
|
+
"lib/config/mylist.rb",
|
37
38
|
"lib/config/wait.rb",
|
38
39
|
"lib/nicoscraper.rb",
|
39
40
|
"nicoscraper.gemspec",
|
40
41
|
"test/movie_spec.rb",
|
42
|
+
"test/mylist_getmoreinfo_spec.rb",
|
41
43
|
"test/mylist_spec.rb",
|
42
44
|
"test/searcher_spec.rb"
|
43
45
|
]
|
@@ -51,18 +53,14 @@ Gem::Specification.new do |s|
|
|
51
53
|
s.specification_version = 3
|
52
54
|
|
53
55
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
54
|
-
s.add_runtime_dependency(%q<damerau-levenshtein>, [">= 0.5.3"])
|
55
56
|
s.add_runtime_dependency(%q<libxml-ruby>, [">= 2.2.2"])
|
56
|
-
s.add_runtime_dependency(%q<mechanize>, [">= 2.0.0"])
|
57
57
|
s.add_development_dependency(%q<rake>, ["= 0.8.7"])
|
58
58
|
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
59
59
|
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
|
60
60
|
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
|
61
61
|
s.add_development_dependency(%q<rcov>, [">= 0"])
|
62
62
|
else
|
63
|
-
s.add_dependency(%q<damerau-levenshtein>, [">= 0.5.3"])
|
64
63
|
s.add_dependency(%q<libxml-ruby>, [">= 2.2.2"])
|
65
|
-
s.add_dependency(%q<mechanize>, [">= 2.0.0"])
|
66
64
|
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
67
65
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
68
66
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -70,9 +68,7 @@ Gem::Specification.new do |s|
|
|
70
68
|
s.add_dependency(%q<rcov>, [">= 0"])
|
71
69
|
end
|
72
70
|
else
|
73
|
-
s.add_dependency(%q<damerau-levenshtein>, [">= 0.5.3"])
|
74
71
|
s.add_dependency(%q<libxml-ruby>, [">= 2.2.2"])
|
75
|
-
s.add_dependency(%q<mechanize>, [">= 2.0.0"])
|
76
72
|
s.add_dependency(%q<rake>, ["= 0.8.7"])
|
77
73
|
s.add_dependency(%q<shoulda>, [">= 0"])
|
78
74
|
s.add_dependency(%q<bundler>, ["~> 1.0.0"])
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# $:.unshift File.dirname(__FILE__) + "/../lib"
|
3
|
+
|
4
|
+
require '../lib/nicoscraper.rb'
|
5
|
+
|
6
|
+
|
7
|
+
describe Nicos::Mylist, "After executiton of 'getMoreInfo' method" +
|
8
|
+
"And for example, with passing argument (15196568)" do
|
9
|
+
before(:all) do
|
10
|
+
@mylist = Nicos::Mylist.new(15196568)
|
11
|
+
@mylist.getMoreInfo
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have the following values" do
|
15
|
+
@mylist.available .should be_true
|
16
|
+
|
17
|
+
@mylist.mylist_id .should equal(15196568)
|
18
|
+
@mylist.user_id .should equal(1934563)
|
19
|
+
@mylist.author .should == "おぽこ"
|
20
|
+
|
21
|
+
@mylist.title .should == "【Oblivion】おっさんの大冒険"
|
22
|
+
@mylist.description .should_not be_nil
|
23
|
+
@mylist.public .should_not be_nil
|
24
|
+
@mylist.default_sort .should_not be_nil
|
25
|
+
@mylist.create_time .should_not be_nil
|
26
|
+
@mylist.update_time .should_not be_nil
|
27
|
+
|
28
|
+
@mylist.icon_id .should_not be_nil
|
29
|
+
@mylist.movies .should_not be_nil
|
30
|
+
@mylist.movies .should be_kind_of(Array)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have Movie class instances. and these have the following structure." do
|
34
|
+
@mylist.available.should be_true
|
35
|
+
|
36
|
+
@mylist.mylist_id.should === 15196568
|
37
|
+
@mylist.movies .should be_instance_of(Array)
|
38
|
+
|
39
|
+
movieObj = @mylist.movies[0]
|
40
|
+
movieObj.available .should be_true
|
41
|
+
|
42
|
+
movieObj.video_id .should_not be_nil
|
43
|
+
movieObj.item_id .should_not be_nil
|
44
|
+
movieObj.item_id .should_not == 0
|
45
|
+
movieObj.title .should_not be_nil
|
46
|
+
movieObj.first_retrieve .should_not be_nil
|
47
|
+
#movieObj.memo .should_not be_nil
|
48
|
+
movieObj.description .should_not be_nil
|
49
|
+
movieObj.thumbnail_url .should_not be_nil
|
50
|
+
movieObj.length .should_not be_nil
|
51
|
+
movieObj.length .should_not == 0
|
52
|
+
|
53
|
+
movieObj.view_counter .should_not == 0
|
54
|
+
movieObj.comment_num .should_not == 0
|
55
|
+
movieObj.mylist_counter .should_not == 0
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
62
|
+
"for non-existent mylist." do
|
63
|
+
before(:all) do
|
64
|
+
@mylist = Nicos::Mylist.new(999999999)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should " do
|
68
|
+
r = @mylist.getMoreInfo
|
69
|
+
r[:status] .should === :notFound
|
70
|
+
r[:result] .should be_nil
|
71
|
+
|
72
|
+
@mylist.available .should_not be_true
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
78
|
+
"for nonpublic mylist." do
|
79
|
+
before(:all) do
|
80
|
+
@mylist = Nicos::Mylist.new(22947348)
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should " do
|
84
|
+
r = @mylist.getMoreInfo
|
85
|
+
r[:status] .should === :notPublic
|
86
|
+
r[:result] .should be_nil
|
87
|
+
|
88
|
+
@mylist.available .should_not be_true
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
# マイリストは削除と404の区別がない?
|
93
|
+
describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
94
|
+
"for deleted mylist." do
|
95
|
+
before(:all) do
|
96
|
+
@mylist = Nicos::Mylist.new(23361251) # 自分のマイリストで、公開設定にしてから削除したもの。
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should " do
|
100
|
+
r = @mylist.getMoreInfo
|
101
|
+
# r["status] .should === :deleted
|
102
|
+
r[:status] .should === :notFound
|
103
|
+
r[:result] .should be_nil
|
104
|
+
|
105
|
+
@mylist.available .should_not be_true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
|
110
|
+
describe Nicos::Mylist, "After executiton of 'getInfo' method" do
|
111
|
+
before(:all) do
|
112
|
+
@mylist = Nicos::Mylist.new(15196568)
|
113
|
+
@mylist.getMoreInfo
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should return over 0.9 when execute 'getSimilarity' method." +
|
117
|
+
"passing arguments (1450136)" do
|
118
|
+
result = @mylist.getSimilarity
|
119
|
+
result .should_not be_nil
|
120
|
+
result .should >= 0.7
|
121
|
+
end
|
122
|
+
end
|
data/test/mylist_spec.rb
CHANGED
@@ -8,9 +8,9 @@ describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
|
8
8
|
before(:all) do
|
9
9
|
@mylist = Nicos::Mylist.new(15196568)
|
10
10
|
@mylist.getInfo
|
11
|
+
p @mylist
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
14
|
it "should have the following values" do
|
15
15
|
@mylist.available .should be_true
|
16
16
|
|
@@ -29,7 +29,6 @@ describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
|
29
29
|
@mylist.author .should == "おぽこ"
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
32
|
it "should have Movie class instances. and these have the following structure." do
|
34
33
|
@mylist.available.should be_true
|
35
34
|
|
@@ -40,6 +39,8 @@ describe Nicos::Mylist, "After executiton of 'getInfo' method" +
|
|
40
39
|
movieObj.available .should be_true
|
41
40
|
|
42
41
|
movieObj.video_id .should_not be_nil
|
42
|
+
movieObj.item_id .should_not be_nil
|
43
|
+
movieObj.item_id .should_not == 0
|
43
44
|
movieObj.title .should_not be_nil
|
44
45
|
movieObj.first_retrieve .should_not be_nil
|
45
46
|
#movieObj.memo .should_not be_nil
|
@@ -114,6 +115,9 @@ describe Nicos::Mylist, "After executiton of 'getInfo' method" do
|
|
114
115
|
"passing arguments (1450136)" do
|
115
116
|
result = @mylist.getSimilarity
|
116
117
|
result .should_not be_nil
|
117
|
-
result .should >= 0.
|
118
|
+
result .should >= 0.7
|
118
119
|
end
|
119
120
|
end
|
121
|
+
|
122
|
+
|
123
|
+
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nicoscraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.13
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Masami Yonehara
|
@@ -10,22 +10,11 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-10-
|
13
|
+
date: 2011-10-17 00:00:00 Z
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: damerau-levenshtein
|
17
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
|
-
requirements:
|
20
|
-
- - ">="
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: 0.5.3
|
23
|
-
type: :runtime
|
24
|
-
prerelease: false
|
25
|
-
version_requirements: *id001
|
26
15
|
- !ruby/object:Gem::Dependency
|
27
16
|
name: libxml-ruby
|
28
|
-
requirement: &
|
17
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
29
18
|
none: false
|
30
19
|
requirements:
|
31
20
|
- - ">="
|
@@ -33,21 +22,10 @@ dependencies:
|
|
33
22
|
version: 2.2.2
|
34
23
|
type: :runtime
|
35
24
|
prerelease: false
|
36
|
-
version_requirements: *
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: mechanize
|
39
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: 2.0.0
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *id003
|
25
|
+
version_requirements: *id001
|
48
26
|
- !ruby/object:Gem::Dependency
|
49
27
|
name: rake
|
50
|
-
requirement: &
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
51
29
|
none: false
|
52
30
|
requirements:
|
53
31
|
- - "="
|
@@ -55,10 +33,10 @@ dependencies:
|
|
55
33
|
version: 0.8.7
|
56
34
|
type: :development
|
57
35
|
prerelease: false
|
58
|
-
version_requirements: *
|
36
|
+
version_requirements: *id002
|
59
37
|
- !ruby/object:Gem::Dependency
|
60
38
|
name: shoulda
|
61
|
-
requirement: &
|
39
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
62
40
|
none: false
|
63
41
|
requirements:
|
64
42
|
- - ">="
|
@@ -66,10 +44,10 @@ dependencies:
|
|
66
44
|
version: "0"
|
67
45
|
type: :development
|
68
46
|
prerelease: false
|
69
|
-
version_requirements: *
|
47
|
+
version_requirements: *id003
|
70
48
|
- !ruby/object:Gem::Dependency
|
71
49
|
name: bundler
|
72
|
-
requirement: &
|
50
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
51
|
none: false
|
74
52
|
requirements:
|
75
53
|
- - ~>
|
@@ -77,10 +55,10 @@ dependencies:
|
|
77
55
|
version: 1.0.0
|
78
56
|
type: :development
|
79
57
|
prerelease: false
|
80
|
-
version_requirements: *
|
58
|
+
version_requirements: *id004
|
81
59
|
- !ruby/object:Gem::Dependency
|
82
60
|
name: jeweler
|
83
|
-
requirement: &
|
61
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
84
62
|
none: false
|
85
63
|
requirements:
|
86
64
|
- - ~>
|
@@ -88,10 +66,10 @@ dependencies:
|
|
88
66
|
version: 1.6.4
|
89
67
|
type: :development
|
90
68
|
prerelease: false
|
91
|
-
version_requirements: *
|
69
|
+
version_requirements: *id005
|
92
70
|
- !ruby/object:Gem::Dependency
|
93
71
|
name: rcov
|
94
|
-
requirement: &
|
72
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
95
73
|
none: false
|
96
74
|
requirements:
|
97
75
|
- - ">="
|
@@ -99,7 +77,7 @@ dependencies:
|
|
99
77
|
version: "0"
|
100
78
|
type: :development
|
101
79
|
prerelease: false
|
102
|
-
version_requirements: *
|
80
|
+
version_requirements: *id006
|
103
81
|
description: "It scrape movies and mylists of Niconico douga.\n "
|
104
82
|
email: zeitdiebe@gmail.com
|
105
83
|
executables: []
|
@@ -126,10 +104,12 @@ files:
|
|
126
104
|
- lib/classes/parser.rb
|
127
105
|
- lib/classes/searcher.rb
|
128
106
|
- lib/classes/tools.rb
|
107
|
+
- lib/config/mylist.rb
|
129
108
|
- lib/config/wait.rb
|
130
109
|
- lib/nicoscraper.rb
|
131
110
|
- nicoscraper.gemspec
|
132
111
|
- test/movie_spec.rb
|
112
|
+
- test/mylist_getmoreinfo_spec.rb
|
133
113
|
- test/mylist_spec.rb
|
134
114
|
- test/searcher_spec.rb
|
135
115
|
homepage: http://github.com/hdemon/nicoscraper
|
@@ -145,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
125
|
requirements:
|
146
126
|
- - ">="
|
147
127
|
- !ruby/object:Gem::Version
|
148
|
-
hash:
|
128
|
+
hash: 3984463765989888126
|
149
129
|
segments:
|
150
130
|
- 0
|
151
131
|
version: "0"
|