Merge lp:~luismmontielg/do-plugins/YouTube into lp:do-plugins

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
Reviewer Review Type Date Requested Status
Do Plugins Team Pending
Review via email: mp+24958@code.launchpad.net

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
=== modified file '.bzrignore'
--- .bzrignore 2010-05-08 01:02:38 +0000
+++ .bzrignore 2010-05-09 17:35:41 +0000
@@ -1,1 +1,3 @@
1Emesene.addin.xml1Emesene.addin.xml
2.bzrignore
3../Resources/Youtube.addin.xml
24
=== modified file 'YouTube/Makefile.am'
--- YouTube/Makefile.am 2009-06-22 04:05:16 +0000
+++ YouTube/Makefile.am 2010-05-09 17:35:41 +0000
@@ -13,7 +13,8 @@
13 src/YouTubeSearchAction.cs \13 src/YouTubeSearchAction.cs \
14 src/YouTubeSubscriptionItem.cs \14 src/YouTubeSubscriptionItem.cs \
15 src/YouTubeSubscriptionItemSource.cs \15 src/YouTubeSubscriptionItemSource.cs \
16 src/YoutubeVideoItem.cs16 src/YoutubeVideoItem.cs \
17 src/CertHandler.cs
1718
18RESOURCES = \19RESOURCES = \
19 Resources/Youtube.addin.xml \20 Resources/Youtube.addin.xml \
2021
=== modified file 'YouTube/Resources/Youtube.addin.xml.in'
--- YouTube/Resources/Youtube.addin.xml.in 2009-06-22 21:50:13 +0000
+++ YouTube/Resources/Youtube.addin.xml.in 2010-05-09 17:35:41 +0000
@@ -1,7 +1,7 @@
1<Addin 1<Addin
2 id="YouTube"2 id="YouTube"
3 namespace= "Do"3 namespace= "Do"
4 version="1.0"4 version="1.1"
5 name="YouTube"5 name="YouTube"
6 description="Search your favorites, subscriptions, uploaded videos, and more."6 description="Search your favorites, subscriptions, uploaded videos, and more."
7 author="Luis Miguel Montiel G"7 author="Luis Miguel Montiel G"
@@ -22,11 +22,11 @@
22 <!-- Extensions included in this assembly -->22 <!-- Extensions included in this assembly -->
23 <!-- Sources -->23 <!-- Sources -->
24 <Extension path = "/Do/ItemSource">24 <Extension path = "/Do/ItemSource">
25 <ItemSource type="Do.Universe.YouTubeFavoriteItemSource" />25 <ItemSource type="Youtube.YouTubeFavoriteItemSource" />
26 <ItemSource type="Do.Universe.YouTubeSubscriptionItemSource" />26 <ItemSource type="Youtube.YouTubeSubscriptionItemSource" />
27 <ItemSource type="Do.Universe.YouTubeOwnVideosItemSource" />27 <ItemSource type="Youtube.YouTubeOwnVideosItemSource" />
28 </Extension>28 </Extension>
29 <Extension path = "/Do/Action">29 <Extension path = "/Do/Action">
30 <Action type="Do.Universe.YouTubeSearchAction" />30 <Action type="Youtube.YouTubeSearchAction" />
31 </Extension>31 </Extension>
32</Addin>32</Addin>
3333
=== added file 'YouTube/src/CertHandler.cs'
--- YouTube/src/CertHandler.cs 1970-01-01 00:00:00 +0000
+++ YouTube/src/CertHandler.cs 2010-05-09 17:35:41 +0000
@@ -0,0 +1,37 @@
1/* CertHandler.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21using System;
22using System.Net;
23using System.Collections;
24using System.Security.Cryptography.X509Certificates;
25
26namespace Youtube
27{
28
29 public class CertHandler : ICertificatePolicy
30 {
31 public bool CheckValidationResult (ServicePoint sp, X509Certificate cert,
32 WebRequest request, int error)
33 {
34 return true;
35 }
36 }
37}
038
=== modified file 'YouTube/src/Preferences.cs'
--- YouTube/src/Preferences.cs 2009-06-22 04:05:16 +0000
+++ YouTube/src/Preferences.cs 2010-05-09 17:35:41 +0000
@@ -1,8 +1,28 @@
1/* Preferences.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using Mono.Addins;22using Mono.Addins;
3using Do.Platform;23using Do.Platform;
424
5namespace Do.Universe25namespace Youtube
6{ 26{
7 public class YouTubePreferences27 public class YouTubePreferences
8 {28 {
929
=== modified file 'YouTube/src/YouTubeFavoriteItemSource.cs'
--- YouTube/src/YouTubeFavoriteItemSource.cs 2009-06-22 04:05:16 +0000
+++ YouTube/src/YouTubeFavoriteItemSource.cs 2010-05-09 17:35:41 +0000
@@ -1,3 +1,23 @@
1/* YouTubeFavoriteItemSource.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using System.Collections.Generic;22using System.Collections.Generic;
3using Mono.Addins;23using Mono.Addins;
@@ -6,7 +26,7 @@
6using Do.Platform.Linux;26using Do.Platform.Linux;
7using System.Threading;27using System.Threading;
828
9namespace Do.Universe29namespace Youtube
10{30{
11 public class YouTubeFavoriteItemSource : ItemSource, IConfigurable31 public class YouTubeFavoriteItemSource : ItemSource, IConfigurable
12 {32 {
1333
=== modified file 'YouTube/src/YouTubeOwnVideosItemSource.cs'
--- YouTube/src/YouTubeOwnVideosItemSource.cs 2009-06-22 04:05:16 +0000
+++ YouTube/src/YouTubeOwnVideosItemSource.cs 2010-05-09 17:35:41 +0000
@@ -1,8 +1,22 @@
1// YouTubeOwnVideosSource.cs created with MonoDevelop1/* YouTubeOwnVideosItemSource.cs
2// User: luis at 08:50 p 10/09/20082 *
3//3 * GNOME Do is the legal property of its developers. Please refer to the
4// To change standard headers go to Edit->Preferences->Coding->Standard Headers4 * COPYRIGHT file distributed with this
5//5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
620
7using System;21using System;
8using System.Collections.Generic;22using System.Collections.Generic;
@@ -10,7 +24,7 @@
10using System.Threading;24using System.Threading;
11using Do.Universe;25using Do.Universe;
1226
13namespace Do.Universe27namespace Youtube
14{28{
15 29
16 30
1731
=== modified file 'YouTube/src/YouTubeSearchAction.cs'
--- YouTube/src/YouTubeSearchAction.cs 2009-02-01 20:19:36 +0000
+++ YouTube/src/YouTubeSearchAction.cs 2010-05-09 17:35:41 +0000
@@ -1,10 +1,30 @@
1/* YouTubeSearchAction.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using System.Collections.Generic;22using System.Collections.Generic;
3using Do.Universe;23using Do.Universe;
4using Do.Platform;24using Do.Platform;
5using System.Linq;25using System.Linq;
626
7namespace Do.Universe27namespace Youtube
8{28{
9 public class YouTubeSearchAction : Act29 public class YouTubeSearchAction : Act
10 {30 {
@@ -39,22 +59,9 @@
39 59
40 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)60 public override IEnumerable<Item> Perform (IEnumerable<Item> items, IEnumerable<Item> modItems)
41 { 61 {
42
43 //string search = "";
44
45// foreach (Item item in items) {
46// if (item is IUrlItem) {
47// search = (item as IUrlItem).Url;
48// } else if (item is ITextItem) {
49// search = (item as ITextItem).Text;
50// }
51// search = search.Replace (" ", "%20");
52// Services.Environment.OpenUrl(url+search);
53// }
54
55 string search = (items.First() as ITextItem).Text; 62 string search = (items.First() as ITextItem).Text;
56 search = search.Replace (" ", "%20");63 search = search.Replace (" ", "%20");
57 Services.Environment.OpenUrl(Youtube.searchUrl+search);64 Services.Environment.OpenUrl(String.Format(Youtube.searchUrl, search));
58 yield break;65 yield break;
59 }66 }
60 }67 }
6168
=== modified file 'YouTube/src/YouTubeSubscriptionItem.cs'
--- YouTube/src/YouTubeSubscriptionItem.cs 2009-02-01 20:19:36 +0000
+++ YouTube/src/YouTubeSubscriptionItem.cs 2010-05-09 17:35:41 +0000
@@ -1,7 +1,28 @@
1/* YouTubeSubscriptionItem.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
1using System;22using System;
2using Do.Universe;23using Do.Universe;
324
4namespace Do.Universe25namespace Youtube
5{ 26{
6 public class YouTubeSubscriptionItem : Item, IUrlItem27 public class YouTubeSubscriptionItem : Item, IUrlItem
7 {28 {
829
=== modified file 'YouTube/src/YouTubeSubscriptionItemSource.cs'
--- YouTube/src/YouTubeSubscriptionItemSource.cs 2009-06-22 04:05:16 +0000
+++ YouTube/src/YouTubeSubscriptionItemSource.cs 2010-05-09 17:35:41 +0000
@@ -1,10 +1,31 @@
1/* YouTubeSubscriptionItemSource.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21
1using System;22using System;
2using System.Collections.Generic;23using System.Collections.Generic;
3using Mono.Addins;24using Mono.Addins;
4using System.Threading;25using System.Threading;
5using Do.Universe;26using Do.Universe;
627
7namespace Do.Universe28namespace Youtube
8{ 29{
9 public class YouTubeSubscriptionItemSource : ItemSource30 public class YouTubeSubscriptionItemSource : ItemSource
10 {31 {
1132
=== modified file 'YouTube/src/Youtube.cs'
--- YouTube/src/Youtube.cs 2009-06-22 04:05:16 +0000
+++ YouTube/src/Youtube.cs 2010-05-09 17:35:41 +0000
@@ -1,3 +1,23 @@
1/* Youtube.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using System.IO;22using System.IO;
3using System.Net;23using System.Net;
@@ -10,119 +30,127 @@
10using Google.GData.YouTube;30using Google.GData.YouTube;
11using Google.GData.Extensions.MediaRss;31using Google.GData.Extensions.MediaRss;
1232
13namespace Do.Universe33namespace Youtube
14{34{
15 public class Youtube35 public class Youtube
16 {36 {
1737
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, "
19 + "are your credentials valid?");39 + "are your credentials valid?");
20 40
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 "
22 + "login information in YouTube plugin configuration.");42 + "login information in YouTube plugin configuration.");
23 43
24 public const string appName = "luismmontielg-gnomeDoYoutubePlugin0.1";44 private const string appName = "gnome-do-plugin";
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}";
26 public static string clientID = "ytapi-lmg-test-ojd8d285-0";46 private const string clientID = "gnome-do-client";
27 public static string developerKey = "AI39si5c61jYzQLvzEDjAnU1HOQIf-DzyzvIBXAkGJ82NlXoMg10RDW1sRz5Uyodv9_ETPzmJXdfFqVRNt51yGkkNo2YW0BdxQ";47 private const string developerKey = "AI39si5utjLEVOmAty2JLxz8KlixVQkwbSsEZqUXVUV-hUK1zDctrUbujGL2kWJBs47a7CaO-LOf_FXUiyuvQ9j7pbq8YO9wsA";
48
28 public static List<Item> favorites;49 public static List<Item> favorites;
29 public static List<Item> subscriptions;50 public static List<Item> subscriptions;
30 public static List<Item> own;51 public static List<Item> own;
52
31 private static YouTubeService service;53 private static YouTubeService service;
32 private static string username;54 private static string username;
33 private static string password;55 private static string password;
56
34 private static int subUpdate;57 private static int subUpdate;
35 private static int favUpdate;58 private static int favUpdate;
36 private static int ownUpdate;59 private static int ownUpdate;
37 60
61 private const string favoritesQueryTemplate = "http://gdata.youtube.com/feeds/api/users/default/favorites?start-index={0}&max-results={1}";
62 private const string ownQueryTemplate = "http://gdata.youtube.com/feeds/api/users/default/uploads?start-index={0}&max-results={1}";
63 private const string youtubeWatchUrlTemplate = "http://www.youtube.com/watch?v={0}";
64
38 public static YouTubePreferences Preferences { get; private set; }65 public static YouTubePreferences Preferences { get; private set; }
39 66
40 static Youtube()67 static Youtube()
41 {68 {
42 Youtube.favorites = new List<Item>();69 Youtube.favorites = new List<Item>();
43 Youtube.own = new List<Item>();70 Youtube.own = new List<Item>();
44 Youtube.subscriptions = new List<Item>();71 Youtube.subscriptions = new List<Item>();
72
45 Preferences = new YouTubePreferences ();73 Preferences = new YouTubePreferences ();
74
46 subUpdate = 0;75 subUpdate = 0;
47 favUpdate = 0;76 favUpdate = 0;
48 ownUpdate = 0;77 ownUpdate = 0;
78
49 username = Preferences.Username;79 username = Preferences.Username;
50 password = Preferences.Password;80 password = Preferences.Password;
81
51 Connect (username, password);82 Connect (username, password);
52 }83 }
53 84
85 private static void parseFeed(YouTubeFeed feed, List<Item> videos)
86 {
87 string description = "";
88 string url = null;
89 foreach(YouTubeEntry entry in feed.Entries)
90 {
91 description = "";
92 url = String.Format(youtubeWatchUrlTemplate, entry.VideoId);
93 if (entry.Media.Description != null)
94 {
95 description = entry.Media.Description.Value;
96 }
97 YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, description);
98 videos.Add(video);
99 }
100 }
101
102 private static void update(string queryTemplate, List<Item> videos, ref int counter, string category)
103 {
104 if (videos.Count != 0 || (counter % 20 != 0 && counter != 0))
105 {
106 counter = counter + 1;
107 return;
108 }
109
110 counter = counter + 1;
111
112 videos.Clear();
113 int maxResults = 50;
114 int startIndex = 1;
115
116 string feedUrl = String.Format(queryTemplate, startIndex, maxResults);
117
118 YouTubeQuery query = new YouTubeQuery(feedUrl);
119 YouTubeFeed videoFeed = null;
120
121 try
122 {
123 videoFeed = service.Query(query);
124 while(videoFeed.Entries.Count > 0)
125 {
126 parseFeed(videoFeed, videos);
127
128 startIndex += maxResults;
129 feedUrl = String.Format(queryTemplate, startIndex, maxResults);
130 query = new YouTubeQuery(feedUrl);
131 videoFeed = service.Query(query);
132 }
133 startIndex = 1;
134 Log<Youtube>.Debug("Finished updating {0} videos", category);
135 }
136 catch(Exception e)
137 {
138 Log<Youtube>.Error ("Error getting {0} videos - {1}", category, e.Message);
139 Log<Youtube>.Debug (e.StackTrace);
140 }
141
142 }
143
54 public static void updateFavorites()144 public static void updateFavorites()
55 {145 {
56 favUpdate++;146 update (favoritesQueryTemplate, Youtube.favorites, ref favUpdate, "favorites");
57 Log<Youtube>.Debug("Update favorites videos tries = {0} - favorite.Count : {1}", favUpdate, Youtube.favorites.Count);
58 if (Youtube.favorites.Count == 0 || favUpdate%20 == 0){
59 Youtube.favorites.Clear();
60 int maxResults = 50;
61 int startIndex = 1;
62
63 string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/favorites?start-index="+ startIndex +"&max-results="+maxResults;
64 YouTubeQuery query = new YouTubeQuery(feedUrl);
65 Log<Youtube>.Debug("feedUrl for favorites videos: {0}", feedUrl);
66 try{
67 YouTubeFeed videoFeed = service.Query(query);
68 while(videoFeed.Entries.Count > 0){
69 foreach (YouTubeEntry entry in videoFeed.Entries)
70 {
71 //Log<Youtube>.Debug("Video #{0}, Title: {1}", ++i, entry.Title.Text);
72 string url = ("http://www.youtube.com/watch?v="+entry.VideoId);
73 //Log<Youtube>.Debug("Video url: {0}", url);
74 YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, entry.Media.Description.Value);
75 favorites.Add(video);
76 }
77 startIndex += maxResults;
78 feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/favorites?start-index="+ startIndex +"&max-results="+maxResults;
79 query = new YouTubeQuery(feedUrl);
80 videoFeed = service.Query(query);
81 }
82 startIndex = 1;
83 Log<Youtube>.Debug("Finished updating favorite videos");
84 }catch(Exception e) {
85 Log<Youtube>.Error ("Error getting favorites videos - {0}", e.Message);
86 Log<Youtube>.Debug (e.StackTrace);
87 }
88 }
89 }147 }
90 148
91 public static void updateOwn()149 public static void updateOwn()
92 {150 {
93 ownUpdate++;151 update (ownQueryTemplate, Youtube.own, ref ownUpdate, "own youtube");
94 Log<Youtube>.Debug("Update own videos tries = {0} - own.Count : {1}", ownUpdate, Youtube.own.Count);152 }
95 if (Youtube.own.Count == 0 || ownUpdate%20 == 0){153
96 Youtube.own.Clear();
97 int maxResults = 50;
98 int startIndex = 1;
99
100 string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/uploads?start-index="+ startIndex +"&max-results="+maxResults;
101 YouTubeQuery query = new YouTubeQuery(feedUrl);
102 Log<Youtube>.Debug("feedUrl for own videos: {0}", feedUrl);
103 try{
104 YouTubeFeed videoFeed = service.Query(query);
105 while(videoFeed.Entries.Count > 0){
106 foreach (YouTubeEntry entry in videoFeed.Entries)
107 {
108 //Log<Youtube>.Debug("Video #{0}, Title(own video): {1}", ++i, entry.Title.Text);
109 string url = "http://www.youtube.com/watch?v="+entry.VideoId;
110 YoutubeVideoItem video = new YoutubeVideoItem(entry.Title.Text, url, entry.Media.Description.Value);
111 own.Add(video);
112 }
113 startIndex += maxResults;
114 feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/uploads?start-index="+ startIndex +"&max-results="+maxResults;
115 query = new YouTubeQuery(feedUrl);
116 videoFeed = service.Query(query);
117 }
118 Log<Youtube>.Debug("Finished updating own videos");
119 }catch(Exception e) {
120 Log<Youtube>.Error ("Error getting own videos - {0}", e.Message);
121 Log<Youtube>.Debug (e.StackTrace);
122 }
123 }
124 }
125
126 public static void updateSubscriptions()154 public static void updateSubscriptions()
127 {155 {
128 subUpdate++;156 subUpdate++;
@@ -130,19 +158,19 @@
130 if (Youtube.subscriptions.Count == 0 || subUpdate%20==0){158 if (Youtube.subscriptions.Count == 0 || subUpdate%20==0){
131 Youtube.subscriptions.Clear();159 Youtube.subscriptions.Clear();
132 160
133 string feedUrl = "http://gdata.youtube.com/feeds/api/users/"+ username +"/subscriptions";161 string feedUrl = "http://gdata.youtube.com/feeds/api/users/default/subscriptions";
134 YouTubeQuery query = new YouTubeQuery(feedUrl);162 YouTubeQuery query = new YouTubeQuery(feedUrl);
135 Log<Youtube>.Debug("feedUrl for subscriptions: {0}", feedUrl); 163 Log<Youtube>.Debug("feedUrl for subscriptions: {0}", feedUrl);
164 SubscriptionFeed subFeed = null;
165 string url = "http://www.youtube.com/user/{0}";
136 try166 try
137 {167 {
138 SubscriptionFeed subFeed = service.GetSubscriptions(query);168 subFeed = service.GetSubscriptions(query);
139 if(subFeed.Entries.Count > 0){169 if(subFeed.Entries.Count > 0){
140 foreach (SubscriptionEntry entry in subFeed.Entries)170 foreach (SubscriptionEntry entry in subFeed.Entries)
141 {171 {
142 //Log<Youtube>.Debug("Subscriptions - {0}", ++i);172 YouTubeSubscriptionItem subscription =
143 //Log<Youtube>.Debug("{0}", entry.Title.Text);173 new YouTubeSubscriptionItem(entry.UserName, String.Format(url, entry.UserName), entry.Title.Text);
144 string url = "http://www.youtube.com/user/" + entry.UserName;
145 YouTubeSubscriptionItem subscription = new YouTubeSubscriptionItem(entry.UserName, url, entry.Title.Text);
146 Youtube.subscriptions.Add(subscription);174 Youtube.subscriptions.Add(subscription);
147 }175 }
148 }176 }
@@ -150,12 +178,14 @@
150 }178 }
151 catch(Exception e) 179 catch(Exception e)
152 {180 {
153 Log<Youtube>.Error ("Error getting subscriptions - {0}", e.Message);181 Log<Youtube>.Error ("Error getting subscriptions - {0}", e.Message);
154 Log<Youtube>.Debug (e.StackTrace);182 Log<Youtube>.Debug (e.StackTrace);
155 }183 }
156 }184 }
157 } 185 }
158 186
187
188
159 public static bool TryConnect (string username, string password)189 public static bool TryConnect (string username, string password)
160 {190 {
161 try {191 try {
@@ -180,8 +210,10 @@
180 try {210 try {
181 service = new YouTubeService (appName, clientID, developerKey);211 service = new YouTubeService (appName, clientID, developerKey);
182 service.setUserCredentials (username, password);212 service.setUserCredentials (username, password);
213 ServicePointManager.CertificatePolicy = new CertHandler ();
183 } catch (Exception e) {214 } catch (Exception e) {
184 Log<Youtube>.Error (ConnectionErrorMessage);215 Log<Youtube>.Error (ConnectionErrorMessage);
216 Log<Youtube>.Error (e.Message);
185 }217 }
186 }218 }
187 }219 }
188220
=== modified file 'YouTube/src/YoutubeConfig.cs'
--- YouTube/src/YoutubeConfig.cs 2009-02-01 20:19:36 +0000
+++ YouTube/src/YoutubeConfig.cs 2010-05-09 17:35:41 +0000
@@ -1,9 +1,29 @@
1/* YoutubeConfig.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using Gtk;22using Gtk;
3using Do.Platform;23using Do.Platform;
4using Do.Platform.Linux;24using Do.Platform.Linux;
525
6namespace Do.Universe26namespace Youtube
7{ 27{
8 28
9 public class YouTubeConfig : AbstractLoginWidget29 public class YouTubeConfig : AbstractLoginWidget
1030
=== modified file 'YouTube/src/YoutubeVideoItem.cs'
--- YouTube/src/YoutubeVideoItem.cs 2009-02-01 20:19:36 +0000
+++ YouTube/src/YoutubeVideoItem.cs 2010-05-09 17:35:41 +0000
@@ -1,7 +1,27 @@
1/* YouTubeVideoItem.cs
2 *
3 * GNOME Do is the legal property of its developers. Please refer to the
4 * COPYRIGHT file distributed with this
5 * source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
1using System;21using System;
2using Do.Universe;22using Do.Universe;
323
4namespace Do.Universe24namespace Youtube
5{ 25{
6 public class YoutubeVideoItem : Item, IUrlItem26 public class YoutubeVideoItem : Item, IUrlItem
7 {27 {
@@ -35,6 +55,5 @@
35 {55 {
36 get { return url; }56 get { return url; }
37 }57 }
38
39 }58 }
40}59}

Subscribers

People subscribed via source and target branches