From 039bee555e4a8ad0e901259204e4a7be8b77c5da Mon Sep 17 00:00:00 2001 From: Mohamed Rafeeq Date: Thu, 28 May 2015 17:28:53 +0400 Subject: [PATCH 1/7] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 64249be..e61b856 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,5 @@ This is an External Content Library provider which exposes videos from YouTube in SDL Tridion 2013. The first version supports displaying videos from a single specified account, but could potentially be extended to allow search, multiple users, video upload and publishing in future. -[https://www.sdltridionworld.com/community/2011_extensions/youtube_ecl_provider.aspx](https://www.sdltridionworld.com/community/2011_extensions/youtube_ecl_provider.aspx) \ No newline at end of file + +[https://www.sdltridionworld.com/community/2011_extensions/youtube_ecl_provider.aspx](https://www.sdltridionworld.com/community/2011_extensions/youtube_ecl_provider.aspx) From aa2daaefeddcce8b6b35dd13694b1f821b71ef58 Mon Sep 17 00:00:00 2001 From: Mohamed Rafeeq Date: Thu, 28 May 2015 21:07:19 +0400 Subject: [PATCH 2/7] Adding support google api 3 versions Adding support google api 3 versions --- Blocks.Tridion.ECL.YouTube.Tests/App.config | 33 ++- .../Blocks.Tridion.ECL.YouTube.Tests.csproj | 70 ++++++- .../ExternalContentLibrary.xml | 26 +++ .../YouTubeClientTests.cs | 14 +- .../packages.config | 15 +- Blocks.Tridion.ECL.YouTube/API/Video.cs | 40 ++++ .../API/YouTubeClient.cs | 195 +++++++++++++----- .../Blocks.Tridion.ECL.YouTube.csproj | 84 ++++++-- .../Extensions/TemplateAttributeExtensions.cs | 2 +- Blocks.Tridion.ECL.YouTube/YouTubeListItem.cs | 58 +++++- .../YouTubeMountPoint.cs | 49 +++-- Blocks.Tridion.ECL.YouTube/YouTubeProvider.cs | 41 +++- Blocks.Tridion.ECL.YouTube/YouTubeVideo.cs | 23 ++- Blocks.Tridion.ECL.YouTube/app.config | 23 +++ Blocks.Tridion.ECL.YouTube/packages.config | 15 +- 15 files changed, 547 insertions(+), 141 deletions(-) create mode 100644 Blocks.Tridion.ECL.YouTube.Tests/ExternalContentLibrary.xml create mode 100644 Blocks.Tridion.ECL.YouTube/API/Video.cs create mode 100644 Blocks.Tridion.ECL.YouTube/app.config diff --git a/Blocks.Tridion.ECL.YouTube.Tests/App.config b/Blocks.Tridion.ECL.YouTube.Tests/App.config index 2fa18b6..e90f915 100644 --- a/Blocks.Tridion.ECL.YouTube.Tests/App.config +++ b/Blocks.Tridion.ECL.YouTube.Tests/App.config @@ -1,9 +1,32 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Blocks.Tridion.ECL.YouTube.Tests/Blocks.Tridion.ECL.YouTube.Tests.csproj b/Blocks.Tridion.ECL.YouTube.Tests/Blocks.Tridion.ECL.YouTube.Tests.csproj index b4d4ce1..6c6ed42 100644 --- a/Blocks.Tridion.ECL.YouTube.Tests/Blocks.Tridion.ECL.YouTube.Tests.csproj +++ b/Blocks.Tridion.ECL.YouTube.Tests/Blocks.Tridion.ECL.YouTube.Tests.csproj @@ -32,17 +32,39 @@ 4 - - ..\packages\Google.GData.Client.2.1.0.0\lib\Google.GData.Client.dll + + ..\packages\Google.Apis.1.9.0\lib\net40\Google.Apis.dll - - ..\packages\Google.GData.Extensions.2.1.0.0\lib\Google.GData.Extensions.dll + + ..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.dll - - ..\packages\Google.GData.YouTube.2.1.0.0\lib\Google.GData.YouTube.dll + + ..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.PlatformServices.dll - - ..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll + + ..\packages\Google.Apis.Core.1.9.0\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll + + + ..\packages\Google.Apis.1.9.0\lib\net40\Google.Apis.PlatformServices.dll + + + ..\packages\Google.Apis.YouTube.v3.1.9.0.1370\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.YouTube.v3.dll + + + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + False + ..\packages\Newtonsoft.Json.6.0.4\lib\net40\Newtonsoft.Json.dll False @@ -53,7 +75,34 @@ + + ..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll + + + + False + ..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.dll + + + ..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.Extensions.dll + + + ..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.Primitives.dll + + + False + ..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.WebRequest.dll + + + ..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll + + + ..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll + + + ..\packages\Zlib.Portable.1.10.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll + @@ -77,6 +126,11 @@ + + + + + + + + + + net.tcp://localhost:2660/CoreService/2011/netTcp + + + + + + DOMAIN\user + Your YouTube App Name + Your Google API Key + + + + + Proxy Address + Proxy Username + Proxy Password + + + \ No newline at end of file diff --git a/Blocks.Tridion.ECL.YouTube.Tests/YouTubeClientTests.cs b/Blocks.Tridion.ECL.YouTube.Tests/YouTubeClientTests.cs index b99b995..5abdb9c 100644 --- a/Blocks.Tridion.ECL.YouTube.Tests/YouTubeClientTests.cs +++ b/Blocks.Tridion.ECL.YouTube.Tests/YouTubeClientTests.cs @@ -17,9 +17,8 @@ public void Setup() var appSettings = ConfigurationManager.AppSettings; _client = new YouTubeClient(appSettings["AppName"], - appSettings["DeveloperKey"], - appSettings["Username"], - appSettings["Password"]); + appSettings["ApiKey"], + appSettings["Username"]); } [Test] @@ -33,15 +32,6 @@ public void Can_get_videos() Assert.That(videos, Is.Not.Empty); } - [Test] - public void Can_get_popular_videos() - { - var videos = _client.GetMostPopular(); - - Assert.That(videos, Is.Not.Null); - Assert.That(videos, Is.Not.Empty); - } - [Test] public void Can_get_video_by_id() { diff --git a/Blocks.Tridion.ECL.YouTube.Tests/packages.config b/Blocks.Tridion.ECL.YouTube.Tests/packages.config index 6a39539..6caa7a8 100644 --- a/Blocks.Tridion.ECL.YouTube.Tests/packages.config +++ b/Blocks.Tridion.ECL.YouTube.Tests/packages.config @@ -1,8 +1,15 @@  - - - - + + + + + + + + + + + \ No newline at end of file diff --git a/Blocks.Tridion.ECL.YouTube/API/Video.cs b/Blocks.Tridion.ECL.YouTube/API/Video.cs new file mode 100644 index 0000000..f7a815e --- /dev/null +++ b/Blocks.Tridion.ECL.YouTube/API/Video.cs @@ -0,0 +1,40 @@ +using System; +using Google.Apis.YouTube.v3.Data; + +namespace Blocks.Tridion.ECL.YouTube.API +{ + public class Video + { + public Video(PlaylistItem result) + { + VideoId = result.Snippet.ResourceId.VideoId; + Title = result.Snippet.Title; + Uploader = ""; + Description = result.Snippet.Description; + //Type=result.Snippet. + Thumbnail = result.Snippet.Thumbnails.Default.Url; + ThumbnailETag = result.Snippet.Thumbnails.ETag; + } + + public Video(SearchResult result) + { + VideoId = result.Id.VideoId; + Title = result.Snippet.Title; + Uploader = ""; + Description = result.Snippet.Description; + //Type=result + Thumbnail = result.Snippet.Thumbnails.Default.Url; + ThumbnailETag = result.Snippet.Thumbnails.ETag; + } + + public DateTime? Published { get; set; } + public string Title { get; set; } + public string Uploader { get; set; } + public string Description { get; set; } + public string VideoId { get; set; } + public string Type { get; set; } + + public string Thumbnail { get; set; } + public string ThumbnailETag { get; set; } + } +} diff --git a/Blocks.Tridion.ECL.YouTube/API/YouTubeClient.cs b/Blocks.Tridion.ECL.YouTube/API/YouTubeClient.cs index de71a2c..a20e7c2 100644 --- a/Blocks.Tridion.ECL.YouTube/API/YouTubeClient.cs +++ b/Blocks.Tridion.ECL.YouTube/API/YouTubeClient.cs @@ -1,8 +1,10 @@ using System; using System.Collections.Generic; using System.Linq; -using Google.GData.YouTube; -using Google.YouTube; +using System.Net; +using Google.Apis.Services; +using Google.Apis.YouTube.v3; +using log4net.Repository.Hierarchy; namespace Blocks.Tridion.ECL.YouTube.API { @@ -11,26 +13,51 @@ namespace Blocks.Tridion.ECL.YouTube.API /// public class YouTubeClient { - private readonly YouTubeRequestSettings _settings; + private readonly YouTubeService _youTubeService; private readonly string _userName; + public WebProxy _proxy { get; set; } public string UserToDisplay { get; set; } + public List Users { get; set; } /// - /// Initializes a new instance of the class. + /// /// - /// The YouTube Application Name - /// The YouTube Developer Key - /// The YouTube Username - /// The YouTube Password. - public YouTubeClient(string appName, string developerKey, string userName, string password) + /// + /// + /// + public YouTubeClient(string appName, string apiKey, string userName) { - _settings = new YouTubeRequestSettings(appName, developerKey, userName, password); - _settings.AutoPaging = true; + _youTubeService = new YouTubeService( + new BaseClientService.Initializer() + { + ApplicationName = appName, + ApiKey = apiKey + }); + _userName = userName; + } + /// + /// Initializes a new instance of the class with proxy . + /// + /// + /// + /// + /// + public YouTubeClient(string appName, string apiKey, string userName, WebProxy proxy) + { + _youTubeService = new YouTubeService( + new BaseClientService.Initializer() + { + ApplicationName = appName, + ApiKey = apiKey + }); _userName = userName; + _proxy = proxy; + } + /// /// Retrieves a list of videos uploaded by the configured user. /// @@ -38,86 +65,140 @@ public IList