diff --git a/functions/Set-YouTubeVideoRating.ps1 b/functions/Set-YouTubeVideoRating.ps1 new file mode 100644 index 0000000..722cb6a --- /dev/null +++ b/functions/Set-YouTubeVideoRating.ps1 @@ -0,0 +1,17 @@ +function Set-YouTubeVideoRating { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $true)] + [string] $VideoId, + [Parameter(Mandatory = $false)] + [ValidateSet('dislike','like','none')] + [string] $Rating = 'none' + ) + + $Request = @{ + Uri = 'https://www.googleapis.com/youtube/v3/videos/rate?id={0}&rating={1}' -f $VideoId, $Rating + Method = 'Post' + Headers = (Get-AccessToken) + } + Invoke-RestMethod @Request +} \ No newline at end of file diff --git a/youtube.psd1 b/youtube.psd1 index 4d3eaf4..281d780 100644 --- a/youtube.psd1 +++ b/youtube.psd1 @@ -24,6 +24,7 @@ 'Remove-YouTubeSubscription' 'Get-YouTubeActivity' 'Get-YouTubeChannel' + 'Set-YouTubeVideoRating' ) AliasesToExport = @('') VariablesToExport = @('')