youtube-g-es 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/History.txt +45 -0
- data/Manifest.txt +28 -0
- data/README.txt +86 -0
- data/TODO.txt +16 -0
- data/lib/youtube_g.rb +29 -0
- data/lib/youtube_g/client.rb +85 -0
- data/lib/youtube_g/logger.rb +25 -0
- data/lib/youtube_g/model/author.rb +11 -0
- data/lib/youtube_g/model/category.rb +11 -0
- data/lib/youtube_g/model/contact.rb +16 -0
- data/lib/youtube_g/model/content.rb +18 -0
- data/lib/youtube_g/model/playlist.rb +8 -0
- data/lib/youtube_g/model/rating.rb +17 -0
- data/lib/youtube_g/model/thumbnail.rb +17 -0
- data/lib/youtube_g/model/user.rb +20 -0
- data/lib/youtube_g/model/video.rb +190 -0
- data/lib/youtube_g/parser.rb +169 -0
- data/lib/youtube_g/record.rb +12 -0
- data/lib/youtube_g/request/base_search.rb +43 -0
- data/lib/youtube_g/request/standard_search.rb +40 -0
- data/lib/youtube_g/request/user_search.rb +42 -0
- data/lib/youtube_g/request/video_search.rb +93 -0
- data/lib/youtube_g/request/video_upload.rb +130 -0
- data/lib/youtube_g/response/video_search.rb +41 -0
- data/test/test_client.rb +268 -0
- data/test/test_video.rb +42 -0
- data/test/test_video_search.rb +138 -0
- data/youtube-g-es.gemspec +52 -0
- metadata +80 -0
data/test/test_video.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
require 'youtube_g'
|
6
|
+
|
7
|
+
class TestVideo < Test::Unit::TestCase
|
8
|
+
def test_should_extract_unique_id_from_video_id
|
9
|
+
video = YouTubeG::Model::Video.new(:video_id => "http://gdata.youtube.com/feeds/videos/ZTUVgYoeN_o")
|
10
|
+
assert_equal "ZTUVgYoeN_o", video.unique_id
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_should_extract_unique_id_with_hypen_from_video_id
|
14
|
+
video = YouTubeG::Model::Video.new(:video_id => "http://gdata.youtube.com/feeds/videos/BDqs-OZWw9o")
|
15
|
+
assert_equal "BDqs-OZWw9o", video.unique_id
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_should_have_related_videos
|
19
|
+
video = YouTubeG::Model::Video.new(:video_id => "http://gdata.youtube.com/feeds/videos/BDqs-OZWw9o")
|
20
|
+
response = video.related
|
21
|
+
|
22
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/BDqs-OZWw9o/related", response.feed_id
|
23
|
+
assert_equal 25, response.max_result_count
|
24
|
+
assert_equal 25, response.videos.length
|
25
|
+
assert_equal 1, response.offset
|
26
|
+
assert(response.total_result_count > 0)
|
27
|
+
assert_instance_of Time, response.updated_at
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_should_have_response_videos
|
31
|
+
video = YouTubeG::Model::Video.new(:video_id => "http://gdata.youtube.com/feeds/videos/BDqs-OZWw9o")
|
32
|
+
response = video.responses
|
33
|
+
|
34
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/BDqs-OZWw9o/responses", response.feed_id
|
35
|
+
assert_equal 25, response.max_result_count
|
36
|
+
assert_equal 25, response.videos.length
|
37
|
+
assert_equal 1, response.offset
|
38
|
+
assert(response.total_result_count > 0)
|
39
|
+
assert_instance_of Time, response.updated_at
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,138 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
require 'youtube_g'
|
6
|
+
|
7
|
+
class TestVideoSearch < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_should_build_basic_query_url
|
10
|
+
request = YouTubeG::Request::VideoSearch.new(:query => "penguin")
|
11
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=penguin", request.url
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_build_multiword_metasearch_query_url
|
15
|
+
request = YouTubeG::Request::VideoSearch.new(:query => 'christina ricci')
|
16
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos?vq=christina+ricci", request.url
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_should_build_video_id_url
|
20
|
+
request = YouTubeG::Request::VideoSearch.new(:video_id => 'T7YazwP8GtY')
|
21
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/T7YazwP8GtY", request.url
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_should_build_one_tag_querl_url
|
25
|
+
request = YouTubeG::Request::VideoSearch.new(:tags => ['panther'])
|
26
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/panther/", request.url
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_should_build_multiple_tags_query_url
|
30
|
+
request = YouTubeG::Request::VideoSearch.new(:tags => ['tiger', 'leopard'])
|
31
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/tiger/leopard/", request.url
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_should_build_one_category_query_url
|
35
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => [:news])
|
36
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/", request.url
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_should_build_multiple_categories_query_url
|
40
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports])
|
41
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/", request.url
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_should_build_categories_and_tags_query_url
|
45
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => [:news, :sports], :tags => ['soccer', 'football'])
|
46
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News/Sports/soccer/football/", request.url
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_should_build_categories_and_tags_url_with_max_results
|
50
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => [:music], :tags => ['classic', 'rock'], :max_results => 2)
|
51
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/Music/classic/rock/?max-results=2", request.url
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_should_build_author_query_url
|
55
|
+
request = YouTubeG::Request::VideoSearch.new(:author => "davidguetta")
|
56
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos?author=davidguetta", request.url
|
57
|
+
end
|
58
|
+
# -- Standard Feeds --------------------------------------------------------------------------------
|
59
|
+
|
60
|
+
def test_should_build_url_for_most_viewed
|
61
|
+
request = YouTubeG::Request::StandardSearch.new(:most_viewed)
|
62
|
+
assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed", request.url
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_should_build_url_for_top_rated_for_today
|
66
|
+
request = YouTubeG::Request::StandardSearch.new(:top_rated, :time => :today)
|
67
|
+
assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?time=today", request.url
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_should_build_url_for_most_viewed_offset_and_max_results_without_time
|
71
|
+
request = YouTubeG::Request::StandardSearch.new(:top_rated, :offset => 5, :max_results => 10)
|
72
|
+
assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=10&start-index=5", request.url
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_should_build_url_for_most_viewed_offset_and_max_results_with_time
|
76
|
+
request = YouTubeG::Request::StandardSearch.new(:top_rated, :offset => 5, :max_results => 10, :time => :today)
|
77
|
+
assert_equal "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?max-results=10&start-index=5&time=today", request.url
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_should_raise_exception_for_invalid_type
|
81
|
+
assert_raise RuntimeError do
|
82
|
+
request = YouTubeG::Request::StandardSearch.new(:most_viewed_yo)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# -- Complex Video Queries -------------------------------------------------------------------------
|
87
|
+
|
88
|
+
def test_should_build_url_for_boolean_or_case_for_categories
|
89
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports] })
|
90
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/", request.url
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_should_build_url_for_boolean_or_and_exclude_case_for_categories
|
94
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] })
|
95
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/", request.url
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_should_build_url_for_exclude_case_for_tags
|
99
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
|
100
|
+
:tags => { :include => ['football'], :exclude => ['soccer'] })
|
101
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/football/-soccer/", request.url
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_should_build_url_for_either_case_for_tags
|
105
|
+
request = YouTubeG::Request::VideoSearch.new(:categories => { :either => [:news, :sports], :exclude => [:comedy] },
|
106
|
+
:tags => { :either => ['soccer', 'football', 'donkey'] })
|
107
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/News%7CSports/-Comedy/soccer%7Cfootball%7Cdonkey/", request.url
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_should_build_url_for_query_search_with_categories_excluded
|
111
|
+
request = YouTubeG::Request::VideoSearch.new(:query => 'bench press',
|
112
|
+
:categories => { :exclude => [:comedy, :entertainment] },
|
113
|
+
:max_results => 10)
|
114
|
+
assert_equal "http://gdata.youtube.com/feeds/api/videos/-/-Comedy/-Entertainment/?max-results=10&vq=bench+press", request.url
|
115
|
+
end
|
116
|
+
|
117
|
+
# -- User Queries ---------------------------------------------------------------------------------
|
118
|
+
|
119
|
+
def test_should_build_url_for_videos_by_user
|
120
|
+
request = YouTubeG::Request::UserSearch.new(:user => 'liz')
|
121
|
+
assert_equal "http://gdata.youtube.com/feeds/api/users/liz/uploads", request.url
|
122
|
+
end
|
123
|
+
|
124
|
+
def test_should_build_url_for_videos_by_user_paginate_and_order
|
125
|
+
request = YouTubeG::Request::UserSearch.new(:user => 'liz', :offset => 20, :max_results => 10, :order_by => 'published')
|
126
|
+
assert_equal "http://gdata.youtube.com/feeds/api/users/liz/uploads?max-results=10&orderby=published&start-index=20", request.url
|
127
|
+
end
|
128
|
+
|
129
|
+
def test_should_build_url_for_favorite_videos_by_user
|
130
|
+
request = YouTubeG::Request::UserSearch.new(:favorites, :user => 'liz')
|
131
|
+
assert_equal "http://gdata.youtube.com/feeds/api/users/liz/favorites", request.url
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_should_build_url_for_favorite_videos_by_user_paginate
|
135
|
+
request = YouTubeG::Request::UserSearch.new(:favorites, :user => 'liz', :offset => 20, :max_results => 10)
|
136
|
+
assert_equal "http://gdata.youtube.com/feeds/api/users/liz/favorites?max-results=10&start-index=20", request.url
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
spec = Gem::Specification.new do |s|
|
2
|
+
s.name = 'youtube-g-es'
|
3
|
+
s.version = '0.5.1'
|
4
|
+
s.date = '2016-09-28'
|
5
|
+
s.summary = 'An object-oriented Ruby wrapper for the YouTube GData API'
|
6
|
+
s.email = "ruby-youtube-library@googlegroups.com"
|
7
|
+
s.homepage = "http://youtube-g.rubyforge.org/"
|
8
|
+
s.description = "An object-oriented Ruby wrapper for the YouTube GData API"
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.authors = ["Shane Vitarana", "Walter Korman", "Aman Gupta", "Filip H.F. Slagter"]
|
11
|
+
|
12
|
+
# ruby -rpp -e "pp Dir['**/*.*'].map"
|
13
|
+
s.files = [
|
14
|
+
"History.txt",
|
15
|
+
"lib/youtube_g/client.rb",
|
16
|
+
"lib/youtube_g/logger.rb",
|
17
|
+
"lib/youtube_g/model/author.rb",
|
18
|
+
"lib/youtube_g/model/category.rb",
|
19
|
+
"lib/youtube_g/model/contact.rb",
|
20
|
+
"lib/youtube_g/model/content.rb",
|
21
|
+
"lib/youtube_g/model/playlist.rb",
|
22
|
+
"lib/youtube_g/model/rating.rb",
|
23
|
+
"lib/youtube_g/model/thumbnail.rb",
|
24
|
+
"lib/youtube_g/model/user.rb",
|
25
|
+
"lib/youtube_g/model/video.rb",
|
26
|
+
"lib/youtube_g/parser.rb",
|
27
|
+
"lib/youtube_g/record.rb",
|
28
|
+
"lib/youtube_g/request/base_search.rb",
|
29
|
+
"lib/youtube_g/request/standard_search.rb",
|
30
|
+
"lib/youtube_g/request/user_search.rb",
|
31
|
+
"lib/youtube_g/request/video_search.rb",
|
32
|
+
"lib/youtube_g/request/video_upload.rb",
|
33
|
+
"lib/youtube_g/response/video_search.rb",
|
34
|
+
"lib/youtube_g.rb",
|
35
|
+
"Manifest.txt",
|
36
|
+
"README.txt",
|
37
|
+
"test/test_client.rb",
|
38
|
+
"test/test_video.rb",
|
39
|
+
"test/test_video_search.rb",
|
40
|
+
"TODO.txt",
|
41
|
+
"youtube-g-es.gemspec"
|
42
|
+
]
|
43
|
+
|
44
|
+
s.test_files = [
|
45
|
+
"test/test_client.rb",
|
46
|
+
"test/test_video.rb",
|
47
|
+
"test/test_video_search.rb"
|
48
|
+
]
|
49
|
+
|
50
|
+
s.rdoc_options = ["--main", "README.txt"]
|
51
|
+
s.extra_rdoc_files = ["History.txt", "README.txt"]
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: youtube-g-es
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shane Vitarana
|
8
|
+
- Walter Korman
|
9
|
+
- Aman Gupta
|
10
|
+
- Filip H.F. Slagter
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2016-09-28 00:00:00.000000000 Z
|
15
|
+
dependencies: []
|
16
|
+
description: An object-oriented Ruby wrapper for the YouTube GData API
|
17
|
+
email: ruby-youtube-library@googlegroups.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files:
|
21
|
+
- History.txt
|
22
|
+
- README.txt
|
23
|
+
files:
|
24
|
+
- History.txt
|
25
|
+
- Manifest.txt
|
26
|
+
- README.txt
|
27
|
+
- TODO.txt
|
28
|
+
- lib/youtube_g.rb
|
29
|
+
- lib/youtube_g/client.rb
|
30
|
+
- lib/youtube_g/logger.rb
|
31
|
+
- lib/youtube_g/model/author.rb
|
32
|
+
- lib/youtube_g/model/category.rb
|
33
|
+
- lib/youtube_g/model/contact.rb
|
34
|
+
- lib/youtube_g/model/content.rb
|
35
|
+
- lib/youtube_g/model/playlist.rb
|
36
|
+
- lib/youtube_g/model/rating.rb
|
37
|
+
- lib/youtube_g/model/thumbnail.rb
|
38
|
+
- lib/youtube_g/model/user.rb
|
39
|
+
- lib/youtube_g/model/video.rb
|
40
|
+
- lib/youtube_g/parser.rb
|
41
|
+
- lib/youtube_g/record.rb
|
42
|
+
- lib/youtube_g/request/base_search.rb
|
43
|
+
- lib/youtube_g/request/standard_search.rb
|
44
|
+
- lib/youtube_g/request/user_search.rb
|
45
|
+
- lib/youtube_g/request/video_search.rb
|
46
|
+
- lib/youtube_g/request/video_upload.rb
|
47
|
+
- lib/youtube_g/response/video_search.rb
|
48
|
+
- test/test_client.rb
|
49
|
+
- test/test_video.rb
|
50
|
+
- test/test_video_search.rb
|
51
|
+
- youtube-g-es.gemspec
|
52
|
+
homepage: http://youtube-g.rubyforge.org/
|
53
|
+
licenses: []
|
54
|
+
metadata: {}
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options:
|
57
|
+
- --main
|
58
|
+
- README.txt
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.4.3
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: An object-oriented Ruby wrapper for the YouTube GData API
|
77
|
+
test_files:
|
78
|
+
- test/test_client.rb
|
79
|
+
- test/test_video.rb
|
80
|
+
- test/test_video_search.rb
|