@@ -3,7 +3,7 @@ import type { dbYouTube } from "../../types/database";
33import { pool } from "../database" ;
44import getSinglePlaylistAndReturnVideoId , {
55 PlaylistType ,
6- } from "../youtube/getSinglePlaylistAndReturnVideoId " ;
6+ } from "../youtube/getSinglePlaylistAndReturnVideoData " ;
77
88export async function dbYouTubeGetAllChannelsToTrack ( ) : Promise <
99 dbYouTube [ ] | [ ]
@@ -38,7 +38,8 @@ export async function checkIfChannelIsAlreadyTracked(
3838 } catch ( err ) {
3939 console . error ( "Error checking if channel is already tracked:" , err ) ;
4040
41- return false ;
41+ // Return true if there's an error as we don't want to add the channel if we can't check it
42+ return true ;
4243 }
4344}
4445
@@ -61,16 +62,19 @@ export async function addNewChannelToTrack(
6162 PlaylistType . Stream ,
6263 ) ;
6364
64- const query = `INSERT INTO youtube (youtube_channel_id, latest_video_id, latest_short_id, latest_stream_id) VALUES (?, ?, ?, ?)` ;
65+ const query = `INSERT INTO youtube (youtube_channel_id, latest_video_id_updated, latest_video_id, latest_short_id, latest_short_id_updated, latest_stream_id, latest_stream_id_updated ) VALUES (?, ?, ?, ?, ?, ?, ?)` ;
6566
6667 try {
6768 const client = await pool . connect ( ) ;
6869
6970 await client . query ( query , [
7071 channelId ,
71- longId || null ,
72- shortId || null ,
73- liveId || null ,
72+ longId ?. videoId || null ,
73+ longId ?. datePublished || null ,
74+ shortId ?. videoId || null ,
75+ shortId ?. datePublished || null ,
76+ liveId ?. videoId || null ,
77+ liveId ?. datePublished || null ,
7478 ] ) ;
7579
7680 return true ;
0 commit comments