Merge lp:~luismmontielg/do-plugins/YouTube into lp:do-plugins
- YouTube
- Merge into trunk
Proposed by
Luis Montiel
Status: | Merged |
---|---|
Merged at revision: | 717 |
Proposed branch: | lp:~luismmontielg/do-plugins/YouTube |
Merge into: | lp:do-plugins |
Diff against target: |
699 lines (+335/-121) 13 files modified
.bzrignore (+2/-0) YouTube/Makefile.am (+2/-1) YouTube/Resources/Youtube.addin.xml.in (+5/-5) YouTube/src/CertHandler.cs (+37/-0) YouTube/src/Preferences.cs (+21/-1) YouTube/src/YouTubeFavoriteItemSource.cs (+21/-1) YouTube/src/YouTubeOwnVideosItemSource.cs (+20/-6) YouTube/src/YouTubeSearchAction.cs (+22/-15) YouTube/src/YouTubeSubscriptionItem.cs (+22/-1) YouTube/src/YouTubeSubscriptionItemSource.cs (+22/-1) YouTube/src/Youtube.cs (+119/-87) YouTube/src/YoutubeConfig.cs (+21/-1) YouTube/src/YoutubeVideoItem.cs (+21/-2) |
To merge this branch: | bzr merge lp:~luismmontielg/do-plugins/YouTube |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Do Plugins Team | Pending | ||
Review via email: mp+24958@code.launchpad.net |
Commit message
Description of the change
Fixed plugin, is working now, also changed namespace
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2010-05-08 01:02:38 +0000 | |||
3 | +++ .bzrignore 2010-05-09 17:35:41 +0000 | |||
4 | @@ -1,1 +1,3 @@ | |||
5 | 1 | Emesene.addin.xml | 1 | Emesene.addin.xml |
6 | 2 | .bzrignore | ||
7 | 3 | ../Resources/Youtube.addin.xml | ||
8 | 2 | 4 | ||
9 | === modified file 'YouTube/Makefile.am' | |||
10 | --- YouTube/Makefile.am 2009-06-22 04:05:16 +0000 | |||
11 | +++ YouTube/Makefile.am 2010-05-09 17:35:41 +0000 | |||
12 | @@ -13,7 +13,8 @@ | |||
13 | 13 | src/YouTubeSearchAction.cs \ | 13 | src/YouTubeSearchAction.cs \ |
14 | 14 | src/YouTubeSubscriptionItem.cs \ | 14 | src/YouTubeSubscriptionItem.cs \ |
15 | 15 | src/YouTubeSubscriptionItemSource.cs \ | 15 | src/YouTubeSubscriptionItemSource.cs \ |
17 | 16 | src/YoutubeVideoItem.cs | 16 | src/YoutubeVideoItem.cs \ |
18 | 17 | src/CertHandler.cs | ||
19 | 17 | 18 | ||
20 | 18 | RESOURCES = \ | 19 | RESOURCES = \ |
21 | 19 | Resources/Youtube.addin.xml \ | 20 | Resources/Youtube.addin.xml \ |
22 | 20 | 21 | ||
23 | === modified file 'YouTube/Resources/Youtube.addin.xml.in' | |||
24 | --- YouTube/Resources/Youtube.addin.xml.in 2009-06-22 21:50:13 +0000 | |||
25 | +++ YouTube/Resources/Youtube.addin.xml.in 2010-05-09 17:35:41 +0000 | |||
26 | @@ -1,7 +1,7 @@ | |||
27 | 1 | <Addin | 1 | <Addin |
28 | 2 | id="YouTube" | 2 | id="YouTube" |
29 | 3 | namespace= "Do" | 3 | namespace= "Do" |
31 | 4 | version="1.0" | 4 | version="1.1" |
32 | 5 | name="YouTube" | 5 | name="YouTube" |
33 | 6 | description="Search your favorites, subscriptions, uploaded videos, and more." | 6 | description="Search your favorites, subscriptions, uploaded videos, and more." |
34 | 7 | author="Luis Miguel Montiel G" | 7 | author="Luis Miguel Montiel G" |
35 | @@ -22,11 +22,11 @@ | |||
36 | 22 | <!-- Extensions included in this assembly --> | 22 | <!-- Extensions included in this assembly --> |
37 | 23 | <!-- Sources --> | 23 | <!-- Sources --> |
38 | 24 | <Extension path = "/Do/ItemSource"> | 24 | <Extension path = "/Do/ItemSource"> |
42 | 25 | <ItemSource type="Do.Universe.YouTubeFavoriteItemSource" /> | 25 | <ItemSource type="Youtube.YouTubeFavoriteItemSource" /> |
43 | 26 | <ItemSource type="Do.Universe.YouTubeSubscriptionItemSource" /> | 26 | <ItemSource type="Youtube.YouTubeSubscriptionItemSource" /> |
44 | 27 | <ItemSource type="Do.Universe.YouTubeOwnVideosItemSource" /> | 27 | <ItemSource type="Youtube.YouTubeOwnVideosItemSource" /> |
45 | 28 | </Extension> | 28 | </Extension> |
46 | 29 | <Extension path = "/Do/Action"> | 29 | <Extension path = "/Do/Action"> |
48 | 30 | <Action type="Do.Universe.YouTubeSearchAction" /> | 30 | <Action type="Youtube.YouTubeSearchAction" /> |
49 | 31 | </Extension> | 31 | </Extension> |
50 | 32 | </Addin> | 32 | </Addin> |
51 | 33 | 33 | ||
52 | === added file 'YouTube/src/CertHandler.cs' | |||
53 | --- YouTube/src/CertHandler.cs 1970-01-01 00:00:00 +0000 | |||
54 | +++ YouTube/src/CertHandler.cs 2010-05-09 17:35:41 +0000 | |||
55 | @@ -0,0 +1,37 @@ | |||
56 | 1 | /* CertHandler.cs | ||
57 | 2 | * | ||
58 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
59 | 4 | * COPYRIGHT file distributed with this | ||
60 | 5 | * source distribution. | ||
61 | 6 | * | ||
62 | 7 | * This program is free software: you can redistribute it and/or modify | ||
63 | 8 | * it under the terms of the GNU General Public License as published by | ||
64 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
65 | 10 | * (at your option) any later version. | ||
66 | 11 | * | ||
67 | 12 | * This program is distributed in the hope that it will be useful, | ||
68 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
69 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
70 | 15 | * GNU General Public License for more details. | ||
71 | 16 | * | ||
72 | 17 | * You should have received a copy of the GNU General Public License | ||
73 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
74 | 19 | */ | ||
75 | 20 | |||
76 | 21 | using System; | ||
77 | 22 | using System.Net; | ||
78 | 23 | using System.Collections; | ||
79 | 24 | using System.Security.Cryptography.X509Certificates; | ||
80 | 25 | |||
81 | 26 | namespace Youtube | ||
82 | 27 | { | ||
83 | 28 | |||
84 | 29 | public class CertHandler : ICertificatePolicy | ||
85 | 30 | { | ||
86 | 31 | public bool CheckValidationResult (ServicePoint sp, X509Certificate cert, | ||
87 | 32 | WebRequest request, int error) | ||
88 | 33 | { | ||
89 | 34 | return true; | ||
90 | 35 | } | ||
91 | 36 | } | ||
92 | 37 | } | ||
93 | 0 | 38 | ||
94 | === modified file 'YouTube/src/Preferences.cs' | |||
95 | --- YouTube/src/Preferences.cs 2009-06-22 04:05:16 +0000 | |||
96 | +++ YouTube/src/Preferences.cs 2010-05-09 17:35:41 +0000 | |||
97 | @@ -1,8 +1,28 @@ | |||
98 | 1 | /* Preferences.cs | ||
99 | 2 | * | ||
100 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
101 | 4 | * COPYRIGHT file distributed with this | ||
102 | 5 | * source distribution. | ||
103 | 6 | * | ||
104 | 7 | * This program is free software: you can redistribute it and/or modify | ||
105 | 8 | * it under the terms of the GNU General Public License as published by | ||
106 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
107 | 10 | * (at your option) any later version. | ||
108 | 11 | * | ||
109 | 12 | * This program is distributed in the hope that it will be useful, | ||
110 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
111 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
112 | 15 | * GNU General Public License for more details. | ||
113 | 16 | * | ||
114 | 17 | * You should have received a copy of the GNU General Public License | ||
115 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
116 | 19 | */ | ||
117 | 20 | |||
118 | 1 | using System; | 21 | using System; |
119 | 2 | using Mono.Addins; | 22 | using Mono.Addins; |
120 | 3 | using Do.Platform; | 23 | using Do.Platform; |
121 | 4 | 24 | ||
123 | 5 | namespace Do.Universe | 25 | namespace Youtube |
124 | 6 | { | 26 | { |
125 | 7 | public class YouTubePreferences | 27 | public class YouTubePreferences |
126 | 8 | { | 28 | { |
127 | 9 | 29 | ||
128 | === modified file 'YouTube/src/YouTubeFavoriteItemSource.cs' | |||
129 | --- YouTube/src/YouTubeFavoriteItemSource.cs 2009-06-22 04:05:16 +0000 | |||
130 | +++ YouTube/src/YouTubeFavoriteItemSource.cs 2010-05-09 17:35:41 +0000 | |||
131 | @@ -1,3 +1,23 @@ | |||
132 | 1 | /* YouTubeFavoriteItemSource.cs | ||
133 | 2 | * | ||
134 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
135 | 4 | * COPYRIGHT file distributed with this | ||
136 | 5 | * source distribution. | ||
137 | 6 | * | ||
138 | 7 | * This program is free software: you can redistribute it and/or modify | ||
139 | 8 | * it under the terms of the GNU General Public License as published by | ||
140 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
141 | 10 | * (at your option) any later version. | ||
142 | 11 | * | ||
143 | 12 | * This program is distributed in the hope that it will be useful, | ||
144 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
145 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
146 | 15 | * GNU General Public License for more details. | ||
147 | 16 | * | ||
148 | 17 | * You should have received a copy of the GNU General Public License | ||
149 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
150 | 19 | */ | ||
151 | 20 | |||
152 | 1 | using System; | 21 | using System; |
153 | 2 | using System.Collections.Generic; | 22 | using System.Collections.Generic; |
154 | 3 | using Mono.Addins; | 23 | using Mono.Addins; |
155 | @@ -6,7 +26,7 @@ | |||
156 | 6 | using Do.Platform.Linux; | 26 | using Do.Platform.Linux; |
157 | 7 | using System.Threading; | 27 | using System.Threading; |
158 | 8 | 28 | ||
160 | 9 | namespace Do.Universe | 29 | namespace Youtube |
161 | 10 | { | 30 | { |
162 | 11 | public class YouTubeFavoriteItemSource : ItemSource, IConfigurable | 31 | public class YouTubeFavoriteItemSource : ItemSource, IConfigurable |
163 | 12 | { | 32 | { |
164 | 13 | 33 | ||
165 | === modified file 'YouTube/src/YouTubeOwnVideosItemSource.cs' | |||
166 | --- YouTube/src/YouTubeOwnVideosItemSource.cs 2009-06-22 04:05:16 +0000 | |||
167 | +++ YouTube/src/YouTubeOwnVideosItemSource.cs 2010-05-09 17:35:41 +0000 | |||
168 | @@ -1,8 +1,22 @@ | |||
174 | 1 | // YouTubeOwnVideosSource.cs created with MonoDevelop | 1 | /* YouTubeOwnVideosItemSource.cs |
175 | 2 | // User: luis at 08:50 p 10/09/2008 | 2 | * |
176 | 3 | // | 3 | * GNOME Do is the legal property of its developers. Please refer to the |
177 | 4 | // To change standard headers go to Edit->Preferences->Coding->Standard Headers | 4 | * COPYRIGHT file distributed with this |
178 | 5 | // | 5 | * source distribution. |
179 | 6 | * | ||
180 | 7 | * This program is free software: you can redistribute it and/or modify | ||
181 | 8 | * it under the terms of the GNU General Public License as published by | ||
182 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
183 | 10 | * (at your option) any later version. | ||
184 | 11 | * | ||
185 | 12 | * This program is distributed in the hope that it will be useful, | ||
186 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
187 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
188 | 15 | * GNU General Public License for more details. | ||
189 | 16 | * | ||
190 | 17 | * You should have received a copy of the GNU General Public License | ||
191 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
192 | 19 | */ | ||
193 | 6 | 20 | ||
194 | 7 | using System; | 21 | using System; |
195 | 8 | using System.Collections.Generic; | 22 | using System.Collections.Generic; |
196 | @@ -10,7 +24,7 @@ | |||
197 | 10 | using System.Threading; | 24 | using System.Threading; |
198 | 11 | using Do.Universe; | 25 | using Do.Universe; |
199 | 12 | 26 | ||
201 | 13 | namespace Do.Universe | 27 | namespace Youtube |
202 | 14 | { | 28 | { |
203 | 15 | 29 | ||
204 | 16 | 30 | ||
205 | 17 | 31 | ||
206 | === modified file 'YouTube/src/YouTubeSearchAction.cs' | |||
207 | --- YouTube/src/YouTubeSearchAction.cs 2009-02-01 20:19:36 +0000 | |||
208 | +++ YouTube/src/YouTubeSearchAction.cs 2010-05-09 17:35:41 +0000 | |||
209 | @@ -1,10 +1,30 @@ | |||
210 | 1 | /* YouTubeSearchAction.cs | ||
211 | 2 | * | ||
212 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
213 | 4 | * COPYRIGHT file distributed with this | ||
214 | 5 | * source distribution. | ||
215 | 6 | * | ||
216 | 7 | * This program is free software: you can redistribute it and/or modify | ||
217 | 8 | * it under the terms of the GNU General Public License as published by | ||
218 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
219 | 10 | * (at your option) any later version. | ||
220 | 11 | * | ||
221 | 12 | * This program is distributed in the hope that it will be useful, | ||
222 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
223 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
224 | 15 | * GNU General Public License for more details. | ||
225 | 16 | * | ||
226 | 17 | * You should have received a copy of the GNU General Public License | ||
227 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
228 | 19 | */ | ||
229 | 20 | |||
230 | 1 | using System; | 21 | using System; |
231 | 2 | using System.Collections.Generic; | 22 | using System.Collections.Generic; |
232 | 3 | using Do.Universe; | 23 | using Do.Universe; |
233 | 4 | using Do.Platform; | 24 | using Do.Platform; |
234 | 5 | using System.Linq; | 25 | using System.Linq; |
235 | 6 | 26 | ||
237 | 7 | namespace Do.Universe | 27 | namespace Youtube |
238 | 8 | { | 28 | { |
239 | 9 | public class YouTubeSearchAction : Act | 29 | public class YouTubeSearchAction : Act |
240 | 10 | { | 30 | { |
241 | @@ -39,22 +59,9 @@ | |||
242 | 39 | 59 | ||
243 | 40 | public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) | 60 | public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems) |
244 | 41 | { | 61 | { |
245 | 42 | |||
246 | 43 | //string search = ""; | ||
247 | 44 | |||
248 | 45 | // foreach (Item item in items) { | ||
249 | 46 | // if (item is IUrlItem) { | ||
250 | 47 | // search = (item as IUrlItem).Url; | ||
251 | 48 | // } else if (item is ITextItem) { | ||
252 | 49 | // search = (item as ITextItem).Text; | ||
253 | 50 | // } | ||
254 | 51 | // search = search.Replace (" ", "%20"); | ||
255 | 52 | // Services.Environment.OpenUrl(url+search); | ||
256 | 53 | // } | ||
257 | 54 | |||
258 | 55 | string search = (items.First() as ITextItem).Text; | 62 | string search = (items.First() as ITextItem).Text; |
259 | 56 | search = search.Replace (" ", "%20"); | 63 | search = search.Replace (" ", "%20"); |
261 | 57 | Services.Environment.OpenUrl(Youtube.searchUrl+search); | 64 | Services.Environment.OpenUrl(String.Format(Youtube.searchUrl, search)); |
262 | 58 | yield break; | 65 | yield break; |
263 | 59 | } | 66 | } |
264 | 60 | } | 67 | } |
265 | 61 | 68 | ||
266 | === modified file 'YouTube/src/YouTubeSubscriptionItem.cs' | |||
267 | --- YouTube/src/YouTubeSubscriptionItem.cs 2009-02-01 20:19:36 +0000 | |||
268 | +++ YouTube/src/YouTubeSubscriptionItem.cs 2010-05-09 17:35:41 +0000 | |||
269 | @@ -1,7 +1,28 @@ | |||
270 | 1 | /* YouTubeSubscriptionItem.cs | ||
271 | 2 | * | ||
272 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
273 | 4 | * COPYRIGHT file distributed with this | ||
274 | 5 | * source distribution. | ||
275 | 6 | * | ||
276 | 7 | * This program is free software: you can redistribute it and/or modify | ||
277 | 8 | * it under the terms of the GNU General Public License as published by | ||
278 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
279 | 10 | * (at your option) any later version. | ||
280 | 11 | * | ||
281 | 12 | * This program is distributed in the hope that it will be useful, | ||
282 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
283 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
284 | 15 | * GNU General Public License for more details. | ||
285 | 16 | * | ||
286 | 17 | * You should have received a copy of the GNU General Public License | ||
287 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
288 | 19 | */ | ||
289 | 20 | |||
290 | 21 | |||
291 | 1 | using System; | 22 | using System; |
292 | 2 | using Do.Universe; | 23 | using Do.Universe; |
293 | 3 | 24 | ||
295 | 4 | namespace Do.Universe | 25 | namespace Youtube |
296 | 5 | { | 26 | { |
297 | 6 | public class YouTubeSubscriptionItem : Item, IUrlItem | 27 | public class YouTubeSubscriptionItem : Item, IUrlItem |
298 | 7 | { | 28 | { |
299 | 8 | 29 | ||
300 | === modified file 'YouTube/src/YouTubeSubscriptionItemSource.cs' | |||
301 | --- YouTube/src/YouTubeSubscriptionItemSource.cs 2009-06-22 04:05:16 +0000 | |||
302 | +++ YouTube/src/YouTubeSubscriptionItemSource.cs 2010-05-09 17:35:41 +0000 | |||
303 | @@ -1,10 +1,31 @@ | |||
304 | 1 | /* YouTubeSubscriptionItemSource.cs | ||
305 | 2 | * | ||
306 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
307 | 4 | * COPYRIGHT file distributed with this | ||
308 | 5 | * source distribution. | ||
309 | 6 | * | ||
310 | 7 | * This program is free software: you can redistribute it and/or modify | ||
311 | 8 | * it under the terms of the GNU General Public License as published by | ||
312 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
313 | 10 | * (at your option) any later version. | ||
314 | 11 | * | ||
315 | 12 | * This program is distributed in the hope that it will be useful, | ||
316 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
317 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
318 | 15 | * GNU General Public License for more details. | ||
319 | 16 | * | ||
320 | 17 | * You should have received a copy of the GNU General Public License | ||
321 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
322 | 19 | */ | ||
323 | 20 | |||
324 | 21 | |||
325 | 1 | using System; | 22 | using System; |
326 | 2 | using System.Collections.Generic; | 23 | using System.Collections.Generic; |
327 | 3 | using Mono.Addins; | 24 | using Mono.Addins; |
328 | 4 | using System.Threading; | 25 | using System.Threading; |
329 | 5 | using Do.Universe; | 26 | using Do.Universe; |
330 | 6 | 27 | ||
332 | 7 | namespace Do.Universe | 28 | namespace Youtube |
333 | 8 | { | 29 | { |
334 | 9 | public class YouTubeSubscriptionItemSource : ItemSource | 30 | public class YouTubeSubscriptionItemSource : ItemSource |
335 | 10 | { | 31 | { |
336 | 11 | 32 | ||
337 | === modified file 'YouTube/src/Youtube.cs' | |||
338 | --- YouTube/src/Youtube.cs 2009-06-22 04:05:16 +0000 | |||
339 | +++ YouTube/src/Youtube.cs 2010-05-09 17:35:41 +0000 | |||
340 | @@ -1,3 +1,23 @@ | |||
341 | 1 | /* Youtube.cs | ||
342 | 2 | * | ||
343 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
344 | 4 | * COPYRIGHT file distributed with this | ||
345 | 5 | * source distribution. | ||
346 | 6 | * | ||
347 | 7 | * This program is free software: you can redistribute it and/or modify | ||
348 | 8 | * it under the terms of the GNU General Public License as published by | ||
349 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
350 | 10 | * (at your option) any later version. | ||
351 | 11 | * | ||
352 | 12 | * This program is distributed in the hope that it will be useful, | ||
353 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
354 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
355 | 15 | * GNU General Public License for more details. | ||
356 | 16 | * | ||
357 | 17 | * You should have received a copy of the GNU General Public License | ||
358 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
359 | 19 | */ | ||
360 | 20 | |||
361 | 1 | using System; | 21 | using System; |
362 | 2 | using System.IO; | 22 | using System.IO; |
363 | 3 | using System.Net; | 23 | using System.Net; |
364 | @@ -10,119 +30,127 @@ | |||
365 | 10 | using Google.GData.YouTube; | 30 | using Google.GData.YouTube; |
366 | 11 | using Google.GData.Extensions.MediaRss; | 31 | using Google.GData.Extensions.MediaRss; |
367 | 12 | 32 | ||
369 | 13 | namespace Do.Universe | 33 | namespace Youtube |
370 | 14 | { | 34 | { |
371 | 15 | public class Youtube | 35 | public class Youtube |
372 | 16 | { | 36 | { |
373 | 17 | 37 | ||
374 | 18 | static readonly string ConnectionErrorMessage = AddinManager.CurrentLocalizer.GetString ("An error occurred connecting to YouTube, " | 38 | static readonly string ConnectionErrorMessage = AddinManager.CurrentLocalizer.GetString ("An error occurred connecting to YouTube, " |
375 | 19 | + "are your credentials valid?"); | 39 | + "are your credentials valid?"); |
377 | 20 | 40 | ||
378 | 21 | static readonly string MissingCredentialsMessage = AddinManager.CurrentLocalizer.GetString ("Missing login credentials. Please set " | 41 | static readonly string MissingCredentialsMessage = AddinManager.CurrentLocalizer.GetString ("Missing login credentials. Please set " |
379 | 22 | + "login information in YouTube plugin configuration."); | 42 | + "login information in YouTube plugin configuration."); |
385 | 23 | 43 | ||
386 | 24 | public const string appName = "luismmontielg-gnomeDoYoutubePlugin0.1"; | 44 | private const string appName = "gnome-do-plugin"; |
387 | 25 | public const string searchUrl = "http://www.youtube.com/results?search_query="; | 45 | public const string searchUrl = "http://www.youtube.com/results?search_query={0}"; |
388 | 26 | public static string clientID = "ytapi-lmg-test-ojd8d285-0"; | 46 | private const string clientID = "gnome-do-client"; |
389 | 27 | public static string developerKey = "AI39si5c61jYzQLvzEDjAnU1HOQIf-DzyzvIBXAkGJ82NlXoMg10RDW1sRz5Uyodv9_ETPzmJXdfFqVRNt51yGkkNo2YW0BdxQ"; | 47 | private const string developerKey = "AI39si5utjLEVOmAty2JLxz8KlixVQkwbSsEZqUXVUV-hUK1zDctrUbujGL2kWJBs47a7CaO-LOf_FXUiyuvQ9j7pbq8YO9wsA"; |
390 | 48 | |||
391 | 28 | public static List<Item> favorites; | 49 | public static List<Item> favorites; |
392 | 29 | public static List<Item> subscriptions; | 50 | public static List<Item> subscriptions; |
393 | 30 | public static List<Item> own; | 51 | public static List<Item> own; |
394 | 52 | |||
395 | 31 | private static YouTubeService service; | 53 | private static YouTubeService service; |
396 | 32 | private static string username; | 54 | private static string username; |
397 | 33 | private static string password; | 55 | private static string password; |
398 | 56 | |||
399 | 34 | private static int subUpdate; | 57 | private static int subUpdate; |
400 | 35 | private static int favUpdate; | 58 | private static int favUpdate; |
401 | 36 | private static int ownUpdate; | 59 | private static int ownUpdate; |
403 | 37 | 60 | ||
404 | 61 | private const string favoritesQueryTemplate = "http://gdata.youtube.com/feeds/api/users/default/favorites?start-index={0}&max-results={1}"; | ||
405 | 62 | private const string ownQueryTemplate = "http://gdata.youtube.com/feeds/api/users/default/uploads?start-index={0}&max-results={1}"; | ||
406 | 63 | private const string youtubeWatchUrlTemplate = "http://www.youtube.com/watch?v={0}"; | ||
407 | 64 | |||
408 | 38 | public static YouTubePreferences Preferences { get; private set; } | 65 | public static YouTubePreferences Preferences { get; private set; } |
410 | 39 | 66 | ||
411 | 40 | static Youtube() | 67 | static Youtube() |
412 | 41 | { | 68 | { |
413 | 42 | Youtube.favorites = new List<Item>(); | 69 | Youtube.favorites = new List<Item>(); |
414 | 43 | Youtube.own = new List<Item>(); | 70 | Youtube.own = new List<Item>(); |
415 | 44 | Youtube.subscriptions = new List<Item>(); | 71 | Youtube.subscriptions = new List<Item>(); |
416 | 72 | |||
417 | 45 | Preferences = new YouTubePreferences (); | 73 | Preferences = new YouTubePreferences (); |
418 | 74 | |||
419 | 46 | subUpdate = 0; | 75 | subUpdate = 0; |
420 | 47 | favUpdate = 0; | 76 | favUpdate = 0; |
421 | 48 | ownUpdate = 0; | 77 | ownUpdate = 0; |
422 | 78 | |||
423 | 49 | username = Preferences.Username; | 79 | username = Preferences.Username; |
424 | 50 | password = Preferences.Password; | 80 | password = Preferences.Password; |
425 | 81 | |||
426 | 51 | Connect (username, password); | 82 | Connect (username, password); |
427 | 52 | } | 83 | } |
429 | 53 | 84 | ||
430 | 85 | private static void parseFeed(YouTubeFeed feed, List<Item> videos) | ||
431 | 86 | { | ||
432 | 87 | string description = ""; | ||
433 | 88 | string url = null; | ||
434 | 89 | foreach(YouTubeEntry entry in feed.Entries) | ||
435 | 90 | { | ||
436 | 91 | description = ""; | ||
437 | 92 | url = String.Format(youtubeWatchUrlTemplate, entry.VideoId); | ||
438 | 93 | if (entry.Media.Description != null) | ||
439 | 94 | { | ||
440 | 95 | description = entry.Media.Description.Value; | ||
441 | 96 | } | ||
442 | 97 | YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, description); | ||
443 | 98 | videos.Add(video); | ||
444 | 99 | } | ||
445 | 100 | } | ||
446 | 101 | |||
447 | 102 | private static void update(string queryTemplate, List<Item> videos, ref int counter, string category) | ||
448 | 103 | { | ||
449 | 104 | if (videos.Count != 0 || (counter % 20 != 0 && counter != 0)) | ||
450 | 105 | { | ||
451 | 106 | counter = counter + 1; | ||
452 | 107 | return; | ||
453 | 108 | } | ||
454 | 109 | |||
455 | 110 | counter = counter + 1; | ||
456 | 111 | |||
457 | 112 | videos.Clear(); | ||
458 | 113 | int maxResults = 50; | ||
459 | 114 | int startIndex = 1; | ||
460 | 115 | |||
461 | 116 | string feedUrl = String.Format(queryTemplate, startIndex, maxResults); | ||
462 | 117 | |||
463 | 118 | YouTubeQuery query = new YouTubeQuery(feedUrl); | ||
464 | 119 | YouTubeFeed videoFeed = null; | ||
465 | 120 | |||
466 | 121 | try | ||
467 | 122 | { | ||
468 | 123 | videoFeed = service.Query(query); | ||
469 | 124 | while(videoFeed.Entries.Count > 0) | ||
470 | 125 | { | ||
471 | 126 | parseFeed(videoFeed, videos); | ||
472 | 127 | |||
473 | 128 | startIndex += maxResults; | ||
474 | 129 | feedUrl = String.Format(queryTemplate, startIndex, maxResults); | ||
475 | 130 | query = new YouTubeQuery(feedUrl); | ||
476 | 131 | videoFeed = service.Query(query); | ||
477 | 132 | } | ||
478 | 133 | startIndex = 1; | ||
479 | 134 | Log<Youtube>.Debug("Finished updating {0} videos", category); | ||
480 | 135 | } | ||
481 | 136 | catch(Exception e) | ||
482 | 137 | { | ||
483 | 138 | Log<Youtube>.Error ("Error getting {0} videos - {1}", category, e.Message); | ||
484 | 139 | Log<Youtube>.Debug (e.StackTrace); | ||
485 | 140 | } | ||
486 | 141 | |||
487 | 142 | } | ||
488 | 143 | |||
489 | 54 | public static void updateFavorites() | 144 | public static void updateFavorites() |
490 | 55 | { | 145 | { |
524 | 56 | favUpdate++; | 146 | update (favoritesQueryTemplate, Youtube.favorites, ref favUpdate, "favorites"); |
492 | 57 | Log<Youtube>.Debug("Update favorites videos tries = {0} - favorite.Count : {1}", favUpdate, Youtube.favorites.Count); | ||
493 | 58 | if (Youtube.favorites.Count == 0 || favUpdate%20 == 0){ | ||
494 | 59 | Youtube.favorites.Clear(); | ||
495 | 60 | int maxResults = 50; | ||
496 | 61 | int startIndex = 1; | ||
497 | 62 | |||
498 | 63 | string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/favorites?start-index="+ startIndex +"&max-results="+maxResults; | ||
499 | 64 | YouTubeQuery query = new YouTubeQuery(feedUrl); | ||
500 | 65 | Log<Youtube>.Debug("feedUrl for favorites videos: {0}", feedUrl); | ||
501 | 66 | try{ | ||
502 | 67 | YouTubeFeed videoFeed = service.Query(query); | ||
503 | 68 | while(videoFeed.Entries.Count > 0){ | ||
504 | 69 | foreach (YouTubeEntry entry in videoFeed.Entries) | ||
505 | 70 | { | ||
506 | 71 | //Log<Youtube>.Debug("Video #{0}, Title: {1}", ++i, entry.Title.Text); | ||
507 | 72 | string url = ("http://www.youtube.com/watch?v="+entry.VideoId); | ||
508 | 73 | //Log<Youtube>.Debug("Video url: {0}", url); | ||
509 | 74 | YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, entry.Media.Description.Value); | ||
510 | 75 | favorites.Add(video); | ||
511 | 76 | } | ||
512 | 77 | startIndex += maxResults; | ||
513 | 78 | feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/favorites?start-index="+ startIndex +"&max-results="+maxResults; | ||
514 | 79 | query = new YouTubeQuery(feedUrl); | ||
515 | 80 | videoFeed = service.Query(query); | ||
516 | 81 | } | ||
517 | 82 | startIndex = 1; | ||
518 | 83 | Log<Youtube>.Debug("Finished updating favorite videos"); | ||
519 | 84 | }catch(Exception e) { | ||
520 | 85 | Log<Youtube>.Error ("Error getting favorites videos - {0}", e.Message); | ||
521 | 86 | Log<Youtube>.Debug (e.StackTrace); | ||
522 | 87 | } | ||
523 | 88 | } | ||
525 | 89 | } | 147 | } |
527 | 90 | 148 | ||
528 | 91 | public static void updateOwn() | 149 | public static void updateOwn() |
529 | 92 | { | 150 | { |
563 | 93 | ownUpdate++; | 151 | update (ownQueryTemplate, Youtube.own, ref ownUpdate, "own youtube"); |
564 | 94 | Log<Youtube>.Debug("Update own videos tries = {0} - own.Count : {1}", ownUpdate, Youtube.own.Count); | 152 | } |
565 | 95 | if (Youtube.own.Count == 0 || ownUpdate%20 == 0){ | 153 | |
533 | 96 | Youtube.own.Clear(); | ||
534 | 97 | int maxResults = 50; | ||
535 | 98 | int startIndex = 1; | ||
536 | 99 | |||
537 | 100 | string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/uploads?start-index="+ startIndex +"&max-results="+maxResults; | ||
538 | 101 | YouTubeQuery query = new YouTubeQuery(feedUrl); | ||
539 | 102 | Log<Youtube>.Debug("feedUrl for own videos: {0}", feedUrl); | ||
540 | 103 | try{ | ||
541 | 104 | YouTubeFeed videoFeed = service.Query(query); | ||
542 | 105 | while(videoFeed.Entries.Count > 0){ | ||
543 | 106 | foreach (YouTubeEntry entry in videoFeed.Entries) | ||
544 | 107 | { | ||
545 | 108 | //Log<Youtube>.Debug("Video #{0}, Title(own video): {1}", ++i, entry.Title.Text); | ||
546 | 109 | string url = "http://www.youtube.com/watch?v="+entry.VideoId; | ||
547 | 110 | YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, entry.Media.Description.Value); | ||
548 | 111 | own.Add(video); | ||
549 | 112 | } | ||
550 | 113 | startIndex += maxResults; | ||
551 | 114 | feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/uploads?start-index="+ startIndex +"&max-results="+maxResults; | ||
552 | 115 | query = new YouTubeQuery(feedUrl); | ||
553 | 116 | videoFeed = service.Query(query); | ||
554 | 117 | } | ||
555 | 118 | Log<Youtube>.Debug("Finished updating own videos"); | ||
556 | 119 | }catch(Exception e) { | ||
557 | 120 | Log<Youtube>.Error ("Error getting own videos - {0}", e.Message); | ||
558 | 121 | Log<Youtube>.Debug (e.StackTrace); | ||
559 | 122 | } | ||
560 | 123 | } | ||
561 | 124 | } | ||
562 | 125 | |||
566 | 126 | public static void updateSubscriptions() | 154 | public static void updateSubscriptions() |
567 | 127 | { | 155 | { |
568 | 128 | subUpdate++; | 156 | subUpdate++; |
569 | @@ -130,19 +158,19 @@ | |||
570 | 130 | if (Youtube.subscriptions.Count == 0 || subUpdate%20==0){ | 158 | if (Youtube.subscriptions.Count == 0 || subUpdate%20==0){ |
571 | 131 | Youtube.subscriptions.Clear(); | 159 | Youtube.subscriptions.Clear(); |
572 | 132 | 160 | ||
574 | 133 | string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/subscriptions"; | 161 | string feedUrl = "http://gdata.youtube.com/feeds/api/users/default/subscriptions"; |
575 | 134 | YouTubeQuery query = new YouTubeQuery(feedUrl); | 162 | YouTubeQuery query = new YouTubeQuery(feedUrl); |
576 | 135 | Log<Youtube>.Debug("feedUrl for subscriptions: {0}", feedUrl); | 163 | Log<Youtube>.Debug("feedUrl for subscriptions: {0}", feedUrl); |
577 | 164 | SubscriptionFeed subFeed = null; | ||
578 | 165 | string url = "http://www.youtube.com/user/{0}"; | ||
579 | 136 | try | 166 | try |
580 | 137 | { | 167 | { |
582 | 138 | SubscriptionFeed subFeed = service.GetSubscriptions(query); | 168 | subFeed = service.GetSubscriptions(query); |
583 | 139 | if(subFeed.Entries.Count > 0){ | 169 | if(subFeed.Entries.Count > 0){ |
584 | 140 | foreach (SubscriptionEntry entry in subFeed.Entries) | 170 | foreach (SubscriptionEntry entry in subFeed.Entries) |
585 | 141 | { | 171 | { |
590 | 142 | //Log<Youtube>.Debug("Subscriptions - {0}", ++i); | 172 | YouTubeSubscriptionItem subscription = |
591 | 143 | //Log<Youtube>.Debug("{0}", entry.Title.Text); | 173 | new YouTubeSubscriptionItem(entry.UserName, String.Format(url, entry.UserName), entry.Title.Text); |
588 | 144 | string url = "http://www.youtube.com/user/" + entry.UserName; | ||
589 | 145 | YouTubeSubscriptionItem subscription = new YouTubeSubscriptionItem(entry.UserName, url, entry.Title.Text); | ||
592 | 146 | Youtube.subscriptions.Add(subscription); | 174 | Youtube.subscriptions.Add(subscription); |
593 | 147 | } | 175 | } |
594 | 148 | } | 176 | } |
595 | @@ -150,12 +178,14 @@ | |||
596 | 150 | } | 178 | } |
597 | 151 | catch(Exception e) | 179 | catch(Exception e) |
598 | 152 | { | 180 | { |
601 | 153 | Log<Youtube>.Error ("Error getting subscriptions - {0}", e.Message); | 181 | Log<Youtube>.Error ("Error getting subscriptions - {0}", e.Message); |
602 | 154 | Log<Youtube>.Debug (e.StackTrace); | 182 | Log<Youtube>.Debug (e.StackTrace); |
603 | 155 | } | 183 | } |
604 | 156 | } | 184 | } |
607 | 157 | } | 185 | } |
608 | 158 | 186 | ||
609 | 187 | |||
610 | 188 | |||
611 | 159 | public static bool TryConnect (string username, string password) | 189 | public static bool TryConnect (string username, string password) |
612 | 160 | { | 190 | { |
613 | 161 | try { | 191 | try { |
614 | @@ -180,8 +210,10 @@ | |||
615 | 180 | try { | 210 | try { |
616 | 181 | service = new YouTubeService (appName, clientID, developerKey); | 211 | service = new YouTubeService (appName, clientID, developerKey); |
617 | 182 | service.setUserCredentials (username, password); | 212 | service.setUserCredentials (username, password); |
618 | 213 | ServicePointManager.CertificatePolicy = new CertHandler (); | ||
619 | 183 | } catch (Exception e) { | 214 | } catch (Exception e) { |
620 | 184 | Log<Youtube>.Error (ConnectionErrorMessage); | 215 | Log<Youtube>.Error (ConnectionErrorMessage); |
621 | 216 | Log<Youtube>.Error (e.Message); | ||
622 | 185 | } | 217 | } |
623 | 186 | } | 218 | } |
624 | 187 | } | 219 | } |
625 | 188 | 220 | ||
626 | === modified file 'YouTube/src/YoutubeConfig.cs' | |||
627 | --- YouTube/src/YoutubeConfig.cs 2009-02-01 20:19:36 +0000 | |||
628 | +++ YouTube/src/YoutubeConfig.cs 2010-05-09 17:35:41 +0000 | |||
629 | @@ -1,9 +1,29 @@ | |||
630 | 1 | /* YoutubeConfig.cs | ||
631 | 2 | * | ||
632 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
633 | 4 | * COPYRIGHT file distributed with this | ||
634 | 5 | * source distribution. | ||
635 | 6 | * | ||
636 | 7 | * This program is free software: you can redistribute it and/or modify | ||
637 | 8 | * it under the terms of the GNU General Public License as published by | ||
638 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
639 | 10 | * (at your option) any later version. | ||
640 | 11 | * | ||
641 | 12 | * This program is distributed in the hope that it will be useful, | ||
642 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
643 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
644 | 15 | * GNU General Public License for more details. | ||
645 | 16 | * | ||
646 | 17 | * You should have received a copy of the GNU General Public License | ||
647 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
648 | 19 | */ | ||
649 | 20 | |||
650 | 1 | using System; | 21 | using System; |
651 | 2 | using Gtk; | 22 | using Gtk; |
652 | 3 | using Do.Platform; | 23 | using Do.Platform; |
653 | 4 | using Do.Platform.Linux; | 24 | using Do.Platform.Linux; |
654 | 5 | 25 | ||
656 | 6 | namespace Do.Universe | 26 | namespace Youtube |
657 | 7 | { | 27 | { |
658 | 8 | 28 | ||
659 | 9 | public class YouTubeConfig : AbstractLoginWidget | 29 | public class YouTubeConfig : AbstractLoginWidget |
660 | 10 | 30 | ||
661 | === modified file 'YouTube/src/YoutubeVideoItem.cs' | |||
662 | --- YouTube/src/YoutubeVideoItem.cs 2009-02-01 20:19:36 +0000 | |||
663 | +++ YouTube/src/YoutubeVideoItem.cs 2010-05-09 17:35:41 +0000 | |||
664 | @@ -1,7 +1,27 @@ | |||
665 | 1 | /* YouTubeVideoItem.cs | ||
666 | 2 | * | ||
667 | 3 | * GNOME Do is the legal property of its developers. Please refer to the | ||
668 | 4 | * COPYRIGHT file distributed with this | ||
669 | 5 | * source distribution. | ||
670 | 6 | * | ||
671 | 7 | * This program is free software: you can redistribute it and/or modify | ||
672 | 8 | * it under the terms of the GNU General Public License as published by | ||
673 | 9 | * the Free Software Foundation, either version 3 of the License, or | ||
674 | 10 | * (at your option) any later version. | ||
675 | 11 | * | ||
676 | 12 | * This program is distributed in the hope that it will be useful, | ||
677 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
678 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
679 | 15 | * GNU General Public License for more details. | ||
680 | 16 | * | ||
681 | 17 | * You should have received a copy of the GNU General Public License | ||
682 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
683 | 19 | */ | ||
684 | 20 | |||
685 | 1 | using System; | 21 | using System; |
686 | 2 | using Do.Universe; | 22 | using Do.Universe; |
687 | 3 | 23 | ||
689 | 4 | namespace Do.Universe | 24 | namespace Youtube |
690 | 5 | { | 25 | { |
691 | 6 | public class YoutubeVideoItem : Item, IUrlItem | 26 | public class YoutubeVideoItem : Item, IUrlItem |
692 | 7 | { | 27 | { |
693 | @@ -35,6 +55,5 @@ | |||
694 | 35 | { | 55 | { |
695 | 36 | get { return url; } | 56 | get { return url; } |
696 | 37 | } | 57 | } |
697 | 38 | |||
698 | 39 | } | 58 | } |
699 | 40 | } | 59 | } |