Skip to content

Commit

Permalink
Updated all Skybrud dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Jan 9, 2024
1 parent 2254304 commit 33bff8e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
19 changes: 10 additions & 9 deletions src/Skybrud.VideoPicker/Providers/YouTube/YouTubeVideoProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text.RegularExpressions;
using System.Xml.Linq;
Expand All @@ -18,9 +19,9 @@
using Skybrud.VideoPicker.Services;

namespace Skybrud.VideoPicker.Providers.YouTube {

public class YouTubeVideoProvider : IVideoProvider {

public string Alias => "youtube";

public string Name => "YouTube";
Expand All @@ -44,7 +45,7 @@ public virtual bool IsMatch(VideoPickerService service, string source, out IVide
source = m0.Groups[1].Value;

}

// Does "source" match known formats of YouTube video URLs?
Match m1 = Regex.Match(source, @"youtu(?:\.be|be\.com|be-nocookie\.com)/(embed/|)(?:.*v(?:/|=)|(?:.*/)?)([a-zA-Z0-9-_]+)", RegexOptions.IgnoreCase);
if (m1.Success == false) return false;
Expand All @@ -55,7 +56,7 @@ public virtual bool IsMatch(VideoPickerService service, string source, out IVide
// Get the first credentials (or trigger an error if none)
YouTubeCredentials credentials = youtube?.Credentials.FirstOrDefault();
if (string.IsNullOrWhiteSpace(credentials?.ServerKey)) throw new VideosException("YouTube provider is not configured.");

// Get the video ID from the regex
string videoId = m1.Groups[2].Value;

Expand All @@ -76,12 +77,12 @@ public VideoPickerValue GetVideo(VideoPickerService service, IVideoOptions optio
if (string.IsNullOrWhiteSpace(credentials?.ServerKey)) throw new VideosException("YouTube provider is not configured.");

// Initialize a new GoogleService instance for accessing the YouTube API
GoogleService google = GoogleService.CreateFromServerKey(credentials.ServerKey);
GoogleHttpService google = GoogleHttpService.CreateFromApiKey(credentials.ServerKey);

// Make the request to the YouTube API
YouTubeGetVideoListResponse response = google.YouTube().Videos.GetVideos(new YouTubeGetVideoListOptions {
YouTubeVideoListResponse response = google.YouTube().Videos.GetVideos(new YouTubeGetVideoListOptions {
Part = YouTubeVideoParts.Snippet + YouTubeVideoParts.ContentDetails,
Ids = new[] { o.VideoId }
Ids = new List<string> { o.VideoId }
});

// Get the first video object from the response body
Expand Down
8 changes: 4 additions & 4 deletions src/Skybrud.VideoPicker/Skybrud.VideoPicker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Skybrud.Essentials.Http" Version="1.0.14" />
<PackageReference Include="Skybrud.Social.Google.YouTube" Version="1.0.0-beta001" />
<PackageReference Include="Skybrud.Social.Vimeo" Version="1.0.0-beta005" />
<PackageReference Include="Skybrud.WebApi.Json" Version="1.0.4" />
<PackageReference Include="Skybrud.Essentials.Http" Version="1.1.5" />
<PackageReference Include="Skybrud.Social.Google.YouTube" Version="1.0.0" />
<PackageReference Include="Skybrud.Social.Vimeo" Version="1.0.1" />
<PackageReference Include="Skybrud.WebApi.Json" Version="1.1.0" />
<PackageReference Include="UmbracoCms.Web" Version="8.1.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down

0 comments on commit 33bff8e

Please sign in to comment.