cli/videos-update/index.js
/**
 * Fetch and format details for each provided video
 * @param unfilledVideos - list of videos to fetch details for
 * @param serviceSlug
 * @returns {Promise<unknown>}
 */
Fetch and format details for each provided video
@param unfilledVideos - list of videos to fetch details for
@param serviceSlug
@returns {Promise}
Fetch and format details for each provided video @param unfilledVideos - list of videos to fetch details for @param serviceSlug @returns { Promise }
async function fetchVideosDetails (unfilledVideos, serviceSlug) {
  return async.map(unfilledVideos, async (video, callback) => {
    if (!video.videoId) {
      console.log(chalk.red(`Missing videoId in service ${serviceSlug}. Skipping video:`, video))
      return callback()
    }
    try {
      const videoDetails = await YoutubeClient.getVideoDetails(video.videoId)
      if (!videoDetails) {
        reportVideoNotFound()
        return callback()
      }
      callback(null, {
        service: serviceSlug,
        videoId: videoDetails.videoId,
        tags: videoDetails.tags,
        title: videoDetails.title,
        description: videoDetails.description,
        date: videoDetails.publishedAt,
        duration: youtubeDurationToSeconds(videoDetails.duration)
      })
    } catch (err) {
      reportVideoNotFound()
      callback(err)
    }
    function reportVideoNotFound () {
      console.log(chalk.red(`Unable to load video details. Video is private or doesn't exist. Skipping`), video.videoId)
    }
  })
}
async function fetchVideosDetails ( unfilledVideos , serviceSlug ) { return async . map ( unfilledVideos , async ( video , callback ) => { if ( ! video . videoId ) { console . log ( chalk . red ( ` ${ serviceSlug } ` , video ) ) return callback ( ) } try { const videoDetails = await YoutubeClient . getVideoDetails ( video . videoId ) if ( ! videoDetails ) { reportVideoNotFound ( ) return callback ( ) } callback ( null , { service : serviceSlug , videoId : videoDetails . videoId , tags : videoDetails . tags , title : videoDetails . title , description : videoDetails . description , date : videoDetails . publishedAt , duration : youtubeDurationToSeconds ( videoDetails . duration ) } ) } catch ( err ) { reportVideoNotFound ( ) callback ( err ) } function reportVideoNotFound ( ) { console . log ( chalk . red ( ` ` ) , video . videoId ) } } ) }
Fetch and format details for each provided video
 @param unfilledVideos - list of videos to fetch details for
 @param serviceSlug
 @returns {Promise<unknown>}
Fetch and format details for each provided video @param unfilledVideos - list of videos to fetch details for @param serviceSlug @returns { Promise<unknown > }