Need to figure out how to get the data for ytmusic playlists
This commit is contained in:
Binary file not shown.
@@ -17,13 +17,9 @@ declare namespace InnerTube {
|
|||||||
selected: boolean
|
selected: boolean
|
||||||
content: {
|
content: {
|
||||||
sectionListRenderer: {
|
sectionListRenderer: {
|
||||||
contents:
|
contents: {
|
||||||
| {
|
musicCarouselShelfRenderer: musicCarouselShelfRenderer
|
||||||
musicCarouselShelfRenderer: musicCarouselShelfRenderer
|
}[]
|
||||||
}[]
|
|
||||||
| {
|
|
||||||
musicDescriptionShelfRenderer: musicDescriptionShelfRenderer
|
|
||||||
}[]
|
|
||||||
continuations: [object]
|
continuations: [object]
|
||||||
trackingParams: string
|
trackingParams: string
|
||||||
header: {
|
header: {
|
||||||
@@ -77,7 +73,6 @@ declare namespace InnerTube {
|
|||||||
}
|
}
|
||||||
contents: {
|
contents: {
|
||||||
musicTwoRowItemRenderer?: musicTwoRowItemRenderer
|
musicTwoRowItemRenderer?: musicTwoRowItemRenderer
|
||||||
musicResponsiveListItemRenderer?: unknown
|
|
||||||
}[]
|
}[]
|
||||||
trackingParams: string
|
trackingParams: string
|
||||||
itemSize: string
|
itemSize: string
|
||||||
@@ -259,8 +254,26 @@ export class YouTubeMusic {
|
|||||||
console.log(response.status)
|
console.log(response.status)
|
||||||
const data: InnerTube.BrowseResponse = await response.json()
|
const data: InnerTube.BrowseResponse = await response.json()
|
||||||
const results = data.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents
|
const results = data.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents
|
||||||
const home: any[] = []
|
const home: { id: string; name: string }[] = []
|
||||||
home.push.apply(home, Parsers.parseMixedContent(results))
|
for (const result of results) {
|
||||||
|
const homeSection = result.musicCarouselShelfRenderer.contents
|
||||||
|
for (const item of homeSection) {
|
||||||
|
if (item.musicTwoRowItemRenderer?.navigationEndpoint) {
|
||||||
|
let id: string
|
||||||
|
const navigationEndpoint = item.musicTwoRowItemRenderer.navigationEndpoint
|
||||||
|
if ('browseEndpoint' in navigationEndpoint) {
|
||||||
|
id = navigationEndpoint.browseEndpoint.browseId
|
||||||
|
} else if ('watchEndpoint' in navigationEndpoint) {
|
||||||
|
id = navigationEndpoint.watchEndpoint.videoId
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
home.push({ id, name: item.musicTwoRowItemRenderer.title.runs[0].text })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(JSON.stringify(home))
|
||||||
|
|
||||||
// const sectionList = data.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer
|
// const sectionList = data.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer
|
||||||
// if ('continuations' in sectionList) {
|
// if ('continuations' in sectionList) {
|
||||||
|
|||||||
Reference in New Issue
Block a user