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

Commit

Permalink
Add checks for if a channel has been removed and when a channel has n…
Browse files Browse the repository at this point in the history
…o videos
  • Loading branch information
PrestonN committed Sep 12, 2020
1 parent 75f42ab commit 0525766
Show file tree
Hide file tree
Showing 3 changed files with 431 additions and 637 deletions.
10 changes: 9 additions & 1 deletion app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,17 @@ class YoutubeGrabberHelper {
const channelName = channelMetaData.title
const channelVideoData = response.data[1].response.contents.twoColumnBrowseResultsRenderer.tabs[1].tabRenderer.content.sectionListRenderer.contents[0].itemSectionRenderer.contents[0].gridRenderer

if (typeof (channelVideoData) === 'undefined') {
// Channel has no videos
return {
items: [],
continuation: null
}
}

let continuation = null

if (typeof (channelVideoData.continuations) !== 'undefined') {
if (typeof channelVideoData.continuations !== 'undefined') {
continuation = channelVideoData.continuations[0].nextContinuationData.continuation
}

Expand Down
5 changes: 5 additions & 0 deletions app/youtube-grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ class YoutubeGrabber {
}
}

if (typeof (channelPageResponse.data[1].response.alerts) !== 'undefined') {
const alert = channelPageResponse.data[1].response.alerts[0].alertRenderer.text.simpleText
return Promise.reject(alert)
}

const channelMetaData = channelPageResponse.data[1].response.metadata.channelMetadataRenderer
const channelHeaderData = channelPageResponse.data[1].response.header.c4TabbedHeaderRenderer
const channelContentsData = channelPageResponse.data[1].response.contents.twoColumnBrowseResultsRenderer
Expand Down
Loading

0 comments on commit 0525766

Please # to comment.