youtube_pop 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # YouTubePop
2
2
 
3
- A simple YouTube wrapper around Standard Video Feeds. Gets Top rated, Most viewed, Most shared, Most popular, Most recent, Most discussed, Most
3
+ A very simple YouTube wrapper around Standard Video Feeds. Gets Top rated, Most viewed, Top Favorites, Most shared, Most viewed Most popular, Most recent, Most discussed, Most responded, Recently featured and Trending videos
4
+
4
5
  ## Installation
5
6
 
6
7
  Add this line to your application's Gemfile:
@@ -16,10 +16,13 @@ module YoutubePop
16
16
  attr_accessor :published, :updated, :content, :link, :author_name
17
17
  end
18
18
 
19
+ # Searches for the following from the response:
20
+ #
21
+ # feed/entry/published, feed/entry/updated
22
+ # feed/entry/content, feed/entry/link rel="alternate" href=
23
+ # feed/entry/author/name
19
24
  class StandardApi
20
25
  def initialize
21
- @entries = []
22
-
23
26
  options = {
24
27
  :timeout => 2,
25
28
  :open_timeout => 2
@@ -31,204 +34,60 @@ module YoutubePop
31
34
  end
32
35
  end
33
36
 
34
- #feed/entry/published
35
- #feed/entry/updated
36
- #feed/entry/content
37
- #feed/entry/link rel="alternate" href=
38
- #
39
- #feed/entry/author/name
40
- #feed/entry/author/uri
41
37
  def top_rated
42
38
  response = @conn.get '/feeds/api/standardfeeds/top_rated/'
43
- doc = Nokogiri::XML(response.body)
44
- doc.css('entry').map do |entry|
45
- published = entry.css('published').text
46
- updated = entry.css('updated').text
47
- content = entry.css('content').text
48
- link = entry.at_css("link")['href']
49
- author_name = entry.at_css("author uri").text
50
-
51
- entry = Entry.new
52
- entry.published = published
53
- entry.updated = updated
54
- entry.content = content
55
- entry.link = link
56
- entry.author_name = author_name
57
- @entries << entry
58
- end
59
- @entries
39
+ entries = get_entries(response)
60
40
  end
61
41
 
62
42
  def top_favorites
63
43
  response = @conn.get '/feeds/api/standardfeeds/top_favorites'
64
- doc = Nokogiri::XML(response.body)
65
- doc.css('entry').map do |entry|
66
- published = entry.css('published').text
67
- updated = entry.css('updated').text
68
- content = entry.css('content').text
69
- link = entry.at_css("link")['href']
70
- author_name = entry.at_css("author uri").text
71
-
72
- entry = Entry.new
73
- entry.published = published
74
- entry.updated = updated
75
- entry.content = content
76
- entry.link = link
77
- entry.author_name = author_name
78
- @entries << entry
79
- end
80
- @entries
44
+ entries = get_entries(response)
81
45
  end
82
46
 
83
47
  def most_shared
84
48
  response = @conn.get '/feeds/api/standardfeeds/most_shared'
85
- doc = Nokogiri::XML(response.body)
86
- doc.css('entry').map do |entry|
87
- published = entry.css('published').text
88
- updated = entry.css('updated').text
89
- content = entry.css('content').text
90
- link = entry.at_css("link")['href']
91
- author_name = entry.at_css("author uri").text
92
-
93
- entry = Entry.new
94
- entry.published = published
95
- entry.updated = updated
96
- entry.content = content
97
- entry.link = link
98
- entry.author_name = author_name
99
- @entries << entry
100
- end
101
- @entries
49
+ entries = get_entries(response)
102
50
  end
103
51
 
104
52
  def most_viewed
105
53
  response = @conn.get '/feeds/api/standardfeeds/most_viewed'
106
- doc = Nokogiri::XML(response.body)
107
- doc.css('entry').map do |entry|
108
- published = entry.css('published').text
109
- updated = entry.css('updated').text
110
- content = entry.css('content').text
111
- link = entry.at_css("link")['href']
112
- author_name = entry.at_css("author uri").text
113
-
114
- entry = Entry.new
115
- entry.published = published
116
- entry.updated = updated
117
- entry.content = content
118
- entry.link = link
119
- entry.author_name = author_name
120
- @entries << entry
121
- end
122
- @entries
54
+ entries = get_entries(response)
123
55
  end
124
56
 
125
57
  def most_popular
126
58
  response = @conn.get '/feeds/api/standardfeeds/most_popular'
127
- doc = Nokogiri::XML(response.body)
128
- doc.css('entry').map do |entry|
129
- published = entry.css('published').text
130
- updated = entry.css('updated').text
131
- content = entry.css('content').text
132
- link = entry.at_css("link")['href']
133
- author_name = entry.at_css("author uri").text
134
-
135
- entry = Entry.new
136
- entry.published = published
137
- entry.updated = updated
138
- entry.content = content
139
- entry.link = link
140
- entry.author_name = author_name
141
- @entries << entry
142
- end
143
- @entries
59
+ entries = get_entries(response)
144
60
  end
145
61
 
146
62
  def most_recent
147
63
  response = @conn.get '/feeds/api/standardfeeds/most_recent'
148
- doc = Nokogiri::XML(response.body)
149
- doc.css('entry').map do |entry|
150
- published = entry.css('published').text
151
- updated = entry.css('updated').text
152
- content = entry.css('content').text
153
- link = entry.at_css("link")['href']
154
- author_name = entry.at_css("author uri").text
155
-
156
- entry = Entry.new
157
- entry.published = published
158
- entry.updated = updated
159
- entry.content = content
160
- entry.link = link
161
- entry.author_name = author_name
162
- @entries << entry
163
- end
164
- @entries
64
+ entries = get_entries(response)
165
65
  end
166
66
 
167
67
  def most_discussed
168
68
  response = @conn.get '/feeds/api/standardfeeds/most_discussed'
169
- doc = Nokogiri::XML(response.body)
170
- doc.css('entry').map do |entry|
171
- published = entry.css('published').text
172
- updated = entry.css('updated').text
173
- content = entry.css('content').text
174
- link = entry.at_css("link")['href']
175
- author_name = entry.at_css("author uri").text
176
-
177
- entry = Entry.new
178
- entry.published = published
179
- entry.updated = updated
180
- entry.content = content
181
- entry.link = link
182
- entry.author_name = author_name
183
- @entries << entry
184
- end
185
- @entries
69
+ entries = get_entries(response)
186
70
  end
187
71
 
188
72
  def most_responded
189
73
  response = @conn.get '/feeds/api/standardfeeds/most_responded'
190
- doc = Nokogiri::XML(response.body)
191
- doc.css('entry').map do |entry|
192
- published = entry.css('published').text
193
- updated = entry.css('updated').text
194
- content = entry.css('content').text
195
- link = entry.at_css("link")['href']
196
- author_name = entry.at_css("author uri").text
197
-
198
- entry = Entry.new
199
- entry.published = published
200
- entry.updated = updated
201
- entry.content = content
202
- entry.link = link
203
- entry.author_name = author_name
204
- @entries << entry
205
- end
206
- @entries
74
+ entries = get_entries(response)
207
75
  end
208
76
 
209
77
  def recently_featured
210
78
  response = @conn.get '/feeds/api/standardfeeds/recently_featured'
211
- doc = Nokogiri::XML(response.body)
212
- doc.css('entry').map do |entry|
213
- published = entry.css('published').text
214
- updated = entry.css('updated').text
215
- content = entry.css('content').text
216
- link = entry.at_css("link")['href']
217
- author_name = entry.at_css("author uri").text
218
-
219
- entry = Entry.new
220
- entry.published = published
221
- entry.updated = updated
222
- entry.content = content
223
- entry.link = link
224
- entry.author_name = author_name
225
- @entries << entry
226
- end
227
- @entries
79
+ entries = get_entries(response)
228
80
  end
229
81
 
230
82
  def trending_videos
231
83
  response = @conn.get '/feeds/api/standardfeeds/on_the_web'
84
+ entries = get_entries(response)
85
+ end
86
+
87
+ private
88
+
89
+ def get_entries(response)
90
+ entries = []
232
91
  doc = Nokogiri::XML(response.body)
233
92
  doc.css('entry').map do |entry|
234
93
  published = entry.css('published').text
@@ -243,9 +102,9 @@ module YoutubePop
243
102
  entry.content = content
244
103
  entry.link = link
245
104
  entry.author_name = author_name
246
- @entries << entry
105
+ entries << entry
247
106
  end
248
- @entries
107
+ entries
249
108
  end
250
109
  end
251
110
  end
@@ -1,3 +1,3 @@
1
1
  module YoutubePop
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: youtube_pop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-15 00:00:00.000000000 Z
12
+ date: 2012-06-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday