downthetube 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README +9 -0
  2. data/downthetube.gemspec +2 -2
  3. data/lib/youtube.rb +10 -2
  4. metadata +4 -4
data/README CHANGED
@@ -1,5 +1,14 @@
1
1
  Many libraries have been written to pull things off Youtube. This is one of them.
2
2
 
3
+ Installation
4
+
5
+ The usual: gem install downthetube
6
+
7
+ then put it in your Gemfile if you are doing Rails stuff with it:
8
+
9
+ gem 'downthetube'
10
+
11
+ Usage:
3
12
 
4
13
 
5
14
  irb(main):006:0> playlist = Youtube.playlists_for("stephensam").first
data/downthetube.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  specification = Gem::Specification.new do |spec|
2
2
  # Descriptive and source information for this gem.
3
3
  spec.name = "downthetube"
4
- spec.version = "0.0.1"
4
+ spec.version = "0.0.2"
5
5
  spec.description = "A library to make downloading playlists and videos from Youtube less nasty."
6
6
  spec.summary = "Downloads playlists and videos from Youtube."
7
7
  spec.author = "Mike Williamson"
@@ -13,6 +13,6 @@ specification = Gem::Specification.new do |spec|
13
13
  spec.add_dependency("gdata", ">= 1.0.0")
14
14
  spec.extra_rdoc_files = ["README"]
15
15
  spec.require_path = ["lib"]
16
- spec.test_files = ["spec"]
16
+ #spec.test_files = ["spec"]
17
17
  end
18
18
 
data/lib/youtube.rb CHANGED
@@ -17,14 +17,16 @@ class Youtube
17
17
  attr_reader :title, :author, :url, :id
18
18
 
19
19
  def initialize entry
20
- if entry.class == REXML::Element
20
+ if ((entry) && (entry.class == REXML::Element))
21
21
  @xml = entry
22
22
  @id = @xml.get_text('yt:playlistId')
23
23
  @title = @xml.get_text('title')
24
24
  @author = @xml.get_text('author/name')
25
25
  @xml.each_element_with_attribute('src'){|a| @url = a.attribute('src').to_s }
26
+ elsif((entry.class==String)&&(entry =~ /\w{16}/))
27
+ @url = "http://gdata.youtube.com/feeds/api/playlists/#{entry}"
26
28
  else
27
- raise "What was passed into Playlist class was not an REXML object"
29
+ raise "The Playlist class did not understand the parameter it was initialized with."
28
30
  end
29
31
  end
30
32
 
@@ -97,6 +99,12 @@ class Youtube
97
99
  end
98
100
  end
99
101
 
102
+ extend ActiveModel::Naming
103
+
104
+ def name
105
+ "Video"
106
+ end
107
+
100
108
 
101
109
  def thumbnail size=:small
102
110
  if size == :large
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: downthetube
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Mike Williamson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-31 00:00:00 -04:00
18
+ date: 2011-06-03 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency