Skip to content

Commit

Permalink
Merge pull request #56 from zaanposni/fix/ytlemon-to-official-api-mig…
Browse files Browse the repository at this point in the history
…ration

Fix/ytlemon to official api migration
  • Loading branch information
zaanposni authored Oct 27, 2024
2 parents 782801a + 84c01d9 commit 4323c0c
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ INSTAGRAM_2FA_SECRET=
TWITTER_USERNAME=
TWITTER_PASSWORD=
TWITTER_LIST_ID=

YOUTUBE_API_KEY=
1 change: 1 addition & 0 deletions docker-compose-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/dataimport/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ INSTAGRAM_2FA_SECRET=
TWITTER_USERNAME=
TWITTER_PASSWORD=
TWITTER_LIST_ID=

YOUTUBE_API_KEY=
16 changes: 9 additions & 7 deletions src/dataimport/youtube_video_linker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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']}'")
Expand Down
4 changes: 2 additions & 2 deletions src/psaggregator/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/psaggregator/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "psaggregator",
"version": "1.14.0",
"version": "1.14.1",
"scripts": {
"dev": "vite dev",
"build": "vite build",
Expand Down

0 comments on commit 4323c0c

Please sign in to comment.