youtube_search 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- youtube_search (0.1.1)
4
+ youtube_search (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/Readme.md CHANGED
@@ -1,8 +1,7 @@
1
1
  Search youtube via this simple ruby api
2
2
 
3
- - just 10+ LOC
3
+ - simple
4
4
  - no dependencies
5
- - no funky stuff going on
6
5
 
7
6
  Install
8
7
  =======
@@ -14,7 +13,7 @@ Or
14
13
 
15
14
  Usage
16
15
  =====
17
- YoutubeSearch.search('cats').first
16
+ YoutubeSearch.search('boat').first
18
17
  {
19
18
  "title"=>"Killer Whale Imitates Boat Motor",
20
19
  "published"=>"2011-09-29T15:30:43.000Z",
@@ -31,14 +30,18 @@ page / per_page are supported
31
30
 
32
31
  and [standard youtube options](http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html#Standard_parameters)
33
32
 
34
- YoutubeSearch.search('cats', :page => 10, :per_page => 4).first
33
+ YoutubeSearch.search('cats', 'time' => 'this_week', 'orderby' => 'viewCount').first
35
34
 
36
- I can haz iframe:
35
+ ### I can haz iframe:
37
36
 
38
37
  # DISCLAIMER this iframe may steal 4 minutes of your life ;)
39
38
  id = YoutubeSearch.search('lolcats').first['video_id']
40
39
  %{<iframe src="http://www.youtube.com/embed/#{id}" width=640 height=480 frameborder=0></iframe>}
41
40
 
41
+ ### Retrieve videos by playlist ID
42
+
43
+ videos = YoutubeSearch.playlist_videos('5F23DAF4BFE3D14C')
44
+
42
45
  TODO
43
46
  ====
44
47
  - more detailed xml parsing (atm only name and value is read)
@@ -47,6 +50,10 @@ TODO
47
50
 
48
51
  Author
49
52
  ======
53
+
54
+ ### [Contributors](http://github.com/grosser/youtube_search/contributors)
55
+ - [David Gil](https://qoolife.com)
56
+
50
57
  [Michael Grosser](http://grosser.it)<br/>
51
58
  michael@grosser.it<br/>
52
59
  Hereby placed under public domain, do what you want, just do not hold me accountable...<br/>
@@ -1,3 +1,3 @@
1
1
  module YoutubeSearch
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -10,21 +10,40 @@ module YoutubeSearch
10
10
  parse(xml)
11
11
  end
12
12
 
13
- def self.parse(xml)
13
+ def self.playlist_videos(playlist_id)
14
+ xml = open("https://gdata.youtube.com/feeds/api/playlists/#{playlist_id}?v=2").read
15
+ parse(xml, :type => :playlist)
16
+ end
17
+
18
+ def self.parse(xml, options={})
19
+ elements_in(xml, 'feed/entry').map do |element|
20
+ entry = xml_to_hash(element)
21
+ entry['video_id'] = if options[:type] == :playlist
22
+ element.elements['*/yt:videoid'].text
23
+ else
24
+ entry['id'].split('/').last
25
+ end
26
+
27
+ entry
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def self.elements_in(xml, selector)
14
34
  entries = []
15
35
  doc = REXML::Document.new(xml)
16
- doc.elements.each('feed/entry') do |p|
17
- entry = Hash[p.children.map do |child|
18
- [child.name, child.text]
19
- end]
20
-
21
- entry['video_id'] = entry['id'].split('/').last
22
- entries << entry
36
+ doc.elements.each(selector) do |element|
37
+ entries << element
23
38
  end
24
39
  entries
25
40
  end
26
41
 
27
- private
42
+ def self.xml_to_hash(element)
43
+ Hash[element.children.map do |child|
44
+ [child.name, child.text]
45
+ end]
46
+ end
28
47
 
29
48
  def self.options_with_per_page_and_page(options)
30
49
  options = options.dup
@@ -0,0 +1 @@
1
+ <?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:media='http://search.yahoo.com/mrss/' xmlns:openSearch='http://a9.com/-/spec/opensearch/1.1/' xmlns:gd='http://schemas.google.com/g/2005' xmlns:gml='http://www.opengis.net/gml' xmlns:yt='http://gdata.youtube.com/schemas/2007' xmlns:georss='http://www.georss.org/georss' gd:etag='W/&quot;C0AMR347eCp7I2A9WhRRFks.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C</id><updated>2011-11-30T14:03:06.000Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><title>Clínica VASS - Canal de Qoolife</title><subtitle>¿Necesitas más información sobre Clínica VASS? En estos vídeos te ayudarán a conocernos mejor.</subtitle><logo>http://www.youtube.com/img/pic_youtubelogo_123x63.gif</logo><link rel='alternate' type='text/html' href='https://www.youtube.com/view_play_list?p=5F23DAF4BFE3D14C'/><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C?v=2'/><link rel='http://schemas.google.com/g/2005#batch' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/batch?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C?start-index=1&amp;max-results=25&amp;v=2'/><link rel='service' type='application/atomsvc+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C?alt=atom-service&amp;v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><generator version='2.1' uri='http://gdata.youtube.com'>YouTube data API</generator><openSearch:totalResults>6</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><media:group><media:content url='http://www.youtube.com/p/5F23DAF4BFE3D14C' type='application/x-shockwave-flash' yt:format='5'/><media:description type='plain'>¿Necesitas más información sobre Clínica VASS? En estos vídeos te ayudarán a conocernos mejor.</media:description><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/default.jpg' height='90' width='120' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:title type='plain'>Clínica VASS - Canal de Qoolife</media:title><yt:duration seconds='0'/></media:group><yt:playlistId>5F23DAF4BFE3D14C</yt:playlistId><entry gd:etag='W/&quot;CEQMQHg-eCp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UJvHjGFHgPSakUFmztBgGKG</id><updated>2011-12-07T01:46:21.650Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='People' label='People &amp; Blogs'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Osteopatia'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='terapias'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='manuales'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Raúl'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Guzmán'/><title>Osteopatia y terapias manuales</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=5wU-yHnq7Hs&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/5wU-yHnq7Hs/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/5wU-yHnq7Hs/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=5wU-yHnq7Hs'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/5wU-yHnq7Hs?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UJvHjGFHgPSakUFmztBgGKG?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/5wU-yHnq7Hs/comments?v=2' countHint='1'/></gd:comments><georss:where><gml:Point><gml:pos>40.503977898435274 -3.6735963821411133</gml:pos></gml:Point></georss:where><media:group><media:category label='People &amp; Blogs' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>People</media:category><media:content url='https://www.youtube.com/v/5wU-yHnq7Hs?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='192' yt:format='5'/><media:content url='rtsp://v8.cache7.c.youtube.com/CiULENy73wIaHAl77Op5yD4F5xMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='192' yt:format='1'/><media:content url='rtsp://v1.cache5.c.youtube.com/CiULENy73wIaHAl77Op5yD4F5xMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='192' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>Sesión de Osteopatía y terapias manuales en Clínica Vass</media:description><media:keywords>Osteopatia, terapias, manuales, Raúl, Guzmán</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=5wU-yHnq7Hs&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/5wU-yHnq7Hs/default.jpg' height='90' width='120' time='00:01:36' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/5wU-yHnq7Hs/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/5wU-yHnq7Hs/1.jpg' height='90' width='120' time='00:00:48' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/5wU-yHnq7Hs/2.jpg' height='90' width='120' time='00:01:36' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/5wU-yHnq7Hs/3.jpg' height='90' width='120' time='00:02:24' yt:name='end'/><media:title type='plain'>Osteopatia y terapias manuales</media:title><yt:aspectRatio>widescreen</yt:aspectRatio><yt:duration seconds='192'/><yt:uploaded>2010-01-08T10:37:16.000Z</yt:uploaded><yt:videoid>5wU-yHnq7Hs</yt:videoid></media:group><gd:rating average='5.0' max='5' min='1' numRaters='5' rel='http://schemas.google.com/g/2005#overall'/><yt:recorded>2010-01-08</yt:recorded><yt:statistics favoriteCount='3' viewCount='9058'/><yt:rating numDislikes='0' numLikes='5'/><yt:position>1</yt:position></entry><entry gd:etag='W/&quot;CEQMQHg-eSp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UKdlAKbbMWlfjo9ojnLihjF</id><updated>2011-12-07T01:46:21.651Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Tech' label='Science &amp; Technology'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Rizartrosis'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Tendinitis'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='de'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Quervain'/><title>Rizartrosis y Tendinitis de Quervain.m4v</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=QC1GLNiPtSY&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QC1GLNiPtSY/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QC1GLNiPtSY/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=QC1GLNiPtSY'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QC1GLNiPtSY?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UKdlAKbbMWlfjo9ojnLihjF?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/QC1GLNiPtSY/comments?v=2' countHint='0'/></gd:comments><georss:where><gml:Point><gml:pos>40.50399421400763 -3.6736392974853516</gml:pos></gml:Point></georss:where><media:group><media:category label='Science &amp; Technology' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Tech</media:category><media:content url='https://www.youtube.com/v/QC1GLNiPtSY?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='92' yt:format='5'/><media:content url='rtsp://v5.cache3.c.youtube.com/CiULENy73wIaHAkmtY_YLEYtQBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='92' yt:format='1'/><media:content url='rtsp://v6.cache1.c.youtube.com/CiULENy73wIaHAkmtY_YLEYtQBMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='92' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>Cómo tratar una Rizartrosis y Tendinitis del pulgar</media:description><media:keywords>Rizartrosis, Tendinitis, de, Quervain</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=QC1GLNiPtSY&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/QC1GLNiPtSY/default.jpg' height='90' width='120' time='00:00:46' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/QC1GLNiPtSY/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/QC1GLNiPtSY/1.jpg' height='90' width='120' time='00:00:23' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/QC1GLNiPtSY/2.jpg' height='90' width='120' time='00:00:46' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/QC1GLNiPtSY/3.jpg' height='90' width='120' time='00:01:09' yt:name='end'/><media:title type='plain'>Rizartrosis y Tendinitis de Quervain.m4v</media:title><yt:aspectRatio>widescreen</yt:aspectRatio><yt:duration seconds='92'/><yt:uploaded>2010-06-21T08:47:04.000Z</yt:uploaded><yt:videoid>QC1GLNiPtSY</yt:videoid></media:group><yt:recorded>2010-06-21</yt:recorded><yt:statistics favoriteCount='2' viewCount='4875'/><yt:position>2</yt:position></entry><entry gd:etag='W/&quot;CEQMQHg-eSp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UKKop_MiyjnvNikUPNEYsZ2</id><updated>2011-12-07T01:46:21.651Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Education' label='Education'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Sesamoiditis'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='tendinitis'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='del'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='primer'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='metatarsiano'/><title>Sesamoiditis y tendinitis del primer metatarsiano 1</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=GObLbr3pQag&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/GObLbr3pQag/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/GObLbr3pQag/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=GObLbr3pQag'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/GObLbr3pQag?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UKKop_MiyjnvNikUPNEYsZ2?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/GObLbr3pQag/comments?v=2' countHint='1'/></gd:comments><yt:location>Avenica camino de santiago 31 madrid</yt:location><media:group><media:category label='Education' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Education</media:category><media:content url='https://www.youtube.com/v/GObLbr3pQag?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='120' yt:format='5'/><media:content url='rtsp://v2.cache6.c.youtube.com/CiULENy73wIaHAmoQem9bsvmGBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='120' yt:format='1'/><media:content url='rtsp://v1.cache5.c.youtube.com/CiULENy73wIaHAmoQem9bsvmGBMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='120' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>Tratamiento de una Sesamoiditis - Hallus Rigidus</media:description><media:keywords>Sesamoiditis, tendinitis, del, primer, metatarsiano</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=GObLbr3pQag&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/GObLbr3pQag/default.jpg' height='90' width='120' time='00:01:00' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/GObLbr3pQag/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/GObLbr3pQag/1.jpg' height='90' width='120' time='00:00:30' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/GObLbr3pQag/2.jpg' height='90' width='120' time='00:01:00' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/GObLbr3pQag/3.jpg' height='90' width='120' time='00:01:30' yt:name='end'/><media:title type='plain'>Sesamoiditis y tendinitis del primer metatarsiano 1</media:title><yt:aspectRatio>widescreen</yt:aspectRatio><yt:duration seconds='120'/><yt:uploaded>2010-03-03T10:23:16.000Z</yt:uploaded><yt:videoid>GObLbr3pQag</yt:videoid></media:group><gd:rating average='3.0' max='5' min='1' numRaters='4' rel='http://schemas.google.com/g/2005#overall'/><yt:recorded>2010-03-03</yt:recorded><yt:statistics favoriteCount='3' viewCount='4372'/><yt:rating numDislikes='2' numLikes='2'/><yt:position>3</yt:position></entry><entry gd:etag='W/&quot;CEQMQHg-eSp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UL7bE4uNUuJI9zDGcm3a5lc</id><updated>2011-12-07T01:46:21.651Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='People' label='People &amp; Blogs'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Drenaje'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='linfático'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='gestacional'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='embarazadas'/><title>Drenaje linfático gestacional</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=SDurBqiV4kk&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/SDurBqiV4kk/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/SDurBqiV4kk/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=SDurBqiV4kk'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/SDurBqiV4kk?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UL7bE4uNUuJI9zDGcm3a5lc?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/SDurBqiV4kk/comments?v=2' countHint='0'/></gd:comments><georss:where><gml:Point><gml:pos>40.504141053980156 -3.673553466796875</gml:pos></gml:Point></georss:where><media:group><media:category label='People &amp; Blogs' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>People</media:category><media:content url='https://www.youtube.com/v/SDurBqiV4kk?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='130' yt:format='5'/><media:content url='rtsp://v4.cache3.c.youtube.com/CiULENy73wIaHAlJ4pWoBqs7SBMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='130' yt:format='1'/><media:content url='rtsp://v1.cache6.c.youtube.com/CiULENy73wIaHAlJ4pWoBqs7SBMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='130' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>Sesión de drenaje linfático gestacional en Clínica Vass</media:description><media:keywords>Drenaje, linfático, gestacional, embarazadas</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=SDurBqiV4kk&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/SDurBqiV4kk/default.jpg' height='90' width='120' time='00:01:05' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/SDurBqiV4kk/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/SDurBqiV4kk/1.jpg' height='90' width='120' time='00:00:32.500' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/SDurBqiV4kk/2.jpg' height='90' width='120' time='00:01:05' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/SDurBqiV4kk/3.jpg' height='90' width='120' time='00:01:37.500' yt:name='end'/><media:title type='plain'>Drenaje linfático gestacional</media:title><yt:aspectRatio>widescreen</yt:aspectRatio><yt:duration seconds='130'/><yt:uploaded>2009-12-11T17:14:55.000Z</yt:uploaded><yt:videoid>SDurBqiV4kk</yt:videoid></media:group><gd:rating average='5.0' max='5' min='1' numRaters='1' rel='http://schemas.google.com/g/2005#overall'/><yt:recorded>2010-01-08</yt:recorded><yt:statistics favoriteCount='4' viewCount='2312'/><yt:rating numDislikes='0' numLikes='1'/><yt:position>4</yt:position></entry><entry gd:etag='W/&quot;CEQMQHg-eSp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UK9Qb2pwCziSRuXJdMWvKzp</id><updated>2011-12-07T01:46:21.651Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Tech' label='Science &amp; Technology'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Clinica VASS'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='estreñimiento'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='estreñimiento infantil'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='osteopatía visceral'/><title>Clínica VASS en Las Mañanas de la 1 - Tratamiento de estreñimiento infantil y de adultos.wmv</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=FcTOgyk8hdk&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/FcTOgyk8hdk/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/FcTOgyk8hdk/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=FcTOgyk8hdk'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/FcTOgyk8hdk?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UK9Qb2pwCziSRuXJdMWvKzp?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/FcTOgyk8hdk/comments?v=2' countHint='0'/></gd:comments><media:group><media:category label='Science &amp; Technology' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Tech</media:category><media:content url='https://www.youtube.com/v/FcTOgyk8hdk?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='207' yt:format='5'/><media:content url='rtsp://v1.cache1.c.youtube.com/CiULENy73wIaHAnZhTwpg87EFRMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='207' yt:format='1'/><media:content url='rtsp://v4.cache7.c.youtube.com/CiULENy73wIaHAnZhTwpg87EFRMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='207' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>Nuevo reportaje de Las mañanas de la 1, esta vez sobre cómo tratar el estreñimiento infantil y también en adultos</media:description><media:keywords>Clinica VASS, estreñimiento, estreñimiento infantil, osteopatía visceral</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=FcTOgyk8hdk&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/default.jpg' height='90' width='120' time='00:01:43.500' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/1.jpg' height='90' width='120' time='00:00:51.750' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/2.jpg' height='90' width='120' time='00:01:43.500' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/FcTOgyk8hdk/3.jpg' height='90' width='120' time='00:02:35.250' yt:name='end'/><media:title type='plain'>Clínica VASS en Las Mañanas de la 1 - Tratamiento de estreñimiento infantil y de adultos.wmv</media:title><yt:aspectRatio>widescreen</yt:aspectRatio><yt:duration seconds='207'/><yt:uploaded>2011-10-26T17:14:54.000Z</yt:uploaded><yt:videoid>FcTOgyk8hdk</yt:videoid></media:group><yt:statistics favoriteCount='0' viewCount='211'/><yt:position>5</yt:position></entry><entry gd:etag='W/&quot;CEQMQHg-eSp7I2A9WhRQEk8.&quot;'><id>tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UJjAJ_IhEXk66NLSWsf8ORa</id><updated>2011-12-07T01:46:21.651Z</updated><category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#playlist'/><category scheme='http://gdata.youtube.com/schemas/2007/categories.cat' term='Tech' label='Science &amp; Technology'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Television'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Televisión Española'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='Clínica VASS'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='bebés'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='cólicos'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='del'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='lactante'/><category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='masaje infantil'/><title>Clínica VASS en TVE - Las mañanas de la 1</title><link rel='alternate' type='text/html' href='https://www.youtube.com/watch?v=QqepLC4z4lk&amp;feature=youtube_gdata'/><link rel='http://gdata.youtube.com/schemas/2007#video.responses' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QqepLC4z4lk/responses?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QqepLC4z4lk/related?v=2'/><link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='https://m.youtube.com/details?v=QqepLC4z4lk'/><link rel='related' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/videos/QqepLC4z4lk?v=2'/><link rel='self' type='application/atom+xml' href='https://gdata.youtube.com/feeds/api/playlists/5F23DAF4BFE3D14C/kRk0fUfl9UJjAJ_IhEXk66NLSWsf8ORa?v=2'/><author><name>ClinicaVass</name><uri>https://gdata.youtube.com/feeds/api/users/ClinicaVass</uri></author><yt:accessControl action='comment' permission='allowed'/><yt:accessControl action='commentVote' permission='allowed'/><yt:accessControl action='videoRespond' permission='moderated'/><yt:accessControl action='rate' permission='allowed'/><yt:accessControl action='embed' permission='allowed'/><yt:accessControl action='list' permission='allowed'/><yt:accessControl action='autoPlay' permission='allowed'/><yt:accessControl action='syndicate' permission='allowed'/><gd:comments><gd:feedLink href='https://gdata.youtube.com/feeds/api/videos/QqepLC4z4lk/comments?v=2' countHint='0'/></gd:comments><media:group><media:category label='Science &amp; Technology' scheme='http://gdata.youtube.com/schemas/2007/categories.cat'>Tech</media:category><media:content url='https://www.youtube.com/v/QqepLC4z4lk?version=3&amp;f=playlists&amp;app=youtube_gdata' type='application/x-shockwave-flash' medium='video' isDefault='true' expression='full' duration='189' yt:format='5'/><media:content url='rtsp://v5.cache7.c.youtube.com/CiULENy73wIaHAlZ4jMuLKmnQhMYDSANFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='189' yt:format='1'/><media:content url='rtsp://v7.cache4.c.youtube.com/CiULENy73wIaHAlZ4jMuLKmnQhMYESARFEgGUglwbGF5bGlzdHMM/0/0/0/video.3gp' type='video/3gpp' medium='video' expression='full' duration='189' yt:format='6'/><media:credit role='uploader' scheme='urn:youtube'>ClinicaVass</media:credit><media:description type='plain'>La tele viene a ver cómo tratamos a los bebés con cólicos.</media:description><media:keywords>Television, Televisión Española, Clínica VASS, bebés, cólicos, del, lactante, masaje infantil</media:keywords><media:license type='text/html' href='http://www.youtube.com/t/terms'>youtube</media:license><media:player url='https://www.youtube.com/watch?v=QqepLC4z4lk&amp;feature=youtube_gdata_player'/><media:thumbnail url='http://i.ytimg.com/vi/QqepLC4z4lk/default.jpg' height='90' width='120' time='00:01:34.500' yt:name='default'/><media:thumbnail url='http://i.ytimg.com/vi/QqepLC4z4lk/hqdefault.jpg' height='360' width='480' yt:name='hqdefault'/><media:thumbnail url='http://i.ytimg.com/vi/QqepLC4z4lk/1.jpg' height='90' width='120' time='00:00:47.250' yt:name='start'/><media:thumbnail url='http://i.ytimg.com/vi/QqepLC4z4lk/2.jpg' height='90' width='120' time='00:01:34.500' yt:name='middle'/><media:thumbnail url='http://i.ytimg.com/vi/QqepLC4z4lk/3.jpg' height='90' width='120' time='00:02:21.750' yt:name='end'/><media:title type='plain'>Clínica VASS en TVE - Las mañanas de la 1</media:title><yt:duration seconds='189'/><yt:uploaded>2011-10-18T15:46:13.000Z</yt:uploaded><yt:videoid>QqepLC4z4lk</yt:videoid></media:group><yt:statistics favoriteCount='0' viewCount='109'/><yt:position>6</yt:position></entry></feed>
@@ -6,7 +6,7 @@ describe YoutubeSearch do
6
6
  end
7
7
 
8
8
  describe 'parse' do
9
- it "can parse xml" do
9
+ it "can parse xml from a search" do
10
10
  # convert to array so we get a nice diff in case of errors
11
11
  YoutubeSearch.parse(File.read('spec/fixtures/search_boat.xml')).first.sort.should == [
12
12
  ["author",nil],
@@ -24,6 +24,26 @@ describe YoutubeSearch do
24
24
  ["video_id", "0b2U5r7Jwkc"],
25
25
  ]
26
26
  end
27
+
28
+ it "can parse xml from a playlist" do
29
+ YoutubeSearch.parse(File.read('spec/fixtures/playlist_5F23DAF4BFE3D14C.xml'), :type => :playlist).first.sort.should == [
30
+ ["accessControl",nil],
31
+ ["author",nil],
32
+ ["category", nil],
33
+ ["comments",nil],
34
+ ["group", nil],
35
+ ["id","tag:youtube.com,2008:playlist:5F23DAF4BFE3D14C:kRk0fUfl9UJvHjGFHgPSakUFmztBgGKG"],
36
+ ["link",nil],
37
+ ["position","1"],
38
+ ["rating", nil],
39
+ ["recorded", "2010-01-08"],
40
+ ["statistics",nil],
41
+ ["title","Osteopatia y terapias manuales"],
42
+ ["updated","2011-12-07T01:46:21.650Z"],
43
+ ["video_id", "5wU-yHnq7Hs"],
44
+ ["where", nil]
45
+ ]
46
+ end
27
47
  end
28
48
 
29
49
  describe 'search' do
@@ -44,6 +64,12 @@ describe YoutubeSearch do
44
64
  end
45
65
  end
46
66
 
67
+ describe 'playlist_videos' do
68
+ it "can retrieve videos from a playlist" do
69
+ YoutubeSearch.playlist_videos('5F23DAF4BFE3D14C').size.should == 6
70
+ end
71
+ end
72
+
47
73
  describe 'options_with_per_page_and_page' do
48
74
  it "converts :page and :per_page" do
49
75
  YoutubeSearch.send(:options_with_per_page_and_page, {:page => 2, :per_page => 4}).should ==
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_search
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Grosser
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-14 00:00:00 +02:00
18
+ date: 2011-12-07 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -35,6 +35,7 @@ files:
35
35
  - Readme.md
36
36
  - lib/youtube_search.rb
37
37
  - lib/youtube_search/version.rb
38
+ - spec/fixtures/playlist_5F23DAF4BFE3D14C.xml
38
39
  - spec/fixtures/search_boat.xml
39
40
  - spec/spec_helper.rb
40
41
  - spec/youtube_search_spec.rb