Skip to content

Commit

Permalink
Podcast Import Script: Re-enable YouTube API
Browse files Browse the repository at this point in the history
  • Loading branch information
andygrunwald committed Dec 12, 2023
1 parent 35bda0e commit 7f1ece8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/publish-podcast-episodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
env:
SPOTIFY_APP_CLIENT_ID: ${{ secrets.SPOTIFY_APP_CLIENT_ID }}
SPOTIFY_APP_CLIENT_SECRET: ${{ secrets.SPOTIFY_APP_CLIENT_SECRET }}
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}

- name: Run make update-redirects
run: make update-redirects
Expand Down
21 changes: 10 additions & 11 deletions scripts/podcast_feed_to_content.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ def sync_podcast_episodes(rss_feed, path_md_files, path_img_files, no_api_calls=
feed_response.encoding = 'utf-8'

# Check if we should run the API calls to external podcast platforms
#apple_podcast_content = {"results": []}
apple_podcast_content = {}
spotify_episodes = []
google_podcast_content = ""
Expand All @@ -225,8 +224,8 @@ def sync_podcast_episodes(rss_feed, path_md_files, path_img_files, no_api_calls=
apple_podcast_content = get_json_content_from_url(PODCAST_APPLE_URL)
spotify_episodes = spotify_client.show_episodes(SPOTIFY_SHOW_ID, limit=50, offset=0, market="DE")
google_podcast_content = get_raw_content_from_url(PODCAST_GOOGLE_URL)
#youtube_playlist_response = youtube_client.playlistItems.list(parts="snippet", maxResults=50, playlist_id=YOUTUBE_PLAYLIST_ID)
#youtube_playlist_items = youtube_playlist_response.items
youtube_playlist_response = youtube_client.playlistItems.list(parts="snippet", maxResults=50, playlist_id=YOUTUBE_PLAYLIST_ID)
youtube_playlist_items = youtube_playlist_response.items

# Pagination and auth not respected.
# Right now it works, because a) we don't make that much requests and
Expand Down Expand Up @@ -709,13 +708,13 @@ def get_episode_link_from_google(content, title: str) -> str:
spotify_client = create_spotify_client(SPOTIFY_APP_CLIENT_ID, SPOTIFY_APP_CLIENT_SECRET)

# YouTube
#YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY')
#if not YOUTUBE_API_KEY:
# logging.error("Env var YOUTUBE_API_KEY is not set properly.")
# logging.error("Please double check and restart.")
# sys.exit(1)
#youtube_client = YoutubeClient(api_key=YOUTUBE_API_KEY)

sync_podcast_episodes(PODCAST_RSS_FEED, f"{folder_prefix}{PATH_MARKDOWN_FILES}", f"{folder_prefix}{PATH_IMAGE_FILES}", no_api_calls=args.no_api_calls, spotify_client=spotify_client, youtube_client=None)
YOUTUBE_API_KEY = os.getenv('YOUTUBE_API_KEY')
if not YOUTUBE_API_KEY:
logging.error("Env var YOUTUBE_API_KEY is not set properly.")
logging.error("Please double check and restart.")
sys.exit(1)
youtube_client = YoutubeClient(api_key=YOUTUBE_API_KEY)

sync_podcast_episodes(PODCAST_RSS_FEED, f"{folder_prefix}{PATH_MARKDOWN_FILES}", f"{folder_prefix}{PATH_IMAGE_FILES}", no_api_calls=args.no_api_calls, spotify_client=spotify_client, youtube_client=youtube_client)
case "redirect":
create_redirects(TOML_FILE, PATH_MARKDOWN_FILES, REDIRECT_PREFIX)

0 comments on commit 7f1ece8

Please sign in to comment.