node-youtube-music
Advanced tools
Comparing version 0.1.8 to 0.2.0
@@ -1,2 +0,2 @@ | ||
import ytMusic from 'node-youtube-music'; | ||
import ytMusic from '../src'; | ||
@@ -3,0 +3,0 @@ const main = () => ytMusic.search('Deadmau5', { lang: 'fr', country: 'FR' }); |
{ | ||
"name": "node-youtube-music", | ||
"description": "Unofficial YouTube Music API for Node.js", | ||
"version": "0.1.8", | ||
"version": "0.2.0", | ||
"main": "dist/src/index.js", | ||
@@ -24,2 +24,3 @@ "types": "dist/src/index.d.ts", | ||
"start:example:search": "yarn build && node dist/examples/search", | ||
"start:example:suggestions": "yarn build && node dist/examples/getSuggestions", | ||
"build": "eslint src/**/* examples/**/* && tsc", | ||
@@ -26,0 +27,0 @@ "test": "yarn build && jest" |
@@ -47,4 +47,3 @@ export default { | ||
}, | ||
params: 'EgWKAQIIAWoKEAoQCRADEAQQBQ%3D%3D', | ||
}), | ||
}; |
import search from './search'; | ||
import getSuggestions from './suggestions'; | ||
export default { | ||
search, | ||
getSuggestions, | ||
}; |
@@ -65,1 +65,33 @@ import { MusicVideo } from './models'; | ||
}; | ||
export const parseSuggestion = (content: { | ||
playlistPanelVideoRenderer: { | ||
navigationEndpoint: { watchEndpoint: { videoId: string } }; | ||
title: { runs: { text: string }[] }; | ||
longBylineText: { runs: { text: string }[] }; | ||
thumbnail: { thumbnails: { url: string }[] }; | ||
lengthText: { runs: { text: string }[] }; | ||
}; | ||
}): MusicVideo | null => { | ||
if ( | ||
!content.playlistPanelVideoRenderer.navigationEndpoint.watchEndpoint.videoId | ||
) { | ||
return null; | ||
} | ||
return { | ||
youtubeId: | ||
content.playlistPanelVideoRenderer.navigationEndpoint.watchEndpoint | ||
.videoId, | ||
title: content.playlistPanelVideoRenderer.title.runs[0].text, | ||
artist: content.playlistPanelVideoRenderer.longBylineText.runs[0].text, | ||
album: content.playlistPanelVideoRenderer.longBylineText.runs[2].text, | ||
thumbnailUrl: content.playlistPanelVideoRenderer.thumbnail.thumbnails.pop() | ||
?.url, | ||
duration: { | ||
label: content.playlistPanelVideoRenderer.lengthText.runs[0].text, | ||
totalSeconds: parseDuration( | ||
content.playlistPanelVideoRenderer.lengthText.runs[0].text | ||
), | ||
}, | ||
}; | ||
}; |
@@ -18,2 +18,3 @@ import got from 'got'; | ||
...context.body(options?.lang, options?.country), | ||
params: 'EgWKAQIIAWoKEAoQCRADEAQQBQ%3D%3D', | ||
query, | ||
@@ -20,0 +21,0 @@ }, |
Sorry, the diff of this file is not supported yet
13201
17
369