From 33bff8e1f0a372a8b73959a846181f6363037f5e Mon Sep 17 00:00:00 2001 From: Anders Bjerner Date: Tue, 9 Jan 2024 19:18:51 +0100 Subject: [PATCH] Updated all Skybrud dependencies --- .../Providers/YouTube/YouTubeVideoProvider.cs | 19 ++++++++++--------- .../Skybrud.VideoPicker.csproj | 8 ++++---- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/Skybrud.VideoPicker/Providers/YouTube/YouTubeVideoProvider.cs b/src/Skybrud.VideoPicker/Providers/YouTube/YouTubeVideoProvider.cs index f302bca..26c1c75 100644 --- a/src/Skybrud.VideoPicker/Providers/YouTube/YouTubeVideoProvider.cs +++ b/src/Skybrud.VideoPicker/Providers/YouTube/YouTubeVideoProvider.cs @@ -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; @@ -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"; @@ -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; @@ -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; @@ -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 { o.VideoId } }); // Get the first video object from the response body diff --git a/src/Skybrud.VideoPicker/Skybrud.VideoPicker.csproj b/src/Skybrud.VideoPicker/Skybrud.VideoPicker.csproj index 96ab2fb..3c0fc6c 100644 --- a/src/Skybrud.VideoPicker/Skybrud.VideoPicker.csproj +++ b/src/Skybrud.VideoPicker/Skybrud.VideoPicker.csproj @@ -23,10 +23,10 @@ - - - - + + + + all