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
from
@@ -1,9 +1,32 @@
<?xml version="1.0" encoding="utf-8" ?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<appSettings> <appSettings>
<add key="AppName" value="Your YouTube App Name"/> <add key="AppName" value="Youtube" />
<add key="DeveloperKey" value="Your YouTube Developer Key"/> <add key="ApiKey" value="Your Google Api Key" />
<add key="Username" value="Your YouTube/Google Username"/> <add key="Username" value="Your YouTube/Google Username" />
<add key="Password" value="Your YouTube/Google Password"/>
</appSettings> </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> </configuration>
@@ -32,17 +32,39 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Google.GData.Client"> <Reference Include="Google.Apis">
<HintPath>..\packages\Google.GData.Client.2.1.0.0\lib\Google.GData.Client.dll</HintPath> <HintPath>..\packages\Google.Apis.1.9.0\lib\net40\Google.Apis.dll</HintPath>
</Reference> </Reference>
<Reference Include="Google.GData.Extensions"> <Reference Include="Google.Apis.Auth">
<HintPath>..\packages\Google.GData.Extensions.2.1.0.0\lib\Google.GData.Extensions.dll</HintPath> <HintPath>..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.dll</HintPath>
</Reference> </Reference>
<Reference Include="Google.GData.YouTube"> <Reference Include="Google.Apis.Auth.PlatformServices">
<HintPath>..\packages\Google.GData.YouTube.2.1.0.0\lib\Google.GData.YouTube.dll</HintPath> <HintPath>..\packages\Google.Apis.Auth.1.9.0\lib\net40\Google.Apis.Auth.PlatformServices.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json"> <Reference Include="Google.Apis.Core">
<HintPath>..\packages\Newtonsoft.Json.4.0.8\lib\net40\Newtonsoft.Json.dll</HintPath> <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>
<Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.6.2.12296, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
@@ -53,7 +75,34 @@
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" /> <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="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>
<ItemGroup> <ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
@@ -77,6 +126,11 @@
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" /> <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target> </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. <!-- 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. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
@@ -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>
@@ -17,9 +17,8 @@ public void Setup()
var appSettings = ConfigurationManager.AppSettings; var appSettings = ConfigurationManager.AppSettings;


_client = new YouTubeClient(appSettings["AppName"], _client = new YouTubeClient(appSettings["AppName"],
appSettings["DeveloperKey"], appSettings["ApiKey"],
appSettings["Username"], appSettings["Username"]);
appSettings["Password"]);
} }


[Test] [Test]
@@ -33,15 +32,6 @@ public void Can_get_videos()
Assert.That(videos, Is.Not.Empty); 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] [Test]
public void Can_get_video_by_id() public void Can_get_video_by_id()
{ {
@@ -1,8 +1,15 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Google.GData.Client" version="2.1.0.0" targetFramework="net40" /> <package id="Google.Apis" version="1.9.0" targetFramework="net40" />
<package id="Google.GData.Extensions" version="2.1.0.0" targetFramework="net40" /> <package id="Google.Apis.Auth" version="1.9.0" targetFramework="net40" />
<package id="Google.GData.YouTube" version="2.1.0.0" targetFramework="net40" /> <package id="Google.Apis.Core" version="1.9.0" targetFramework="net40" />
<package id="Newtonsoft.Json" version="4.0.8" 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="NUnit" version="2.6.2" targetFramework="net40" />
<package id="Zlib.Portable" version="1.10.0" targetFramework="net40" />
</packages> </packages>
@@ -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; }
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.