diff --git a/CHANGELOG.md b/CHANGELOG.md index f483095..5c6e1f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## [3.0.2] 2025-01-03 + +### Fixes +- Fix writing headers after sending response in authentication server. +- Gracefully handle channel page giving 404 (instead of killing the process) (#22). + ## [3.0.1] 2024-12-31 ### Fixes diff --git a/package-lock.json b/package-lock.json index f5ed46b..c63ed44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bbyen", - "version": "3.0.1", + "version": "3.0.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bbyen", - "version": "3.0.1", + "version": "3.0.2", "license": "MIT", "dependencies": { "@babel/core": "7.26.0", diff --git a/package.json b/package.json index de8569c..2d27080 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bbyen", - "version": "3.0.1", + "version": "3.0.2", "description": "Bring Back YouTube Email Notifications!", "main": "src/index.js", "scripts": { diff --git a/src/google/auth/index.ts b/src/google/auth/index.ts index 2327d6b..1578c53 100644 --- a/src/google/auth/index.ts +++ b/src/google/auth/index.ts @@ -74,13 +74,12 @@ const genAuthToken = async (oauth2Client: OAuth2Client) => { try { logger.info('Creating tokens from code') const { tokens } = await oauth2Client.getToken(code) - res.end('Authorization successful. You may now close this tab.') res.writeHead(200) + .end('Authorization successful. You may now close this tab.') resolve(tokens) } catch (err) { console.error(err) - res.end(`Authorization failed. ${err}`) - res.writeHead(500) + res.writeHead(500).end(`Authorization failed. ${err}`) reject(err) } server.close() diff --git a/src/videos.ts b/src/videos.ts index 99dbafe..2fe39d5 100644 --- a/src/videos.ts +++ b/src/videos.ts @@ -55,17 +55,19 @@ const getChannelsVideos = async ({ auth, sendVideoEmail, db, -}: IGetChannelsVideos): boolean => { - const { channelId, channelTitle, channelThumbnail } = channel +}: IGetChannelsVideos): Promise => { + const { channelId, channelThumbnail } = channel const videosSent = new Set((await db.all(SQL` SELECT videoId FROM videos WHERE channelId=${channelId}; `)).map(v => v.videoId)) - const feed = await parser.parseURL([ - 'https://www.youtube.com/feeds/videos.xml', - '?channel_id=', channelId, - ].join('')) + const url = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}` + const feed = await parser.parseURL(url) + .catch((err) => { + logger.warn(`Error parsing videos from '${url}': ${err.message}`) + return { items: [] } + }) for (let { videoId } of feed.items) { try {