diff --git a/.env.example b/.env.example index 8947965..347f958 100644 --- a/.env.example +++ b/.env.example @@ -21,3 +21,5 @@ INSTAGRAM_2FA_SECRET= TWITTER_USERNAME= TWITTER_PASSWORD= TWITTER_LIST_ID= + +YOUTUBE_API_KEY= diff --git a/docker-compose-test.yml b/docker-compose-test.yml index b3a90d5..1a3108c 100644 --- a/docker-compose-test.yml +++ b/docker-compose-test.yml @@ -56,6 +56,7 @@ services: - TWITTER_USERNAME=${TWITTER_USERNAME} - TWITTER_PASSWORD=${TWITTER_PASSWORD} - TWITTER_LIST_ID=${TWITTER_LIST_ID} + - YOUTUBE_API_KEY=${YOUTUBE_API_KEY} volumes: - shared-data:/app/cdn - config:/app/config diff --git a/docker-compose.yml b/docker-compose.yml index db897d6..a961e59 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,6 +50,7 @@ services: - TWITTER_USERNAME=${TWITTER_USERNAME} - TWITTER_PASSWORD=${TWITTER_PASSWORD} - TWITTER_LIST_ID=${TWITTER_LIST_ID} + - YOUTUBE_API_KEY=${YOUTUBE_API_KEY} volumes: - shared-data:/app/cdn - config:/app/config diff --git a/src/dataimport/.env.example b/src/dataimport/.env.example index fcbd779..3f9e391 100644 --- a/src/dataimport/.env.example +++ b/src/dataimport/.env.example @@ -15,3 +15,5 @@ INSTAGRAM_2FA_SECRET= TWITTER_USERNAME= TWITTER_PASSWORD= TWITTER_LIST_ID= + +YOUTUBE_API_KEY= diff --git a/src/dataimport/youtube_video_linker.py b/src/dataimport/youtube_video_linker.py index 5ddd56b..34b3aeb 100644 --- a/src/dataimport/youtube_video_linker.py +++ b/src/dataimport/youtube_video_linker.py @@ -11,18 +11,18 @@ console = Console() -server_base_url = ( - os.getenv("YT_SERVER_BASE_URL") - if os.getenv("YT_SERVER_BASE_URL") - else "http://localhost:8080" -) +youtube_key = os.getenv("YOUTUBE_API_KEY") + +if not youtube_key: + raise Exception("YOUTUBE_API_KEY not set") + channel_ids = [ "UCqwGaUvq_l0RKszeHhZ5leA", # PietSmiet "UC3wla9xMoxDu7MIZImad1kQ", # PietSmietTV "UCYCQdW5rvpLA5Jd1nM6YxxA", # PietSmietLive "UC5yPQPrd8h6r3mGpbbbWVFg", # Best of PietSmiet ] -collection_url = "https://yt.lemnoslife.com/noKey/search?part=snippet&order=date&maxResults=50&channelId={}&type=video" +collection_url = "https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&maxResults=50&channelId={}&type=video&key={}" youtube_url_template = "https://youtu.be/{}" UPDATE_STATEMENT = "UPDATE ContentPiece SET description = :description, secondaryHref = :secondaryHref WHERE id = :id" @@ -54,7 +54,9 @@ async def youtube(): console.log("Fetching yt data...") for channel in channel_ids: console.log(f"Fetching yt data for {channel}") - yt_data = requests.get(collection_url.format(channel)).json()["items"] + yt_data = requests.get(collection_url.format(channel, youtube_key)).json()[ + "items" + ] for video in yt_data: console.log(f"Processing youtube video '{video['snippet']['title']}'") diff --git a/src/psaggregator/package-lock.json b/src/psaggregator/package-lock.json index e558efb..16355f5 100644 --- a/src/psaggregator/package-lock.json +++ b/src/psaggregator/package-lock.json @@ -1,12 +1,12 @@ { "name": "psaggregator", - "version": "1.14.0", + "version": "1.14.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "psaggregator", - "version": "1.14.0", + "version": "1.14.1", "dependencies": { "@internationalized/date": "^3.5.5", "bits-ui": "^0.21.13", diff --git a/src/psaggregator/package.json b/src/psaggregator/package.json index 06f9747..2082ec1 100644 --- a/src/psaggregator/package.json +++ b/src/psaggregator/package.json @@ -1,6 +1,6 @@ { "name": "psaggregator", - "version": "1.14.0", + "version": "1.14.1", "scripts": { "dev": "vite dev", "build": "vite build",