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

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkyProgrammer committed Sep 13, 2022
1 parent 6ec3fbf commit dde9ced
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 9 deletions.
5 changes: 5 additions & 0 deletions app/fetchers/playlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ class PlaylistFetcher {
if (typeof (channelPageDataResponse) === 'undefined') {
channelPageDataResponse = response.data[1].response
}
if (typeof (channelPageDataResponse.alerts) !== 'undefined') {
return {
alertMessage: channelPageDataResponse.alerts[0].alertRenderer.text.simpleText
}
}
let channelName
let channelMetaData
let channelId
Expand Down
5 changes: 5 additions & 0 deletions app/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ class YoutubeGrabberHelper {

// Parse the JSON data and get the relevent array with data
let contentDataJSON = JSON.parse(contentDataString)
if (typeof (contentDataJSON.alerts) !== 'undefined') {
return {
alertMessage: contentDataJSON.alerts[0].alertRenderer.text.simpleText
}
}
const communityTab = contentDataJSON.contents.twoColumnBrowseResultsRenderer.tabs.filter(e => {
return e.tabRenderer !== undefined && e.tabRenderer.title === 'Community'
})[0]
Expand Down
21 changes: 16 additions & 5 deletions app/youtube-grabber.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,11 @@ class YoutubeGrabber {
if (typeof channelPageDataResponse === 'undefined') {
channelPageDataResponse = channelPageResponse.data[1].response
}
if (typeof (channelPageDataResponse.alerts) !== 'undefined') {
return {
alertMessage: channelPageDataResponse.alerts[0].alertRenderer.text.simpleText
}
}
const channelMetaData = channelPageDataResponse.metadata.channelMetadataRenderer
const channelName = channelMetaData.title

Expand Down Expand Up @@ -466,12 +471,13 @@ class YoutubeGrabber {
const ytGrabHelp = YoutubeGrabberHelper.create(httpAgent)
const decideResponse = await ytGrabHelp.decideUrlRequestType(channelId, 'about?flow=grid&view=0&pbj=1', channelIdType)
const channelPageResponse = decideResponse.response
let headerTabs
if (channelPageResponse.data.response) {
headerTabs = channelPageResponse.data.response.contents.twoColumnBrowseResultsRenderer.tabs
} else {
headerTabs = channelPageResponse.data[1].response.contents.twoColumnBrowseResultsRenderer.tabs
const channelPageDataResponse = channelPageResponse.data[1].response
if (typeof (channelPageDataResponse.alerts) !== 'undefined') {
return {
alertMessage: channelPageDataResponse.alerts[0].alertRenderer.text.simpleText
}
}
const headerTabs = channelPageDataResponse.contents.twoColumnBrowseResultsRenderer.tabs
const aboutTab = headerTabs.filter((data) => {
if (typeof data.tabRenderer !== 'undefined') {
return data.tabRenderer.title === 'About'
Expand Down Expand Up @@ -512,6 +518,11 @@ class YoutubeGrabber {
if (typeof channelPageDataResponse === 'undefined') {
channelPageDataResponse = channelPageResponse.data[1].response
}
if (typeof (channelPageDataResponse.alerts) !== 'undefined') {
return {
alertMessage: channelPageDataResponse.alerts[0].alertRenderer.text.simpleText
}
}
const headerTabs = channelPageDataResponse.contents.twoColumnBrowseResultsRenderer.tabs
let channelName
let channelUrl
Expand Down
2 changes: 1 addition & 1 deletion test/channelHome.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('Getting channel home', () => {
})
test('Deleted channel', () => {
const parameters = { channelId: 'UC59AcfHD5jOGqTxb-zAsahw', channelIdType: 1 }
return ytch.getChannelVideos(parameters).then((data) => {
return ytch.getChannelHome(parameters).then((data) => {
expect(data.alertMessage).not.toBe(undefined)
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/channelPlaylists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('Playlists', () => {
})
test('Deleted channel', () => {
const parameters = { channelId: 'UC59AcfHD5jOGqTxb-zAsahw', channelIdType: 1 }
return ytch.getChannelVideos(parameters).then((data) => {
return ytch.getChannelPlaylistInfo(parameters).then((data) => {
expect(data.alertMessage).not.toBe(undefined)
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/channelStats.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('Channel stats', () => {
})
test('Deleted channel', () => {
const parameters = { channelId: 'UC59AcfHD5jOGqTxb-zAsahw', channelIdType: 1 }
return ytch.getChannelVideos(parameters).then((data) => {
return ytch.getChannelStats(parameters).then((data) => {
expect(data.alertMessage).not.toBe(undefined)
})
})
Expand Down
2 changes: 1 addition & 1 deletion test/communityPosts.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Community Posts', () => {
})
test('Deleted channel', () => {
const parameters = { channelId: 'UC59AcfHD5jOGqTxb-zAsahw', channelIdType: 1 }
return ytch.getChannelVideos(parameters).then((data) => {
return ytch.getChannelCommunityPosts(parameters).then((data) => {
expect(data.alertMessage).not.toBe(undefined)
})
})
Expand Down

0 comments on commit dde9ced

Please sign in to comment.