nicovideo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ module Nicovideo #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 2
5
+ TINY = 3
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,5 +1,4 @@
1
- require 'nicovideo/base'
2
-
1
+ # not used
3
2
  module Nicovideo
4
3
  class Video
5
4
  def initialize video_id, data
@@ -15,6 +15,17 @@ module Nicovideo
15
15
 
16
16
  attr_reader :video_id
17
17
 
18
+ def exists?()
19
+ begin
20
+ @page = @page || get_page
21
+ return true
22
+ rescue
23
+ return false
24
+ end
25
+ end
26
+
27
+ def id() @video_id end
28
+
18
29
  def comments(num=500)
19
30
  puts_info 'getting comment xml : id = ' + @video_id
20
31
  begin
@@ -38,7 +49,7 @@ module Nicovideo
38
49
  @params = @params || get_params
39
50
  video_url = CGI.unescape(@params['url'])
40
51
  video_flv = @agent.get_file(video_url)
41
- Video.new(@video_id, video_flv)
52
+ video_flv
42
53
  end
43
54
  end
44
55
 
@@ -16,10 +16,21 @@ nv = Nicovideo.new(mail, password).login
16
16
  video_ids.each {|video_id|
17
17
 
18
18
  nv.watch(video_id) {|v|
19
+ # method 'id' and 'video_id' return video ID(string).
20
+ puts 'video id = ' + v.id
21
+
22
+ # method 'title' returns string.
19
23
  puts 'title = ' + v.title
24
+
25
+ # method 'tags' returns array of string.
20
26
  puts 'tags = ' + v.tags.join(' ')
27
+
28
+ # method 'comments' returns instance of class Comments
29
+ # which has methods 'to_xml', 'to_s'(same).
21
30
  puts 'getting comments xml'
22
31
  File.open("#{video_id}.xml", "wb") {|f| f.write v.comments(100).to_xml }
32
+
33
+ # method 'flv' and 'video' return raw flv data(binary).
23
34
  puts 'getting flv file'
24
35
  File.open("#{video_id}.flv", "wb") {|f| f.write v.flv }
25
36
  }
@@ -29,5 +29,3 @@ video_ids.each {|video_id|
29
29
 
30
30
  sleep 1
31
31
  }
32
-
33
-
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: nicovideo
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
7
- date: 2008-01-07 00:00:00 +09:00
6
+ version: 0.0.3
7
+ date: 2008-01-09 00:00:00 +09:00
8
8
  summary: utils for nicovideo
9
9
  require_paths:
10
10
  - lib