niconico 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/niconico.rb +1 -0
- data/lib/niconico/mylist.rb +24 -0
- data/lib/niconico/version.rb +1 -1
- data/lib/niconico/video.rb +3 -1
- metadata +4 -2
data/lib/niconico.rb
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
class Niconico
|
5
|
+
def mylist(i)
|
6
|
+
login unless @logined
|
7
|
+
|
8
|
+
page = @agent.get(url = "http://www.nicovideo.jp/mylist/#{i.to_s.sub(/^mylist\//,"")}")
|
9
|
+
#require 'ir_b'; ir b
|
10
|
+
if page.search("script").map(&:inner_text).find{|x| /preload/ =~ x }.match(/Mylist\.preload\(\d+, (.+?)\);/)
|
11
|
+
json = JSON.parse($1)
|
12
|
+
#require 'pp'; pp json
|
13
|
+
json.map do |item|
|
14
|
+
Video.new(self, item["item_data"]["video_id"],
|
15
|
+
title: item["item_data"]["title"],
|
16
|
+
mylist_comment: item["description"])
|
17
|
+
end.reverse
|
18
|
+
else
|
19
|
+
raise MylistParseError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class MylistParseError < Exception; end
|
24
|
+
end
|
data/lib/niconico/version.rb
CHANGED
data/lib/niconico/video.rb
CHANGED
@@ -7,7 +7,7 @@ class Niconico
|
|
7
7
|
end
|
8
8
|
|
9
9
|
class Video
|
10
|
-
DEFERRABLES = [:id, :title, :url, :video_url, :type]
|
10
|
+
DEFERRABLES = [:id, :title, :url, :video_url, :type, :tags, :mylist_comment]
|
11
11
|
DEFERRABLES_VAR = DEFERRABLES.map{|k| :"@#{k}" }
|
12
12
|
|
13
13
|
DEFERRABLES.zip(DEFERRABLES_VAR).each do |(k,i)|
|
@@ -57,6 +57,8 @@ class Niconico
|
|
57
57
|
when 's'; :swf
|
58
58
|
else; :flv
|
59
59
|
end
|
60
|
+
@tags = @page.search("#video_tags a[rel=tag]").map(&:inner_text)
|
61
|
+
@mylist_comment ||= nil
|
60
62
|
|
61
63
|
@page
|
62
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: niconico
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-11-17 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: wrapper of Mechanize, optimized for nicovideo. :)
|
15
15
|
email:
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- README.mkd
|
24
24
|
- Rakefile
|
25
25
|
- lib/niconico.rb
|
26
|
+
- lib/niconico/mylist.rb
|
26
27
|
- lib/niconico/ranking.rb
|
27
28
|
- lib/niconico/version.rb
|
28
29
|
- lib/niconico/video.rb
|
@@ -52,3 +53,4 @@ signing_key:
|
|
52
53
|
specification_version: 3
|
53
54
|
summary: wrapper of Mechanize, optimized for nicovideo.
|
54
55
|
test_files: []
|
56
|
+
has_rdoc:
|