Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

Adjust parsing of channel page continuation #115

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 17 additions & 6 deletions app/youtube-grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down