diff --git a/app/helper.js b/app/helper.js index 2be5bcc..6ce5fa5 100644 --- a/app/helper.js +++ b/app/helper.js @@ -189,7 +189,7 @@ class YoutubeGrabberHelper { if (typeof (obj.richItemRenderer) !== 'undefined') { video = obj.richItemRenderer.content.videoRenderer video.lengthSeconds = video.lengthText.simpleText.split(':').reduce((acc, time) => (60 * acc) + +time) - video.title.simpleText = video.title.runs.at(0) + video.title.simpleText = video.title.runs.at(0).text } else if (typeof (obj.reelItemRenderer) !== 'undefined') { video = obj.reelItemRenderer video.title = video.headline diff --git a/app/youtube-grabber.js b/app/youtube-grabber.js index c28fb47..81f25a4 100644 --- a/app/youtube-grabber.js +++ b/app/youtube-grabber.js @@ -247,13 +247,24 @@ class YoutubeGrabber { nextContinuation = continuationItem[0].continuationItemRenderer.continuationEndpoint.continuationCommand.token } - const channelMetaData = channelPageResponse.data.metadata.channelMetadataRenderer - const channelName = channelMetaData.title - const channelId = channelMetaData.externalId + const channelMetaData = channelPageResponse.data?.metadata?.channelMetadataRenderer + let channelInfo = {} + if (channelMetaData) { + const channelName = channelMetaData.title + const channelId = channelMetaData.externalId + + channelInfo = { + channelId, + channelName + } + } else { + const firstVideoTitle = continuationData[0].richItemRenderer.content.videoRenderer.title + const firstPublishTimeText = continuationData[0].richItemRenderer.content.videoRenderer.publishedTimeText - const channelInfo = { - channelId: channelId, - channelName: channelName + channelInfo = { + channelId: channelPageResponse.data.responseContext.serviceTrackingParams.find((service) => service.service === 'GOOGLE_HELP').params[0].value, + channelName: new RegExp(`${firstVideoTitle.runs[0].text} by (.*?) ${firstPublishTimeText.simpleText}`, 'g').exec(firstVideoTitle.accessibility.accessibilityData.label)[1] + } } const nextVideos = continuationData.filter((item) => {