youtube_it 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -12,4 +12,5 @@
12
12
 
13
13
  * ACL support
14
14
 
15
- == 0.0.3 / 2010-08-12
15
+ == 0.0.3 / 2010-08-12
16
+
data/README.txt CHANGED
@@ -132,7 +132,10 @@ Playlist
132
132
 
133
133
  client.remove_video_from_playlist(playlist_id, playlist_entry_id)
134
134
 
135
-
135
+ * get all playlists from some user
136
+
137
+ client.playlists_for(user) #return array with the playlists
138
+
136
139
  Access Control List
137
140
 
138
141
  You can give permissions in your videos, for example denied comments, rate, etc...
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.3
@@ -138,6 +138,10 @@ class YouTubeIt
138
138
  def playlists
139
139
  client.playlists
140
140
  end
141
+
142
+ def playlists_for(user)
143
+ client.playlists_for(user)
144
+ end
141
145
 
142
146
  def add_playlist(options)
143
147
  client.add_playlist(options)
@@ -35,6 +35,34 @@ class YouTubeIt
35
35
  end
36
36
  end
37
37
 
38
+ class PlaylistsFeedParser < FeedParser #:nodoc:
39
+
40
+ # return array of playlist objects
41
+ def parse_content(content)
42
+ doc = REXML::Document.new(content.body)
43
+ feed = doc.elements["feed"]
44
+
45
+ playlists = []
46
+ feed.elements.each("entry") do |entry|
47
+ playlists << parse_entry(entry)
48
+ end
49
+ return playlists
50
+ end
51
+
52
+ protected
53
+
54
+ def parse_entry(entry)
55
+ YouTubeIt::Model::Playlist.new(
56
+ :title => entry.elements["title"].text,
57
+ :summary => (entry.elements["summary"] || entry.elements["media:group"].elements["media:description"]).text,
58
+ :description => (entry.elements["summary"] || entry.elements["media:group"].elements["media:description"]).text,
59
+ :playlist_id => entry.elements["id"].text[/playlist([^<]+)/, 1].sub(':',''),
60
+ :published => entry.elements["published"] ? entry.elements["published"].text : nil,
61
+ :response_code => nil,
62
+ :xml => nil)
63
+ end
64
+ end
65
+
38
66
  class VideoFeedParser < FeedParser #:nodoc:
39
67
 
40
68
  def parse_content(content)
@@ -278,6 +278,15 @@ class YouTubeIt
278
278
  return response.body
279
279
  end
280
280
  end
281
+
282
+ def playlists_for(user)
283
+ playlist_url = "/feeds/api/users/#{user}/playlists?v=2"
284
+ http_connection do |session|
285
+ response = session.get(playlist_url)
286
+ raise_on_faulty_response(response)
287
+ return YouTubeIt::Parser::PlaylistsFeedParser.new(response).parse #return response.body
288
+ end
289
+ end
281
290
 
282
291
  def add_playlist(options)
283
292
  response = nil
Binary file
data/test/test_client.rb CHANGED
@@ -266,6 +266,12 @@ class TestClient < Test::Unit::TestCase
266
266
  assert_equal playlist_updated.title, "title changed"
267
267
  assert @client.delete_playlist(playlist.playlist_id)
268
268
  end
269
+
270
+ def test_should_list_playlist_for_user
271
+ result = @client.playlists_for('chebyte')
272
+ assert result.last.title, "rock"
273
+ end
274
+
269
275
 
270
276
  def test_should_determine_if_widescreen_video_is_widescreen
271
277
  widescreen_id = 'QqQVll-MP3I'
data/youtube_it.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{youtube_it}
8
- s.version = "1.2.1"
8
+ s.version = "1.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["chebyte", "kylejginavan"]
@@ -48,6 +48,7 @@ Gem::Specification.new do |s|
48
48
  "pkg/youtube_it-1.0.0.gem",
49
49
  "pkg/youtube_it-1.1.0.gem",
50
50
  "pkg/youtube_it-1.2.0.gem",
51
+ "pkg/youtube_it-1.2.1.gem",
51
52
  "test/helper.rb",
52
53
  "test/test.mov",
53
54
  "test/test_chain_io.rb",
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 2
8
- - 1
9
- version: 1.2.1
8
+ - 3
9
+ version: 1.2.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - chebyte
@@ -73,6 +73,7 @@ files:
73
73
  - pkg/youtube_it-1.0.0.gem
74
74
  - pkg/youtube_it-1.1.0.gem
75
75
  - pkg/youtube_it-1.2.0.gem
76
+ - pkg/youtube_it-1.2.1.gem
76
77
  - test/helper.rb
77
78
  - test/test.mov
78
79
  - test/test_chain_io.rb