Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube ECL Provider with google youtube v3 #1

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions Blocks.Tridion.ECL.YouTube.Tests/App.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="AppName" value="Your YouTube App Name"/>
<add key="DeveloperKey" value="Your YouTube Developer Key"/>
<add key="Username" value="Your YouTube/Google Username"/>
<add key="Password" value="Your YouTube/Google Password"/>
<add key="AppName" value="Youtube" />
<add key="ApiKey" value="Your Google Api Key" />
<add key="Username" value="Your YouTube/Google Username" />
</appSettings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.0.8.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.9.0" newVersion="2.6.9.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.22.0" newVersion="2.2.22.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Net.Http.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.2.22.0" newVersion="2.2.22.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,39 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Google.GData.Client">
<HintPath>..\packages\Google.GData.Client.2.1.0.0\lib\Google.GData.Client.dll</HintPath>
<Reference Include="Google.Apis">
<HintPath>..\packages\Google.Apis.1.9.0\lib\net40\Google.Apis.dll</HintPath>
</Reference>
<Reference Include="Google.GData.Extensions">
<HintPath>..\packages\Google.GData.Extensions.2.1.0.0\lib\Google.GData.Extensions.dll</HintPath>
<Reference Include="Google.Apis.Auth">
<HintPath>..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.dll</HintPath>
</Reference>
<Reference Include="Google.GData.YouTube">
<HintPath>..\packages\Google.GData.YouTube.2.1.0.0\lib\Google.GData.YouTube.dll</HintPath>
<Reference Include="Google.Apis.Auth.PlatformServices">
<HintPath>..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll</HintPath>
<Reference Include="Google.Apis.Core">
<HintPath>..\packages\Google.Apis.Core.1.9.0\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.Core.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.PlatformServices">
<HintPath>..\packages\Google.Apis.1.9.0\lib\net40\Google.Apis.PlatformServices.dll</HintPath>
</Reference>
<Reference Include="Google.Apis.YouTube.v3">
<HintPath>..\packages\Google.Apis.YouTube.v3.1.9.0.1370\lib\portable-net40+sl50+win+wpa81+wp80\Google.Apis.YouTube.v3.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Newtonsoft.Json.6.0.4\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -53,7 +75,34 @@
<Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.IO">
<HintPath>..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Net.Http, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Extensions">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.Primitives">
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.Primitives.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http.WebRequest, Version=2.2.22.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\Microsoft.Net.Http.2.2.22\lib\net40\System.Net.Http.WebRequest.dll</HintPath>
</Reference>
<Reference Include="System.Runtime">
<HintPath>..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.1.1.9\lib\net40\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Zlib.Portable">
<HintPath>..\packages\Zlib.Portable.1.10.0\lib\portable-net4+sl5+wp8+win8+wpa81+MonoTouch+MonoAndroid\Zlib.Portable.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
Expand All @@ -77,6 +126,11 @@
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
26 changes: 26 additions & 0 deletions Blocks.Tridion.ECL.YouTube.Tests/ExternalContentLibrary.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8" ?>
<Configuration xmlns="http://www.sdltridion.com/ExternalContentLibrary/Configuration">
<!-- Available logging levels: Debug, Info, Warning, Error -->
<l:Logging Level="Warning" xmlns:l="http://www.sdltridion.com/Infrastructure/LoggingConfiguration">
<!-- Additional supported attributes: Language="rfc1766 code" Locale="rfc1766 code". An example of an rfc1766 code is "de-DE" for German. /-->
<!-- <l:Folder>Full path to logging folder, default is %TRIDION%/bin/log</l:Folder>-->
</l:Logging>
<CoreServiceUrl>net.tcp://localhost:2660/CoreService/2011/netTcp</CoreServiceUrl>
<MountPoints>
<MountPoint type="YouTubeProvider" version="*" id="youtube" rootItemName="YouTube">
<StubFolders>
<StubFolder id="tcm:1-3-2" />
</StubFolders>
<PrivilegedUserName>DOMAIN\user</PrivilegedUserName>
<AppName xmlns="http://gdata.youtube.com/schemas/2007">Your YouTube App Name</AppName>
<ApiKey xmlns="http://gdata.youtube.com/schemas/2007">Your Google API Key</ApiKey>
<Users xmlns="http://gdata.youtube.com/schemas/2007">
<User></User>
<User></User>
</Users>
<ProxyURI xmlns="http://gdata.youtube.com/schemas/2007">Proxy Address</ProxyURI>
<ProxyUser xmlns="http://gdata.youtube.com/schemas/2007">Proxy Username </ProxyUser>
<ProxyPassword xmlns="http://gdata.youtube.com/schemas/2007">Proxy Password</ProxyPassword>
</MountPoint>
</MountPoints>
</Configuration>
14 changes: 2 additions & 12 deletions Blocks.Tridion.ECL.YouTube.Tests/YouTubeClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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()
{
Expand Down
15 changes: 11 additions & 4 deletions Blocks.Tridion.ECL.YouTube.Tests/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Google.GData.Client" version="2.1.0.0" targetFramework="net40" />
<package id="Google.GData.Extensions" version="2.1.0.0" targetFramework="net40" />
<package id="Google.GData.YouTube" version="2.1.0.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.0.8" targetFramework="net40" />
<package id="Google.Apis" version="1.9.0" targetFramework="net40" />
<package id="Google.Apis.Auth" version="1.9.0" targetFramework="net40" />
<package id="Google.Apis.Core" version="1.9.0" targetFramework="net40" />
<package id="Google.Apis.YouTube.v3" version="1.9.0.1370" targetFramework="net40" />
<package id="log4net" version="2.0.3" targetFramework="net40" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net40" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40" />
<package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net40" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net40" />
<package id="NUnit" version="2.6.2" targetFramework="net40" />
<package id="Zlib.Portable" version="1.10.0" targetFramework="net40" />
</packages>
40 changes: 40 additions & 0 deletions Blocks.Tridion.ECL.YouTube/API/Video.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}
Loading