video_info 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +24 -0
  3. data/.travis.yml +10 -0
  4. data/Gemfile +11 -0
  5. data/Guardfile +8 -0
  6. data/{LICENSE → LICENSE.txt} +2 -0
  7. data/README.md +42 -43
  8. data/Rakefile +5 -0
  9. data/lib/video_info/provider.rb +36 -26
  10. data/lib/video_info/providers/vimeo.rb +45 -27
  11. data/lib/video_info/providers/vkontakte.rb +114 -0
  12. data/lib/video_info/providers/youtube.rb +62 -23
  13. data/lib/video_info/version.rb +1 -1
  14. data/lib/video_info.rb +1 -1
  15. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/date/.yml +69 -0
  16. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/description/.yml +69 -0
  17. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/duration/.yml +69 -0
  18. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/embed_code/.yml +69 -0
  19. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/embed_url/.yml +69 -0
  20. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/height/.yml +69 -0
  21. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/keywords/.yml +69 -0
  22. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/provider/.yml +69 -0
  23. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_large/.yml +69 -0
  24. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_medium/.yml +69 -0
  25. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/thumbnail_small/.yml +69 -0
  26. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/title/.yml +69 -0
  27. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/url/.yml +69 -0
  28. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/video_id/.yml +69 -0
  29. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/view_count/.yml +69 -0
  30. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029/width/.yml +69 -0
  31. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_and_iframe_attributes/.yml +69 -0
  32. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_and_url_attributes/.yml +69 -0
  33. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_in_/group/_url/provider/.yml +69 -0
  34. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_in_/group/_url/video_id/.yml +69 -0
  35. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_in_text/provider/.yml +69 -0
  36. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vimeo/with_video_898029_in_text/video_id/.yml +69 -0
  37. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/date/.yml +1410 -0
  38. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/description/.yml +1410 -0
  39. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/duration/.yml +1410 -0
  40. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_code/.yml +1410 -0
  41. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/embed_url/.yml +1410 -0
  42. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/height/.yml +1410 -0
  43. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/provider/.yml +1410 -0
  44. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/title/.yml +1410 -0
  45. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/url/.yml +1410 -0
  46. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/video_id/.yml +1410 -0
  47. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/video_owner/.yml +1369 -0
  48. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/view_count/.yml +1410 -0
  49. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Vkontakte/with_video_39576223_108370515/width/.yml +1410 -0
  50. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_arbitrary_iframe_attributes/.yml +62 -0
  51. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_arbitrary_iframe_attributes/provider/.yml +62 -0
  52. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_iframe_attributes/.yml +62 -0
  53. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_iframe_attributes/provider/.yml +62 -0
  54. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_JM9NgvjjVng_in_youtu_be_url/provider/.yml +65 -0
  55. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_JM9NgvjjVng_in_youtu_be_url/video_id/.yml +65 -0
  56. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_after_params/provider/.yml +66 -0
  57. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_after_params/url/.yml +66 -0
  58. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_after_params/video_id/.yml +66 -0
  59. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_e_path/provider/.yml +66 -0
  60. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_e_path/video_id/.yml +66 -0
  61. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_embed_path/provider/.yml +66 -0
  62. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_embed_path/video_id/.yml +66 -0
  63. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_path/provider/.yml +66 -0
  64. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_path/video_id/.yml +66 -0
  65. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_user_url/provider/.yml +66 -0
  66. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_user_url/url/.yml +66 -0
  67. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_VeasFckfMHY_in_user_url/video_id/.yml +66 -0
  68. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_Xp6CXF-Cesg/provider/.yml +62 -0
  69. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_Xp6CXF-Cesg/video_id/.yml +62 -0
  70. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/date/.yml +62 -0
  71. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/description/.yml +62 -0
  72. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/duration/.yml +62 -0
  73. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/embed_code/.yml +62 -0
  74. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/embed_url/.yml +62 -0
  75. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/height/.yml +62 -0
  76. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/keywords/.yml +62 -0
  77. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/provider/.yml +62 -0
  78. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_large/.yml +62 -0
  79. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_medium/.yml +62 -0
  80. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/thumbnail_small/.yml +62 -0
  81. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/title/.yml +62 -0
  82. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/url/.yml +62 -0
  83. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/video_id/.yml +62 -0
  84. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/view_count/.yml +62 -0
  85. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_mZqGqE0D0n4/width/.yml +62 -0
  86. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_oQ49W_xKzKA/.yml +62 -0
  87. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_oQ49W_xKzKA/provider/.yml +62 -0
  88. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_oQ49W_xKzKA/video_id/.yml +62 -0
  89. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_url_in_text/provider/.yml +62 -0
  90. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/with_video_url_in_text/video_id/.yml +62 -0
  91. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/without_http_or_www/provider/.yml +65 -0
  92. data/spec/fixtures/vcr_cassettes/VideoInfo_Providers_Youtube/without_http_or_www/video_id/.yml +65 -0
  93. data/spec/lib/video_info/provider_spec.rb +44 -0
  94. data/spec/lib/video_info/providers/vimeo_spec.rb +74 -0
  95. data/spec/lib/video_info/providers/vkontakte_spec.rb +38 -0
  96. data/spec/lib/video_info/providers/youtube_spec.rb +138 -0
  97. data/spec/lib/video_info_spec.rb +50 -0
  98. data/spec/spec_helper.rb +22 -0
  99. data/video_info.gemspec +29 -0
  100. metadata +219 -22
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4?alt=json&v=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - VideoInfo/1.5.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Gdata-User-Country:
22
+ - CH
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Expires:
28
+ - Mon, 07 Oct 2013 19:53:17 GMT
29
+ Date:
30
+ - Mon, 07 Oct 2013 19:53:17 GMT
31
+ Cache-Control:
32
+ - private, max-age=300, no-transform
33
+ Vary:
34
+ - '*'
35
+ Gdata-Version:
36
+ - '2.1'
37
+ Etag:
38
+ - W/"D0AFQH47eCp7I2A9WhBXE0g."
39
+ Last-Modified:
40
+ - Wed, 27 Mar 2013 03:41:51 GMT
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ Content-Length:
48
+ - '4658'
49
+ Server:
50
+ - GSE
51
+ Alternate-Protocol:
52
+ - 80:quic
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"D0AFQH47eCp7I2A9WhBXE0g.\"","id":{"$t":"tag:youtube.com,2008:video:mZqGqE0D0n4"},"published":{"$t":"2008-04-12T22:25:35.000Z"},"updated":{"$t":"2013-03-27T03:41:51.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Music","label":"Music"}],"title":{"$t":"Cherry
56
+ Bloom - King Of The Knife"},"content":{"type":"application/x-shockwave-flash","src":"http://www.youtube.com/v/mZqGqE0D0n4?version=3&f=videos&app=youtube_gdata"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=mZqGqE0D0n4&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.responses","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/responses?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/related?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#uploader","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/zxQk-rZGowoqMBKxGD5jSA?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4?v=2"}],"author":[{"name":{"$t":"cherrybloomband"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/cherrybloomband"},"yt$userId":{"$t":"zxQk-rZGowoqMBKxGD5jSA"}}],"yt$accessControl":[{"action":"comment","permission":"allowed"},{"action":"commentVote","permission":"allowed"},{"action":"videoRespond","permission":"allowed"},{"action":"rate","permission":"allowed"},{"action":"embed","permission":"allowed"},{"action":"list","permission":"allowed"},{"action":"autoPlay","permission":"allowed"},{"action":"syndicate","permission":"allowed"}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/comments?v=2","countHint":15}},"media$group":{"media$category":[{"$t":"Music","label":"Music","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/mZqGqE0D0n4?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":175,"yt$format":5},{"url":"rtsp://r5---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQl-0gNNqIaamRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":175,"yt$format":1},{"url":"rtsp://r5---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQl-0gNNqIaamRMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":175,"yt$format":6}],"media$credit":[{"$t":"cherrybloomband","role":"uploader","scheme":"urn:youtube","yt$display":"cherrybloomband"}],"media$description":{"$t":"The
57
+ first video from the upcoming album Secret Sounds, to download in-stores April
58
+ 14. Checkout http://www.cherrybloom.net","type":"plain"},"media$keywords":{},"media$license":{"$t":"youtube","type":"text/html","href":"http://www.youtube.com/t/terms"},"media$player":{"url":"http://www.youtube.com/watch?v=mZqGqE0D0n4&feature=youtube_gdata_player"},"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/default.jpg","height":90,"width":120,"time":"00:01:27.500","yt$name":"default"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg","height":180,"width":320,"yt$name":"mqdefault"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg","height":360,"width":480,"yt$name":"hqdefault"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/1.jpg","height":90,"width":120,"time":"00:00:43.750","yt$name":"start"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/2.jpg","height":90,"width":120,"time":"00:01:27.500","yt$name":"middle"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/3.jpg","height":90,"width":120,"time":"00:02:11.250","yt$name":"end"}],"media$title":{"$t":"Cherry
59
+ Bloom - King Of The Knife","type":"plain"},"yt$duration":{"seconds":"175"},"yt$uploaded":{"$t":"2008-04-12T22:25:35.000Z"},"yt$uploaderId":{"$t":"UCzxQk-rZGowoqMBKxGD5jSA"},"yt$videoid":{"$t":"mZqGqE0D0n4"}},"gd$rating":{"average":4.822222,"max":5,"min":1,"numRaters":45,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"6243"},"yt$rating":{"numDislikes":"2","numLikes":"43"}}}'
60
+ http_version:
61
+ recorded_at: Mon, 07 Oct 2013 19:57:41 GMT
62
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,62 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4?alt=json&v=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - VideoInfo/1.5.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Gdata-User-Country:
22
+ - CH
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Expires:
28
+ - Mon, 07 Oct 2013 19:53:17 GMT
29
+ Date:
30
+ - Mon, 07 Oct 2013 19:53:17 GMT
31
+ Cache-Control:
32
+ - private, max-age=300, no-transform
33
+ Vary:
34
+ - '*'
35
+ Gdata-Version:
36
+ - '2.1'
37
+ Etag:
38
+ - W/"D0AFQH47eCp7I2A9WhBXE0g."
39
+ Last-Modified:
40
+ - Wed, 27 Mar 2013 03:41:51 GMT
41
+ X-Content-Type-Options:
42
+ - nosniff
43
+ X-Frame-Options:
44
+ - SAMEORIGIN
45
+ X-Xss-Protection:
46
+ - 1; mode=block
47
+ Content-Length:
48
+ - '4658'
49
+ Server:
50
+ - GSE
51
+ Alternate-Protocol:
52
+ - 80:quic
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"version":"1.0","encoding":"UTF-8","entry":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"D0AFQH47eCp7I2A9WhBXE0g.\"","id":{"$t":"tag:youtube.com,2008:video:mZqGqE0D0n4"},"published":{"$t":"2008-04-12T22:25:35.000Z"},"updated":{"$t":"2013-03-27T03:41:51.000Z"},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Music","label":"Music"}],"title":{"$t":"Cherry
56
+ Bloom - King Of The Knife"},"content":{"type":"application/x-shockwave-flash","src":"http://www.youtube.com/v/mZqGqE0D0n4?version=3&f=videos&app=youtube_gdata"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=mZqGqE0D0n4&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.responses","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/responses?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/related?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#uploader","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/zxQk-rZGowoqMBKxGD5jSA?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4?v=2"}],"author":[{"name":{"$t":"cherrybloomband"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/cherrybloomband"},"yt$userId":{"$t":"zxQk-rZGowoqMBKxGD5jSA"}}],"yt$accessControl":[{"action":"comment","permission":"allowed"},{"action":"commentVote","permission":"allowed"},{"action":"videoRespond","permission":"allowed"},{"action":"rate","permission":"allowed"},{"action":"embed","permission":"allowed"},{"action":"list","permission":"allowed"},{"action":"autoPlay","permission":"allowed"},{"action":"syndicate","permission":"allowed"}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/mZqGqE0D0n4/comments?v=2","countHint":15}},"media$group":{"media$category":[{"$t":"Music","label":"Music","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/mZqGqE0D0n4?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":175,"yt$format":5},{"url":"rtsp://r5---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQl-0gNNqIaamRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":175,"yt$format":1},{"url":"rtsp://r5---sn-5hn7su7k.c.youtube.com/CiILENy73wIaGQl-0gNNqIaamRMYESARFEgGUgZ2aWRlb3MM/0/0/0/video.3gp","type":"video/3gpp","medium":"video","expression":"full","duration":175,"yt$format":6}],"media$credit":[{"$t":"cherrybloomband","role":"uploader","scheme":"urn:youtube","yt$display":"cherrybloomband"}],"media$description":{"$t":"The
57
+ first video from the upcoming album Secret Sounds, to download in-stores April
58
+ 14. Checkout http://www.cherrybloom.net","type":"plain"},"media$keywords":{},"media$license":{"$t":"youtube","type":"text/html","href":"http://www.youtube.com/t/terms"},"media$player":{"url":"http://www.youtube.com/watch?v=mZqGqE0D0n4&feature=youtube_gdata_player"},"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/default.jpg","height":90,"width":120,"time":"00:01:27.500","yt$name":"default"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg","height":180,"width":320,"yt$name":"mqdefault"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg","height":360,"width":480,"yt$name":"hqdefault"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/1.jpg","height":90,"width":120,"time":"00:00:43.750","yt$name":"start"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/2.jpg","height":90,"width":120,"time":"00:01:27.500","yt$name":"middle"},{"url":"http://i1.ytimg.com/vi/mZqGqE0D0n4/3.jpg","height":90,"width":120,"time":"00:02:11.250","yt$name":"end"}],"media$title":{"$t":"Cherry
59
+ Bloom - King Of The Knife","type":"plain"},"yt$duration":{"seconds":"175"},"yt$uploaded":{"$t":"2008-04-12T22:25:35.000Z"},"yt$uploaderId":{"$t":"UCzxQk-rZGowoqMBKxGD5jSA"},"yt$videoid":{"$t":"mZqGqE0D0n4"}},"gd$rating":{"average":4.822222,"max":5,"min":1,"numRaters":45,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"6243"},"yt$rating":{"numDislikes":"2","numLikes":"43"}}}'
60
+ http_version:
61
+ recorded_at: Mon, 07 Oct 2013 19:57:41 GMT
62
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng?alt=json&v=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - VideoInfo/1.5.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Gdata-User-Country:
22
+ - CH
23
+ Content-Type:
24
+ - application/json; charset=UTF-8
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Expires:
28
+ - Mon, 07 Oct 2013 19:57:41 GMT
29
+ Date:
30
+ - Mon, 07 Oct 2013 19:57:41 GMT
31
+ Cache-Control:
32
+ - private, max-age=300, no-transform
33
+ Vary:
34
+ - '*'
35
+ Gdata-Version:
36
+ - '2.1'
37
+ Etag:
38
+ - W/"A0QARX47eCp7I2A9Wh5TF0U."
39
+ Last-Modified:
40
+ - Thu, 03 Oct 2013 08:35:44 GMT
41
+ Transfer-Encoding:
42
+ - chunked
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Frame-Options:
46
+ - SAMEORIGIN
47
+ X-Xss-Protection:
48
+ - 1; mode=block
49
+ Server:
50
+ - GSE
51
+ Alternate-Protocol:
52
+ - 80:quic
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"version":"1.0","encoding":"UTF-8","entry":{"xmlns$app":"http://www.w3.org/2007/app","xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"A0QARX47eCp7I2A9Wh5TF0U.\"","id":{"$t":"tag:youtube.com,2008:video:JM9NgvjjVng"},"published":{"$t":"2008-04-21T15:34:35.000Z"},"updated":{"$t":"2013-10-03T08:35:44.000Z"},"app$control":{"yt$state":{"$t":"Syndication
56
+ of this video was restricted.","name":"restricted","reasonCode":"limitedSyndication"}},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Music","label":"Music"}],"title":{"$t":"Amy
57
+ Macdonald - Poison Prince - 2008 Version"},"content":{"type":"application/x-shockwave-flash","src":"http://www.youtube.com/v/JM9NgvjjVng?version=3&f=videos&app=youtube_gdata"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=JM9NgvjjVng&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.responses","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/responses?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/related?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#uploader","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/4bQSvfzqx4r3YmPw3Osx3g?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng?v=2"}],"author":[{"name":{"$t":"amymacdonaldofficial"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/amymacdonaldofficial"},"yt$userId":{"$t":"4bQSvfzqx4r3YmPw3Osx3g"}}],"yt$accessControl":[{"action":"comment","permission":"allowed"},{"action":"commentVote","permission":"allowed"},{"action":"videoRespond","permission":"allowed"},{"action":"rate","permission":"allowed"},{"action":"embed","permission":"allowed"},{"action":"list","permission":"allowed"},{"action":"autoPlay","permission":"allowed"},{"action":"syndicate","permission":"denied"}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/comments?v=2","countHint":491}},"media$group":{"media$category":[{"$t":"Music","label":"Music","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/JM9NgvjjVng?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":217,"yt$format":5}],"media$credit":[{"$t":"amymacdonaldofficial","role":"uploader","scheme":"urn:youtube","yt$display":"amymacdonaldofficial","yt$type":"partner"}],"media$description":{"$t":"See
58
+ the brand new video to Amy''s new single ''Poison Prince'' out May 19th 2008...\n\nFacebook:
59
+ https://www.facebook.com/amymacdonaldmusic\nTwitter: https://twitter.com/#!/Amy__Macdonald\nOfficial
60
+ Site: http://www.amymacdonald.co.uk\nMailing List: http://bit.ly/KciMZh \niTunes:
61
+ http://bit.ly/JjnaKw","type":"plain"},"media$keywords":{},"media$license":{"$t":"youtube","type":"text/html","href":"http://www.youtube.com/t/terms"},"media$player":{"url":"http://www.youtube.com/watch?v=JM9NgvjjVng&feature=youtube_gdata_player"},"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/default.jpg","height":90,"width":120,"time":"00:01:48.500","yt$name":"default"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/mqdefault.jpg","height":180,"width":320,"yt$name":"mqdefault"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/hqdefault.jpg","height":360,"width":480,"yt$name":"hqdefault"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/1.jpg","height":90,"width":120,"time":"00:00:54.250","yt$name":"start"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/2.jpg","height":90,"width":120,"time":"00:01:48.500","yt$name":"middle"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/3.jpg","height":90,"width":120,"time":"00:02:42.750","yt$name":"end"}],"media$title":{"$t":"Amy
62
+ Macdonald - Poison Prince - 2008 Version","type":"plain"},"yt$duration":{"seconds":"217"},"yt$uploaded":{"$t":"2008-04-21T15:34:35.000Z"},"yt$uploaderId":{"$t":"UC4bQSvfzqx4r3YmPw3Osx3g"},"yt$videoid":{"$t":"JM9NgvjjVng"}},"gd$rating":{"average":4.885831,"max":5,"min":1,"numRaters":1962,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"1662045"},"yt$rating":{"numDislikes":"56","numLikes":"1906"}}}'
63
+ http_version:
64
+ recorded_at: Mon, 07 Oct 2013 19:57:41 GMT
65
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,65 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng?alt=json&v=2
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - VideoInfo/1.5.0
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ Accept:
15
+ - '*/*'
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ X-Gdata-User-Country:
22
+ - CH
23
+ Content-Type:
24
+ - application/json; charset=UTF-8
25
+ Access-Control-Allow-Origin:
26
+ - '*'
27
+ Expires:
28
+ - Mon, 07 Oct 2013 19:57:41 GMT
29
+ Date:
30
+ - Mon, 07 Oct 2013 19:57:41 GMT
31
+ Cache-Control:
32
+ - private, max-age=300, no-transform
33
+ Vary:
34
+ - '*'
35
+ Gdata-Version:
36
+ - '2.1'
37
+ Etag:
38
+ - W/"A0QARX47eCp7I2A9Wh5TF0U."
39
+ Last-Modified:
40
+ - Thu, 03 Oct 2013 08:35:44 GMT
41
+ Transfer-Encoding:
42
+ - chunked
43
+ X-Content-Type-Options:
44
+ - nosniff
45
+ X-Frame-Options:
46
+ - SAMEORIGIN
47
+ X-Xss-Protection:
48
+ - 1; mode=block
49
+ Server:
50
+ - GSE
51
+ Alternate-Protocol:
52
+ - 80:quic
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"version":"1.0","encoding":"UTF-8","entry":{"xmlns$app":"http://www.w3.org/2007/app","xmlns":"http://www.w3.org/2005/Atom","xmlns$media":"http://search.yahoo.com/mrss/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$yt":"http://gdata.youtube.com/schemas/2007","gd$etag":"W/\"A0QARX47eCp7I2A9Wh5TF0U.\"","id":{"$t":"tag:youtube.com,2008:video:JM9NgvjjVng"},"published":{"$t":"2008-04-21T15:34:35.000Z"},"updated":{"$t":"2013-10-03T08:35:44.000Z"},"app$control":{"yt$state":{"$t":"Syndication
56
+ of this video was restricted.","name":"restricted","reasonCode":"limitedSyndication"}},"category":[{"scheme":"http://schemas.google.com/g/2005#kind","term":"http://gdata.youtube.com/schemas/2007#video"},{"scheme":"http://gdata.youtube.com/schemas/2007/categories.cat","term":"Music","label":"Music"}],"title":{"$t":"Amy
57
+ Macdonald - Poison Prince - 2008 Version"},"content":{"type":"application/x-shockwave-flash","src":"http://www.youtube.com/v/JM9NgvjjVng?version=3&f=videos&app=youtube_gdata"},"link":[{"rel":"alternate","type":"text/html","href":"http://www.youtube.com/watch?v=JM9NgvjjVng&feature=youtube_gdata"},{"rel":"http://gdata.youtube.com/schemas/2007#video.responses","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/responses?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#video.related","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/related?v=2"},{"rel":"http://gdata.youtube.com/schemas/2007#uploader","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/users/4bQSvfzqx4r3YmPw3Osx3g?v=2"},{"rel":"self","type":"application/atom+xml","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng?v=2"}],"author":[{"name":{"$t":"amymacdonaldofficial"},"uri":{"$t":"http://gdata.youtube.com/feeds/api/users/amymacdonaldofficial"},"yt$userId":{"$t":"4bQSvfzqx4r3YmPw3Osx3g"}}],"yt$accessControl":[{"action":"comment","permission":"allowed"},{"action":"commentVote","permission":"allowed"},{"action":"videoRespond","permission":"allowed"},{"action":"rate","permission":"allowed"},{"action":"embed","permission":"allowed"},{"action":"list","permission":"allowed"},{"action":"autoPlay","permission":"allowed"},{"action":"syndicate","permission":"denied"}],"gd$comments":{"gd$feedLink":{"rel":"http://gdata.youtube.com/schemas/2007#comments","href":"http://gdata.youtube.com/feeds/api/videos/JM9NgvjjVng/comments?v=2","countHint":491}},"media$group":{"media$category":[{"$t":"Music","label":"Music","scheme":"http://gdata.youtube.com/schemas/2007/categories.cat"}],"media$content":[{"url":"http://www.youtube.com/v/JM9NgvjjVng?version=3&f=videos&app=youtube_gdata","type":"application/x-shockwave-flash","medium":"video","isDefault":"true","expression":"full","duration":217,"yt$format":5}],"media$credit":[{"$t":"amymacdonaldofficial","role":"uploader","scheme":"urn:youtube","yt$display":"amymacdonaldofficial","yt$type":"partner"}],"media$description":{"$t":"See
58
+ the brand new video to Amy''s new single ''Poison Prince'' out May 19th 2008...\n\nFacebook:
59
+ https://www.facebook.com/amymacdonaldmusic\nTwitter: https://twitter.com/#!/Amy__Macdonald\nOfficial
60
+ Site: http://www.amymacdonald.co.uk\nMailing List: http://bit.ly/KciMZh \niTunes:
61
+ http://bit.ly/JjnaKw","type":"plain"},"media$keywords":{},"media$license":{"$t":"youtube","type":"text/html","href":"http://www.youtube.com/t/terms"},"media$player":{"url":"http://www.youtube.com/watch?v=JM9NgvjjVng&feature=youtube_gdata_player"},"media$thumbnail":[{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/default.jpg","height":90,"width":120,"time":"00:01:48.500","yt$name":"default"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/mqdefault.jpg","height":180,"width":320,"yt$name":"mqdefault"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/hqdefault.jpg","height":360,"width":480,"yt$name":"hqdefault"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/1.jpg","height":90,"width":120,"time":"00:00:54.250","yt$name":"start"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/2.jpg","height":90,"width":120,"time":"00:01:48.500","yt$name":"middle"},{"url":"http://i1.ytimg.com/vi/JM9NgvjjVng/3.jpg","height":90,"width":120,"time":"00:02:42.750","yt$name":"end"}],"media$title":{"$t":"Amy
62
+ Macdonald - Poison Prince - 2008 Version","type":"plain"},"yt$duration":{"seconds":"217"},"yt$uploaded":{"$t":"2008-04-21T15:34:35.000Z"},"yt$uploaderId":{"$t":"UC4bQSvfzqx4r3YmPw3Osx3g"},"yt$videoid":{"$t":"JM9NgvjjVng"}},"gd$rating":{"average":4.885831,"max":5,"min":1,"numRaters":1962,"rel":"http://schemas.google.com/g/2005#overall"},"yt$statistics":{"favoriteCount":"0","viewCount":"1662045"},"yt$rating":{"numDislikes":"56","numLikes":"1906"}}}'
63
+ http_version:
64
+ recorded_at: Mon, 07 Oct 2013 19:57:41 GMT
65
+ recorded_with: VCR 2.5.0
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ describe VideoInfo::Provider do
4
+
5
+ class ProviderFu < VideoInfo::Provider
6
+ def _url_regex
7
+ /foo\/(\d)/
8
+ end
9
+ end
10
+
11
+ describe "initialize" do
12
+ let(:url) { 'url' }
13
+ let(:options) { { } }
14
+ let(:provider) { ProviderFu.new(url, options) }
15
+
16
+ it { expect { VideoInfo::Provider.new(url) }.to raise_error(NotImplementedError, 'Provider class must implement #_url_regex private method') }
17
+ it { expect { ProviderFu.new('foo/1') }.to raise_error(NotImplementedError, 'Provider class must implement #_api_url private method') }
18
+
19
+ it "sets default user_agent options" do
20
+ provider.options.should eq({ 'User-Agent' => "VideoInfo/#{VideoInfo::VERSION}" })
21
+ end
22
+
23
+ context "with custom User-Agent options" do
24
+ let(:options) { { 'User-Agent' => 'Test User Agent / 1.0' } }
25
+
26
+ it "sets the option" do
27
+ provider.options.should eq({ 'User-Agent' => 'Test User Agent / 1.0' })
28
+ end
29
+ end
30
+
31
+ context "with Referer options" do
32
+ let(:options) { { :referer => 'http://google.com' } }
33
+
34
+ it "sets the option" do
35
+ provider.options.should include({ 'Referer' => 'http://google.com' })
36
+ end
37
+ end
38
+ end
39
+
40
+ describe ".usable?" do
41
+ it { expect { VideoInfo::Provider.usable?('url') }.to raise_error(NotImplementedError, 'Provider class must implement .usable? public method') }
42
+ end
43
+
44
+ end
@@ -0,0 +1,74 @@
1
+ require 'spec_helper'
2
+
3
+ describe VideoInfo::Providers::Vimeo do
4
+
5
+ describe ".usable?" do
6
+ subject { VideoInfo::Providers::Vimeo.usable?(url) }
7
+
8
+ context "with vimeo url" do
9
+ let(:url) { 'http://www.vimeo.com/898029' }
10
+ it { should be_true }
11
+ end
12
+
13
+ context "with other url" do
14
+ let(:url) { 'http://www.youtube.com/898029' }
15
+ it { should be_false }
16
+ end
17
+ end
18
+
19
+ context "with video 898029", :vcr do
20
+ subject { VideoInfo.get('http://www.vimeo.com/898029') }
21
+
22
+ its(:provider) { should eq 'Vimeo' }
23
+ its(:video_id) { should eq '898029' }
24
+ its(:url) { should eq 'http://vimeo.com/898029' }
25
+ its(:embed_url) { should eq 'http://player.vimeo.com/video/898029' }
26
+ its(:embed_code) { should eq '<iframe src="http://player.vimeo.com/video/898029?autoplay=0&byline=0&portrait=0&title=0" frameborder="0"></iframe>' }
27
+ its(:title) { should eq 'Cherry Bloom - King Of The Knife' }
28
+ its(:description) { should eq 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
29
+ its(:keywords) { should eq 'cherry bloom, secret sounds, king of the knife, rock, alternative' }
30
+ its(:duration) { should eq 175 }
31
+ its(:width) { should eq 640 }
32
+ its(:height) { should eq 360 }
33
+ its(:date) { should eq Time.parse('2008-04-14 13:10:39', Time.now.utc) }
34
+ its(:thumbnail_small) { should eq 'http://b.vimeocdn.com/ts/343/731/34373130_100.jpg' }
35
+ its(:thumbnail_medium) { should eq 'http://b.vimeocdn.com/ts/343/731/34373130_200.jpg' }
36
+ its(:thumbnail_large) { should eq 'http://b.vimeocdn.com/ts/343/731/34373130_640.jpg' }
37
+ its(:view_count) { should be > 4000 }
38
+ end
39
+
40
+ context "with video 898029 and url_attributes", :vcr do
41
+ subject { VideoInfo.get('http://www.vimeo.com/898029') }
42
+
43
+ it { subject.embed_code(:url_attributes => { :autoplay => 1 }).should match(/autoplay=1/) }
44
+ end
45
+
46
+ context "with video 898029 and iframe_attributes", :vcr do
47
+ subject { VideoInfo.get('http://www.vimeo.com/898029') }
48
+
49
+ it { subject.embed_code(:iframe_attributes => { :width => 800, :height => 600 }).should match(/width="800"/) }
50
+ it { subject.embed_code(:iframe_attributes => { :width => 800, :height => 600 }).should match(/height="600"/) }
51
+ end
52
+
53
+ context "with video 898029 in /group/ url", :vcr do
54
+ subject { VideoInfo.get('http://vimeo.com/groups/1234/videos/898029') }
55
+
56
+ its(:provider) { should eq 'Vimeo' }
57
+ its(:video_id) { should eq '898029' }
58
+ end
59
+
60
+ context "with video 898029 in /group/ url", :vcr do
61
+ subject { VideoInfo.get('http://player.vimeo.com/video/898029') }
62
+
63
+ its(:provider) { should eq 'Vimeo' }
64
+ its(:video_id) { should eq '898029' }
65
+ end
66
+
67
+ context "with video 898029 in text", :vcr do
68
+ subject { VideoInfo.get('<a href="http://www.vimeo.com/898029">http://www.vimeo.com/898029</a>') }
69
+
70
+ its(:provider) { should eq 'Vimeo' }
71
+ its(:video_id) { should eq '898029' }
72
+ end
73
+
74
+ end
@@ -0,0 +1,38 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe VideoInfo::Providers::Vkontakte do
6
+
7
+ describe ".usable?" do
8
+ subject { VideoInfo::Providers::Vkontakte.usable?(url) }
9
+
10
+ context "with vkontakte url" do
11
+ let(:url) { 'http://vk.com/video39576223_108370515' }
12
+ it { should be_true }
13
+ end
14
+
15
+ context "with other url" do
16
+ let(:url) { 'http://www.youtube.com/898029' }
17
+ it { should be_false }
18
+ end
19
+ end
20
+
21
+ context "with video 39576223_108370515", :vcr do
22
+ subject { VideoInfo.get('http://vk.com/video39576223_108370515') }
23
+
24
+ its(:provider) { should eq 'Vkontakte' }
25
+ its(:video_owner) { should eq '39576223' }
26
+ its(:video_id) { should eq '108370515' }
27
+ its(:url) { should eq 'http://vk.com/video39576223_108370515' }
28
+ its(:embed_url) { should eq 'http://vk.com/video_ext.php?oid=39576223&id=108370515&hash=15184dbd085c47af' }
29
+ its(:embed_code) { should eq '<iframe src="http://vk.com/video_ext.php?oid=39576223&id=108370515&hash=15184dbd085c47af" frameborder="0" allowfullscreen="allowfullscreen"></iframe>' }
30
+ its(:title) { should eq 'Я уточка)))))' }
31
+ its(:description) { should eq 'это ВЗРЫВ МОЗГА!!! Просто отвал башки...' }
32
+ its(:duration) { should eq 183 }
33
+ its(:width) { should eq 320 }
34
+ its(:height) { should eq 240 }
35
+ its(:view_count) { should be > 10 }
36
+ end
37
+
38
+ end
@@ -0,0 +1,138 @@
1
+ require 'spec_helper'
2
+
3
+ describe VideoInfo::Providers::Youtube do
4
+
5
+ describe ".usable?" do
6
+ subject { VideoInfo::Providers::Youtube.usable?(url) }
7
+
8
+ context "with youtube.com url" do
9
+ let(:url) { 'http://www.youtube.com/watch?v=Xp6CXF' }
10
+ it { should be_true }
11
+ end
12
+
13
+ context "with youtu.be url" do
14
+ let(:url) { 'http://youtu.be/JM9NgvjjVng' }
15
+ it { should be_true }
16
+ end
17
+
18
+ context "with other url" do
19
+ let(:url) { 'http://google.com/video1' }
20
+ it { should be_false }
21
+ end
22
+ end
23
+
24
+ context "with video mZqGqE0D0n4", :vcr do
25
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
26
+
27
+ its(:provider) { should eq 'YouTube' }
28
+ its(:video_id) { should eq 'mZqGqE0D0n4' }
29
+ its(:url) { should eq 'http://www.youtube.com/watch?v=mZqGqE0D0n4' }
30
+ its(:embed_url) { should eq 'http://www.youtube.com/embed/mZqGqE0D0n4' }
31
+ its(:embed_code) { should eq '<iframe src="http://www.youtube.com/embed/mZqGqE0D0n4" frameborder="0" allowfullscreen="allowfullscreen"></iframe>' }
32
+ its(:title) { should eq 'Cherry Bloom - King Of The Knife' }
33
+ its(:description) { should eq 'The first video from the upcoming album Secret Sounds, to download in-stores April 14. Checkout http://www.cherrybloom.net' }
34
+ its(:keywords) { should be_nil }
35
+ its(:duration) { should eq 175 }
36
+ its(:width) { should be_nil }
37
+ its(:height) { should be_nil }
38
+ its(:date) { should eq Time.parse('Sat Apr 12 22:25:35 UTC 2008', Time.now.utc) }
39
+ its(:thumbnail_small) { should eq 'http://i1.ytimg.com/vi/mZqGqE0D0n4/default.jpg' }
40
+ its(:thumbnail_medium) { should eq 'http://i1.ytimg.com/vi/mZqGqE0D0n4/mqdefault.jpg' }
41
+ its(:thumbnail_large) { should eq 'http://i1.ytimg.com/vi/mZqGqE0D0n4/hqdefault.jpg' }
42
+ its(:view_count) { should be > 4000 }
43
+ end
44
+
45
+ context "with video oQ49W_xKzKA", :vcr do
46
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
47
+
48
+ it { subject.embed_code(:url_attributes => { :autoplay => 1 }).should match(/autoplay=1/) }
49
+ end
50
+
51
+ context "with video oQ49W_xKzKA", :vcr do
52
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=oQ49W_xKzKA') }
53
+
54
+ its(:provider) { should eq 'YouTube' }
55
+ its(:video_id) { should eq 'oQ49W_xKzKA' }
56
+ end
57
+
58
+ context "with video Xp6CXF-Cesg", :vcr do
59
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=Xp6CXF-Cesg') }
60
+
61
+ its(:provider) { should eq 'YouTube' }
62
+ its(:video_id) { should eq 'Xp6CXF-Cesg' }
63
+ end
64
+
65
+ context "with video VeasFckfMHY in user url", :vcr do
66
+ subject { VideoInfo.get('http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY') }
67
+
68
+ its(:provider) { should eq 'YouTube' }
69
+ its(:video_id) { should eq 'VeasFckfMHY' }
70
+ its(:url) { should eq 'http://www.youtube.com/user/EducatorVids3?v=VeasFckfMHY' }
71
+ end
72
+
73
+ context "with video VeasFckfMHY after params", :vcr do
74
+ subject { VideoInfo.get('http://www.youtube.com/watch?feature=player_profilepage&v=VeasFckfMHY') }
75
+
76
+ its(:provider) { should eq 'YouTube' }
77
+ its(:video_id) { should eq 'VeasFckfMHY' }
78
+ its(:url) { should eq 'http://www.youtube.com/watch?feature=player_profilepage&v=VeasFckfMHY' }
79
+ end
80
+
81
+ context "with video VeasFckfMHY in path", :vcr do
82
+ subject { VideoInfo.get('http://www.youtube.com/v/VeasFckfMHY') }
83
+
84
+ its(:provider) { should eq 'YouTube' }
85
+ its(:video_id) { should eq 'VeasFckfMHY' }
86
+ end
87
+
88
+ context "with video VeasFckfMHY in e path", :vcr do
89
+ subject { VideoInfo.get('http://www.youtube.com/e/VeasFckfMHY') }
90
+
91
+ its(:provider) { should eq 'YouTube' }
92
+ its(:video_id) { should eq 'VeasFckfMHY' }
93
+ end
94
+
95
+ context "with video VeasFckfMHY in embed path", :vcr do
96
+ subject { VideoInfo.get('http://www.youtube.com/embed/VeasFckfMHY') }
97
+
98
+ its(:provider) { should eq 'YouTube' }
99
+ its(:video_id) { should eq 'VeasFckfMHY' }
100
+ end
101
+
102
+ context "with video JM9NgvjjVng in youtu.be url", :vcr do
103
+ subject { VideoInfo.get('http://youtu.be/JM9NgvjjVng') }
104
+
105
+ its(:provider) { should eq 'YouTube' }
106
+ its(:video_id) { should eq 'JM9NgvjjVng' }
107
+ end
108
+
109
+ context 'without http or www', :vcr do
110
+ subject { VideoInfo.get('youtu.be/JM9NgvjjVng') }
111
+
112
+ its(:provider) { should == 'YouTube' }
113
+ its(:video_id) { should eq 'JM9NgvjjVng' }
114
+ end
115
+
116
+ context "with video url in text", :vcr do
117
+ subject { VideoInfo.get('<a href="http://www.youtube.com/watch?v=mZqGqE0D0n4">http://www.youtube.com/watch?v=mZqGqE0D0n4</a>') }
118
+
119
+ its(:provider) { should == 'YouTube' }
120
+ its(:video_id) { should == 'mZqGqE0D0n4' }
121
+ end
122
+
123
+ context "with iframe attributes", :vcr do
124
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
125
+
126
+ its(:provider) { should == 'YouTube' }
127
+ it { subject.embed_code(:iframe_attributes => { :width => 800, :height => 600 }).should match(/width="800"/) }
128
+ it { subject.embed_code(:iframe_attributes => { :width => 800, :height => 600 }).should match(/height="600"/) }
129
+ end
130
+
131
+ context "with arbitrary iframe_attributes", :vcr do
132
+ subject { VideoInfo.get('http://www.youtube.com/watch?v=mZqGqE0D0n4') }
133
+
134
+ its(:provider) { should == 'YouTube' }
135
+ it { subject.embed_code(:iframe_attributes => { :'data-colorbox' => true }).should match(/data-colorbox="true"/) }
136
+ end
137
+
138
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe VideoInfo do
4
+
5
+ describe ".get" do
6
+ let(:url) { 'url' }
7
+ let(:options) { { :foo => :bar } }
8
+ let(:provider) { double('provider') }
9
+
10
+ it "uses the first usable provider" do
11
+ VideoInfo::Providers::Vimeo.should_receive(:usable?).with(url) { false }
12
+ VideoInfo::Providers::Vkontakte.should_receive(:usable?).with(url) { false }
13
+ VideoInfo::Providers::Youtube.should_receive(:usable?).with(url) { true }
14
+ VideoInfo::Providers::Youtube.should_receive(:new).with(url, options) { provider }
15
+
16
+ VideoInfo.get(url, options).should eq provider
17
+ end
18
+
19
+ it "returns nil when no providers are usable" do
20
+ VideoInfo::Providers::Vimeo.should_receive(:usable?).with(url) { false }
21
+ VideoInfo::Providers::Vkontakte.should_receive(:usable?).with(url) { false }
22
+ VideoInfo::Providers::Youtube.should_receive(:usable?).with(url) { false }
23
+
24
+ VideoInfo.get(url, options).should be_nil
25
+ end
26
+ end
27
+
28
+ describe ".usable?" do
29
+ let(:url) { 'url' }
30
+ let(:options) { { :foo => :bar } }
31
+ let(:provider) { double('provider') }
32
+
33
+ it "returns true when a provider is usable" do
34
+ VideoInfo::Providers::Vimeo.should_receive(:usable?).with(url) { false }
35
+ VideoInfo::Providers::Vkontakte.should_receive(:usable?).with(url) { false }
36
+ VideoInfo::Providers::Youtube.should_receive(:usable?).with(url) { true }
37
+
38
+ VideoInfo.usable?(url).should be_true
39
+ end
40
+
41
+ it "returns false when no providers are usable" do
42
+ VideoInfo::Providers::Vimeo.should_receive(:usable?).with(url) { false }
43
+ VideoInfo::Providers::Vkontakte.should_receive(:usable?).with(url) { false }
44
+ VideoInfo::Providers::Youtube.should_receive(:usable?).with(url) { false }
45
+
46
+ VideoInfo.usable?(url).should be_false
47
+ end
48
+ end
49
+
50
+ end