Skip to content

Commit

Permalink
💡 (getEpisodeList.ps1): comment out YouTube API key and video ID retr…
Browse files Browse the repository at this point in the history
…ieval function

The YouTube API key and the function to retrieve YouTube video IDs are
commented out to temporarily disable YouTube-related functionality. This
change is likely due to issues with the YouTube API or a decision to
pause the integration for now. It prevents unnecessary API calls and
potential errors while maintaining the code for future use.
  • Loading branch information
MrHinsh committed Nov 25, 2024
1 parent df25911 commit 661d4e4
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions .powershell/getEpisodeList.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ $spotifyClientId = "1120c6949df54792975a405bbdcaa3bf"
$spotifyClientSecret = $Env:SPOTIFY_CLIENT_SECRET

# Define your YouTube Data API Key
$youtubeApiKey = $Env:YOUTUBE_API_KEY
#$youtubeApiKey = $Env:YOUTUBE_API_KEY

# Define the YouTube channel ID to restrict searches
$youtubeChannelId = "UCQxOqOLPrgtWJAKJzOgR5uw" # Replace with your desired channel's ID
Expand Down Expand Up @@ -53,20 +53,20 @@ function Get-EpisodeOEmbed {
}

# Function to search YouTube for a video matching the episode title within a specific channel and return the video ID
function Get-YouTubeVideoId {
param (
[string]$searchQuery
)
$youtubeSearchApi = "https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&q=$($searchQuery -replace ' ', '+')&channelId=$youtubeChannelId&key=$youtubeApiKey&maxResults=1"
$youtubeResponse = Invoke-RestMethod -Method Get -Uri $youtubeSearchApi

if ($youtubeResponse.items.Count -gt 0) {
return $youtubeResponse.items[0].id.videoId
}
else {
return $null
}
}
# function Get-YouTubeVideoId {
# param (
# [string]$searchQuery
# )
# $youtubeSearchApi = "https://www.googleapis.com/youtube/v3/search?part=snippet&type=video&q=$($searchQuery -replace ' ', '+')&channelId=$youtubeChannelId&key=$youtubeApiKey&maxResults=1"
# $youtubeResponse = Invoke-RestMethod -Method Get -Uri $youtubeSearchApi

# if ($youtubeResponse.items.Count -gt 0) {
# return $youtubeResponse.items[0].id.videoId
# }
# else {
# return $null
# }
# }

# Augment episodes with oEmbed data and YouTube video ID
foreach ($episode in $episodes) {
Expand All @@ -79,11 +79,10 @@ foreach ($episode in $episodes) {
$episode | Add-Member -MemberType NoteProperty -Name "oembed_html" -Value $oEmbedData.html
$episode | Add-Member -MemberType NoteProperty -Name "oembed_url" -Value $oEmbedData.iframe_url

# Search YouTube using the episode's name and get the video ID
$youtubeVideoId = Get-YouTubeVideoId -searchQuery $episode.name

# Add the YouTube video ID dynamically
$episode | Add-Member -MemberType NoteProperty -Name "youtube_video_id" -Value $youtubeVideoId
## Search YouTube using the episode's name and get the video ID
#$youtubeVideoId = Get-YouTubeVideoId -searchQuery $episode.name
## Add the YouTube video ID dynamically
#$episode | Add-Member -MemberType NoteProperty -Name "youtube_video_id" -Value $youtubeVideoId
}

# Define the target directory and file path
Expand Down

0 comments on commit 661d4e4

Please sign in to comment.