ipman-youtube-music
Advanced tools
Comparing version 0.11.7 to 0.11.8
@@ -84,2 +84,3 @@ declare enum AccountType { | ||
durationStr: string; | ||
thumbnailUrl?: string; | ||
artist?: ArtistPreview; | ||
@@ -86,0 +87,0 @@ album?: AlbumPreview; |
@@ -1,1 +0,1 @@ | ||
"use strict";var q=Object.create;var b=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var r in t)b(e,r,{get:t[r],enumerable:!0})},v=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of te(t))!se.call(e,n)&&n!==r&&b(e,n,{get:()=>t[n],enumerable:!(s=ee(t,n))||s.enumerable});return e};var p=(e,t,r)=>(r=e!=null?q(re(e)):{},v(t||!e||!e.__esModule?b(r,"default",{value:e,enumerable:!0}):r,e)),ie=e=>v(b({},"__esModule",{value:!0}),e);var be={};ne(be,{AccountType:()=>w,AlbumType:()=>y,GetMusicVideoBasedSuggestions:()=>O,ListMusicVideosFromAlbum:()=>Q,ListMusicVideosFromPlaylist:()=>Y,PageType:()=>I,SearchForAlbum:()=>j,SearchForArtists:()=>N,SearchForMusicVideos:()=>X,SearchForPlaylists:()=>G,getArtist:()=>K,getPlaylist:()=>$});module.exports=ie(be);var w=(r=>(r.REGULAR="regular",r.VERIFIED_ARTIST="BADGE_STYLE_TYPE_VERIFIED_ARTIST",r))(w||{}),y=(s=>(s.ep="EP",s.album="Album",s.single="Single",s))(y||{}),I=(s=>(s.artist="MUSIC_PAGE_TYPE_ARTIST",s.album="MUSIC_PAGE_TYPE_ALBUM",s.playlist="MUSIC_PAGE_TYPE_PLAYLIST",s))(I||{});var U=p(require("got"));var R="MUSIC_EXPLICIT_BADGE",g=e=>{let t=e.split(":");return t.length===3?parseInt(t[0],10)*3600+parseInt(t[1],10)*60+parseInt(t[2],10):parseInt(t[0],10)*60+parseInt(t[1],10)},f=e=>{switch(e){case"Album":return"Album";case"EP":return"EP";default:return"Single"}},C=e=>{let t=[];if(e.forEach(r=>{r.navigationEndpoint&&r.navigationEndpoint.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ARTIST"&&t.push({name:r.text,id:r.navigationEndpoint.browseEndpoint.browseId})}),t.length===0){let r=e.findIndex(s=>s.text===" \u2022 ");r!==-1&&e.filter((s,n)=>n<r&&s.name!==" & ").forEach(s=>t.push({name:s.text}))}return t},E=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint?.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s;try{s=C(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs)}catch{}let n;try{let{length:u}=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs;n={name:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[u-3].text,id:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[u-3].navigationEndpoint.browseEndpoint?.browseId}}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{let u=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs.length-1].text;a={label:u,totalSeconds:g(u)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer.badges[0].musicInlineBadgeRenderer.icon.iconType===R}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},L=e=>{let t;try{t=e.playlistPanelVideoRenderer.navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.playlistPanelVideoRenderer.title.runs[0].text}catch{}let s;try{s=C(e.playlistPanelVideoRenderer.longBylineText.runs)}catch{}let n;try{n={name:e.playlistPanelVideoRenderer.longBylineText.runs[2].text}}catch{}let i;try{i=e.playlistPanelVideoRenderer.badges[0].musicInlineBadgeRenderer.icon.iconType==="MUSIC_EXPLICIT_BADGE"}catch{i=!1}let a;try{a=e.playlistPanelVideoRenderer.thumbnail.thumbnails.pop()?.url}catch{}let l;try{l={label:e.playlistPanelVideoRenderer.lengthText.runs[0].text,totalSeconds:g(e.playlistPanelVideoRenderer.lengthText.runs[0].text)}}catch{}return{youtubeId:t,title:r,artists:s,isExplicit:i,album:n,thumbnailUrl:a,duration:l}},A=(e,t)=>{let r;try{r=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch{}if(t&&e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text!=="YouTube Music")return null;let s;try{s=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let n;try{n=parseInt(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text.split(" ")[0],10)}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}return{playlistId:r,title:s,totalSongs:n,thumbnailUrl:i}},P=e=>{let t;try{t=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.buttons[1].musicPlayButtonRenderer?.playNavigationEndpoint.watchEndpoint.playlistId}catch{}let r;try{r=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.title.runs[0].text}catch{}let s;try{s=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.subtitle.runs[0].text}catch{}let n;try{n=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.subtitle.runs[2].text}catch{}let i;try{i=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{a=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.secondSubtitle.runs[2].text}catch{}let l=[];try{(e.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicShelfRenderer??e.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicPlaylistShelfRenderer)?.contents.forEach(o=>{let m={id:"",title:"",durationStr:"",artist:void 0,album:void 0};o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId&&(m.id=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId,m.title=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text,m.durationStr=o.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0].navigationEndpoint&&(m.artist={artistId:o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.browseEndpoint?.browseId,name:o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}),o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0].navigationEndpoint&&(m.album={albumId:o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.browseEndpoint?.browseId,title:o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}),l.push(m))})}catch(o){console.error(o)}let u;try{let o=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer;u={id:o.straplineTextOne?.runs[0].navigationEndpoint?.browseEndpoint.browseId,name:o.straplineTextOne?.runs[0].text??"YouTube Music",thumbnailUrl:o.straplineThumbnail?.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}}catch{}return{id:t,title:r,type:s,year:n,thumbnailUrl:i,durationStr:a,tracks:l,author:u}},T=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s;try{s=C(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs)}catch{}let n;try{n={name:e.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{a={label:e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,totalSeconds:g(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===R}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},S=e=>{let t;try{t=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch(o){console.error("Couldn't parse albumId",o)}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch(o){console.error("Couldn't parse title",o)}let s;try{s=f(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text)}catch(o){console.error("Couldn't parse album type",o)}let n;try{n=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(o){console.error("Couldn't parse thumbnailUrl",o)}let i;try{i=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text}catch(o){console.error("Couldn't parse artist",o)}let a;try{a=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].navigationEndpoint?.browseEndpoint.browseId}catch(o){console.error("Couldn't parse artistId",o)}let l;try{l=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[4].text}catch(o){console.error("Couldn't parse year",o)}let u;try{u=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===R}catch{u=!1}return{albumId:t,title:r,type:s,thumbnailUrl:n,artist:i,artistId:a,year:l,isExplicit:u}},F=e=>{let t;try{t=e.musicResponsiveHeaderRenderer.subtitle.runs[2].text}catch(n){console.error("Couldn't parse artist from album header",n)}let r;try{r=e.musicResponsiveHeaderRenderer.title.runs[0].text}catch(n){console.error("Couldn't parse title from album header",n)}let s;try{s=e.musicResponsiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(n){console.error("Couldn't parse thumbnailUrl from album header",n)}return{artist:t,album:r,thumbnailUrl:s}},M=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s=[];try{if(e.musicResponsiveListItemRenderer.flexColumns[1]?.musicResponsiveListItemFlexColumnRenderer.text.runs)for(let a=0;a<e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs.length;a+=2)s.push({name:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[a].text})}catch{}let n;try{n={label:e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,totalSeconds:g(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let i;try{i=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===R}catch{i=!1}return{youtubeId:t,artists:s,title:r,duration:n,isExplicit:i}},oe=e=>{let t;try{t=e.musicTwoRowItemRenderer.title.runs[0].text}catch(l){console.error("Couldn't get title",l)}let r;try{r=f(e.musicTwoRowItemRenderer.subtitle.runs[0].text)}catch(l){console.error("Couldn't get album type",l)}let s;try{s=e.musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(l){console.error("Couldn't get albumId",l)}let n;try{n=e.musicTwoRowItemRenderer.subtitle.runs.pop()?.text}catch(l){console.error("Couldn't get year",l)}let i;try{i=e.musicTwoRowItemRenderer.subtitleBadges[0].musicInlineBadgeRenderer.icon.iconType===R}catch{i=!1}let a;try{a=e.musicTwoRowItemRenderer.thumbnailRenderer.musicThumbnailRenderer.thumbnail.thumbnails.shift()?.url}catch(l){console.error("Couldn't get thumbnailUrl",l)}return{title:t,type:r,albumId:s,year:n,thumbnailUrl:a,isExplicit:i}},le=e=>{let t;try{t=e.musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(i){console.error("Couldn't get artistId",i)}let r;try{r=e.musicTwoRowItemRenderer.title.runs[0].text}catch(i){console.error("Couldn't get name",i)}let s;try{s=e.musicTwoRowItemRenderer.subtitle.runs[0].text;let i=s.split(" ");i.pop(),s=i.join(" ")}catch(i){console.error("Couldn't get subscribers",i)}let n;try{n=e.musicTwoRowItemRenderer.thumbnailRenderer.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(i){console.error("Couldn't get thumbnailUrl",i)}return{artistId:t,name:r,subscribers:s,thumbnailUrl:n}},B=(e,t)=>{let r;try{r=e.header.musicImmersiveHeaderRenderer.title.runs[0].text}catch(m){console.error("Couldn't get artist name",m)}let s;try{s=e.header.musicImmersiveHeaderRenderer.description.runs[0].text}catch(m){console.error("Couldn't get artist description",m)}let n=[];try{e.header.musicImmersiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.forEach(d=>{n.push(d)})}catch(m){console.error("Couldn't get artist thumbnails",m)}let i;try{i=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicShelfRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(m){console.error("Couldn't get artist songPlaylistId",m)}let a=[],l=[];try{let{contents:m}=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer;for(let d of m)d.musicCarouselShelfRenderer?.contents&&d.musicCarouselShelfRenderer.contents[0].musicTwoRowItemRenderer.title.runs[0].navigationEndpoint?.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ALBUM"&&d.musicCarouselShelfRenderer.contents.forEach(h=>{let x=oe(h);x.type==="Single"?l.push(x):a.push(x)})}catch(m){console.error("Couldn't get albums",m)}let u=[];try{let{contents:m}=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer;for(let d=m.length-1;d>=0;d-=1)if(m[d].musicCarouselShelfRenderer){m[d].musicCarouselShelfRenderer.contents[0].musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ARTIST"&&m[d].musicCarouselShelfRenderer.contents.forEach(h=>{u.push(le(h))});break}}catch(m){console.error("Couldn't get suggestedArtists",m)}let o;try{o=e.header.musicImmersiveHeaderRenderer.subscriptionButton.subscribeButtonRenderer.subscriberCountWithSubscribeText.runs[0].text}catch(m){console.error("Couldn't get subscribers",m)}return{artistId:t,name:r,description:s,albums:a,singles:l,thumbnails:n,songsPlaylistId:i,suggestedArtists:u,subscribers:o}},V=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch(i){console.error("Couldn't get name",i)}let r;try{r=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch(i){console.error("Couldn't get artistId",i)}let s;try{s=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(i){console.error("Couldn't get thumbnailUrl",i)}let n;try{n=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text}catch(i){console.error("Couldn't get subscribers",i)}return{name:t,artistId:r,thumbnailUrl:s,subscribers:n}};var c={body:{context:{client:{userAgent:"Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0,gzip(gfe)",clientName:"WEB_REMIX",clientVersion:"1.20241016.01.00",platform:"DESKTOP",browserName:"Firefox",browserVersion:"131.0",acceptHeader:"application/json"}}}};var ue=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=E(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function X(e){let t="https://music.youtube.com/youtubei/v1/search?alt=json",r={...c.body,params:"EgWKAQIIAWoKEAoQCRADEAQQBQ%3D%3D",query:e,originalQuery:e,searchMethod:"ENTER_KEY",validationStatus:"VALID"},n={method:"POST",headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",Origin:"https://music.youtube.com"},json:r,responseType:"json"};try{let i=await(0,U.default)(t,n);return ue(i.body)}catch(i){return console.error("Error fetching data:",i),[]}}var D=p(require("got"));var ae=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=V(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function N(e,t){try{let r=await D.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});return ae(JSON.parse(r.body))}catch(r){return console.error(r),[]}}var W=p(require("got"));var me=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=S(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function j(e){try{let t=await W.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIYAWoKEAkQAxAEEAUQCg%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return me(JSON.parse(t.body))}catch(t){return console.error(t),[]}}var _=p(require("got"));var ce=(e,t)=>{let r=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer?.contents;if(!r)return[];let s=[];return r.forEach(n=>{try{let i=A(n,t);i&&s.push(i)}catch(i){console.error(i)}}),s};async function G(e,t){let r=await _.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIoAWoKEAoQAxAEEAUQCQ%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});try{return ce(JSON.parse(r.body),t?.onlyOfficialPlaylists??!1)}catch(s){return console.error(s),[]}}var H=p(require("got"));var de=e=>{let{contents:t}=e.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0].tabRenderer.content.musicQueueRenderer.content.playlistPanelRenderer,r=[];return t.forEach(s=>{try{let n=L(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function O(e){let t=await H.default.post("https://music.youtube.com/youtubei/v1/next",{json:{...c.body,enablePersistentPlaylistPanel:!0,isAudioOnly:!0,params:"mgMDCNgE",playerParams:"igMDCNgE",tunerSettingValue:"AUTOMIX_SETTING_NORMAL",playlistId:`RDAMVM${e}`,videoId:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});try{return de(JSON.parse(t.body))}catch{return[]}}var z=p(require("got"));var pe=e=>{let{contents:t}=e.contents.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicShelfRenderer,r=[],{thumbnailUrl:s,artist:n,album:i}=F(e.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0]);return t.forEach(a=>{try{let l=M(a);l&&(l.album=i,l.artists?.length===0&&(l.artists=[{name:n}]),l.thumbnailUrl=s,r.push(l))}catch(l){console.error(l)}}),r};async function Q(e){try{let t=await z.default.post("https://music.youtube.com/youtubei/v1/browse",{json:{...c.body,browseId:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return pe(JSON.parse(t.body))}catch(t){return console.error(t),[]}}var k=p(require("got"));var Re=e=>{let t=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0],{contents:r}=t.musicPlaylistShelfRenderer??t.musicCarouselShelfRenderer,s=[];return r.forEach(n=>{try{let i=T(n);i&&s.push(i)}catch(i){console.error(i)}}),s};async function Y(e){let t;e.startsWith("VL")||(t="VL"+e);try{let r=await k.default.post("https://music.youtube.com/youtubei/v1/browse",{json:{...c.body,browseId:t},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return Re(JSON.parse(r.body))}catch(r){return console.error(`Error in listMusicsFromPlaylist: ${r}`),[]}}var J=p(require("got"));async function K(e,t){let r=await J.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{json:{...c.body,browseId:e},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});try{return B(JSON.parse(r.body),e)}catch(s){return console.error(s),{}}}var Z=p(require("got"));async function $(e,t){let r=await Z.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{json:{...c.body,browseId:e},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});try{let s=P(JSON.parse(r.body).contents);return s&&(s.id=e),s}catch(s){return console.error(s),null}}0&&(module.exports={AccountType,AlbumType,GetMusicVideoBasedSuggestions,ListMusicVideosFromAlbum,ListMusicVideosFromPlaylist,PageType,SearchForAlbum,SearchForArtists,SearchForMusicVideos,SearchForPlaylists,getArtist,getPlaylist}); | ||
"use strict";var q=Object.create;var R=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var r in t)R(e,r,{get:t[r],enumerable:!0})},v=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of te(t))!se.call(e,n)&&n!==r&&R(e,n,{get:()=>t[n],enumerable:!(s=ee(t,n))||s.enumerable});return e};var p=(e,t,r)=>(r=e!=null?q(re(e)):{},v(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),ie=e=>v(R({},"__esModule",{value:!0}),e);var Re={};ne(Re,{AccountType:()=>w,AlbumType:()=>y,GetMusicVideoBasedSuggestions:()=>O,ListMusicVideosFromAlbum:()=>Q,ListMusicVideosFromPlaylist:()=>Y,PageType:()=>I,SearchForAlbum:()=>j,SearchForArtists:()=>N,SearchForMusicVideos:()=>X,SearchForPlaylists:()=>G,getArtist:()=>K,getPlaylist:()=>$});module.exports=ie(Re);var w=(r=>(r.REGULAR="regular",r.VERIFIED_ARTIST="BADGE_STYLE_TYPE_VERIFIED_ARTIST",r))(w||{}),y=(s=>(s.ep="EP",s.album="Album",s.single="Single",s))(y||{}),I=(s=>(s.artist="MUSIC_PAGE_TYPE_ARTIST",s.album="MUSIC_PAGE_TYPE_ALBUM",s.playlist="MUSIC_PAGE_TYPE_PLAYLIST",s))(I||{});var U=p(require("got"));var b="MUSIC_EXPLICIT_BADGE",g=e=>{let t=e.split(":");return t.length===3?parseInt(t[0],10)*3600+parseInt(t[1],10)*60+parseInt(t[2],10):parseInt(t[0],10)*60+parseInt(t[1],10)},f=e=>{switch(e){case"Album":return"Album";case"EP":return"EP";default:return"Single"}},C=e=>{let t=[];if(e.forEach(r=>{r.navigationEndpoint&&r.navigationEndpoint.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ARTIST"&&t.push({name:r.text,id:r.navigationEndpoint.browseEndpoint.browseId})}),t.length===0){let r=e.findIndex(s=>s.text===" \u2022 ");r!==-1&&e.filter((s,n)=>n<r&&s.name!==" & ").forEach(s=>t.push({name:s.text}))}return t},E=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint?.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s;try{s=C(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs)}catch{}let n;try{let{length:u}=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs;n={name:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[u-3].text,id:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[u-3].navigationEndpoint.browseEndpoint?.browseId}}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{let u=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs.length-1].text;a={label:u,totalSeconds:g(u)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer.badges[0].musicInlineBadgeRenderer.icon.iconType===b}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},L=e=>{let t;try{t=e.playlistPanelVideoRenderer.navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.playlistPanelVideoRenderer.title.runs[0].text}catch{}let s;try{s=C(e.playlistPanelVideoRenderer.longBylineText.runs)}catch{}let n;try{n={name:e.playlistPanelVideoRenderer.longBylineText.runs[2].text}}catch{}let i;try{i=e.playlistPanelVideoRenderer.badges[0].musicInlineBadgeRenderer.icon.iconType==="MUSIC_EXPLICIT_BADGE"}catch{i=!1}let a;try{a=e.playlistPanelVideoRenderer.thumbnail.thumbnails.pop()?.url}catch{}let l;try{l={label:e.playlistPanelVideoRenderer.lengthText.runs[0].text,totalSeconds:g(e.playlistPanelVideoRenderer.lengthText.runs[0].text)}}catch{}return{youtubeId:t,title:r,artists:s,isExplicit:i,album:n,thumbnailUrl:a,duration:l}},A=(e,t)=>{let r;try{r=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch{}if(t&&e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text!=="YouTube Music")return null;let s;try{s=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let n;try{n=parseInt(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text.split(" ")[0],10)}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}return{playlistId:r,title:s,totalSongs:n,thumbnailUrl:i}},P=e=>{let t;try{t=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.buttons[1].musicPlayButtonRenderer?.playNavigationEndpoint.watchEndpoint.playlistId}catch{}let r;try{r=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.title.runs[0].text}catch{}let s;try{s=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.subtitle.runs[0].text}catch{}let n;try{n=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.subtitle.runs[2].text}catch{}let i;try{i=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{a=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer.secondSubtitle.runs[2].text}catch{}let l=[];try{(e.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicShelfRenderer??e.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicPlaylistShelfRenderer)?.contents.forEach(o=>{let m={id:"",title:"",durationStr:"",thumbnailUrl:"",artist:void 0,album:void 0};o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId&&(m.id=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId,m.title=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text,m.durationStr=o.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,m.thumbnailUrl=o.musicResponsiveListItemRenderer.thumbnail?.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url,o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0].navigationEndpoint&&(m.artist={artistId:o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.browseEndpoint?.browseId,name:o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}),o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0].navigationEndpoint&&(m.album={albumId:o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.browseEndpoint?.browseId,title:o.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}),l.push(m))})}catch(o){console.error(o)}let u;try{let o=e.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicResponsiveHeaderRenderer;u={id:o.straplineTextOne?.runs[0].navigationEndpoint?.browseEndpoint.browseId,name:o.straplineTextOne?.runs[0].text??"YouTube Music",thumbnailUrl:o.straplineThumbnail?.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}}catch{}return{id:t,title:r,type:s,year:n,thumbnailUrl:i,durationStr:a,tracks:l,author:u}},T=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s;try{s=C(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs)}catch{}let n;try{n={name:e.musicResponsiveListItemRenderer.flexColumns[2].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}}catch{}let i;try{i=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch{}let a;try{a={label:e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,totalSeconds:g(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===b}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},S=e=>{let t;try{t=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch(o){console.error("Couldn't parse albumId",o)}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch(o){console.error("Couldn't parse title",o)}let s;try{s=f(e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text)}catch(o){console.error("Couldn't parse album type",o)}let n;try{n=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(o){console.error("Couldn't parse thumbnailUrl",o)}let i;try{i=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text}catch(o){console.error("Couldn't parse artist",o)}let a;try{a=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].navigationEndpoint?.browseEndpoint.browseId}catch(o){console.error("Couldn't parse artistId",o)}let l;try{l=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[4].text}catch(o){console.error("Couldn't parse year",o)}let u;try{u=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===b}catch{u=!1}return{albumId:t,title:r,type:s,thumbnailUrl:n,artist:i,artistId:a,year:l,isExplicit:u}},F=e=>{let t;try{t=e.musicResponsiveHeaderRenderer.subtitle.runs[2].text}catch(n){console.error("Couldn't parse artist from album header",n)}let r;try{r=e.musicResponsiveHeaderRenderer.title.runs[0].text}catch(n){console.error("Couldn't parse title from album header",n)}let s;try{s=e.musicResponsiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(n){console.error("Couldn't parse thumbnailUrl from album header",n)}return{artist:t,album:r,thumbnailUrl:s}},M=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId}catch{}let r;try{r=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch{}let s=[];try{if(e.musicResponsiveListItemRenderer.flexColumns[1]?.musicResponsiveListItemFlexColumnRenderer.text.runs)for(let a=0;a<e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs.length;a+=2)s.push({name:e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[a].text})}catch{}let n;try{n={label:e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,totalSeconds:g(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let i;try{i=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===b}catch{i=!1}return{youtubeId:t,artists:s,title:r,duration:n,isExplicit:i}},oe=e=>{let t;try{t=e.musicTwoRowItemRenderer.title.runs[0].text}catch(l){console.error("Couldn't get title",l)}let r;try{r=f(e.musicTwoRowItemRenderer.subtitle.runs[0].text)}catch(l){console.error("Couldn't get album type",l)}let s;try{s=e.musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(l){console.error("Couldn't get albumId",l)}let n;try{n=e.musicTwoRowItemRenderer.subtitle.runs.pop()?.text}catch(l){console.error("Couldn't get year",l)}let i;try{i=e.musicTwoRowItemRenderer.subtitleBadges[0].musicInlineBadgeRenderer.icon.iconType===b}catch{i=!1}let a;try{a=e.musicTwoRowItemRenderer.thumbnailRenderer.musicThumbnailRenderer.thumbnail.thumbnails.shift()?.url}catch(l){console.error("Couldn't get thumbnailUrl",l)}return{title:t,type:r,albumId:s,year:n,thumbnailUrl:a,isExplicit:i}},le=e=>{let t;try{t=e.musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(i){console.error("Couldn't get artistId",i)}let r;try{r=e.musicTwoRowItemRenderer.title.runs[0].text}catch(i){console.error("Couldn't get name",i)}let s;try{s=e.musicTwoRowItemRenderer.subtitle.runs[0].text;let i=s.split(" ");i.pop(),s=i.join(" ")}catch(i){console.error("Couldn't get subscribers",i)}let n;try{n=e.musicTwoRowItemRenderer.thumbnailRenderer.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(i){console.error("Couldn't get thumbnailUrl",i)}return{artistId:t,name:r,subscribers:s,thumbnailUrl:n}},B=(e,t)=>{let r;try{r=e.header.musicImmersiveHeaderRenderer.title.runs[0].text}catch(m){console.error("Couldn't get artist name",m)}let s;try{s=e.header.musicImmersiveHeaderRenderer.description.runs[0].text}catch(m){console.error("Couldn't get artist description",m)}let n=[];try{e.header.musicImmersiveHeaderRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.forEach(d=>{n.push(d)})}catch(m){console.error("Couldn't get artist thumbnails",m)}let i;try{i=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicShelfRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseId}catch(m){console.error("Couldn't get artist songPlaylistId",m)}let a=[],l=[];try{let{contents:m}=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer;for(let d of m)d.musicCarouselShelfRenderer?.contents&&d.musicCarouselShelfRenderer.contents[0].musicTwoRowItemRenderer.title.runs[0].navigationEndpoint?.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ALBUM"&&d.musicCarouselShelfRenderer.contents.forEach(h=>{let x=oe(h);x.type==="Single"?l.push(x):a.push(x)})}catch(m){console.error("Couldn't get albums",m)}let u=[];try{let{contents:m}=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer;for(let d=m.length-1;d>=0;d-=1)if(m[d].musicCarouselShelfRenderer){m[d].musicCarouselShelfRenderer.contents[0].musicTwoRowItemRenderer.title.runs[0].navigationEndpoint.browseEndpoint.browseEndpointContextSupportedConfigs.browseEndpointContextMusicConfig.pageType==="MUSIC_PAGE_TYPE_ARTIST"&&m[d].musicCarouselShelfRenderer.contents.forEach(h=>{u.push(le(h))});break}}catch(m){console.error("Couldn't get suggestedArtists",m)}let o;try{o=e.header.musicImmersiveHeaderRenderer.subscriptionButton.subscribeButtonRenderer.subscriberCountWithSubscribeText.runs[0].text}catch(m){console.error("Couldn't get subscribers",m)}return{artistId:t,name:r,description:s,albums:a,singles:l,thumbnails:n,songsPlaylistId:i,suggestedArtists:u,subscribers:o}},V=e=>{let t;try{t=e.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text}catch(i){console.error("Couldn't get name",i)}let r;try{r=e.musicResponsiveListItemRenderer.navigationEndpoint.browseEndpoint.browseId}catch(i){console.error("Couldn't get artistId",i)}let s;try{s=e.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url}catch(i){console.error("Couldn't get thumbnailUrl",i)}let n;try{n=e.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs[2].text}catch(i){console.error("Couldn't get subscribers",i)}return{name:t,artistId:r,thumbnailUrl:s,subscribers:n}};var c={body:{context:{client:{userAgent:"Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0,gzip(gfe)",clientName:"WEB_REMIX",clientVersion:"1.20241016.01.00",platform:"DESKTOP",browserName:"Firefox",browserVersion:"131.0",acceptHeader:"application/json"}}}};var ue=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=E(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function X(e){let t="https://music.youtube.com/youtubei/v1/search?alt=json",r={...c.body,params:"EgWKAQIIAWoKEAoQCRADEAQQBQ%3D%3D",query:e,originalQuery:e,searchMethod:"ENTER_KEY",validationStatus:"VALID"},n={method:"POST",headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",Origin:"https://music.youtube.com"},json:r,responseType:"json"};try{let i=await(0,U.default)(t,n);return ue(i.body)}catch(i){return console.error("Error fetching data:",i),[]}}var D=p(require("got"));var ae=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=V(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function N(e,t){try{let r=await D.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});return ae(JSON.parse(r.body))}catch(r){return console.error(r),[]}}var W=p(require("got"));var me=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=S(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function j(e){try{let t=await W.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIYAWoKEAkQAxAEEAUQCg%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return me(JSON.parse(t.body))}catch(t){return console.error(t),[]}}var _=p(require("got"));var ce=(e,t)=>{let r=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer?.contents;if(!r)return[];let s=[];return r.forEach(n=>{try{let i=A(n,t);i&&s.push(i)}catch(i){console.error(i)}}),s};async function G(e,t){let r=await _.default.post("https://music.youtube.com/youtubei/v1/search",{json:{...c.body,params:"EgWKAQIoAWoKEAoQAxAEEAUQCQ%3D%3D",query:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});try{return ce(JSON.parse(r.body),t?.onlyOfficialPlaylists??!1)}catch(s){return console.error(s),[]}}var H=p(require("got"));var de=e=>{let{contents:t}=e.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0].tabRenderer.content.musicQueueRenderer.content.playlistPanelRenderer,r=[];return t.forEach(s=>{try{let n=L(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function O(e){let t=await H.default.post("https://music.youtube.com/youtubei/v1/next",{json:{...c.body,enablePersistentPlaylistPanel:!0,isAudioOnly:!0,params:"mgMDCNgE",playerParams:"igMDCNgE",tunerSettingValue:"AUTOMIX_SETTING_NORMAL",playlistId:`RDAMVM${e}`,videoId:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});try{return de(JSON.parse(t.body))}catch{return[]}}var z=p(require("got"));var pe=e=>{let{contents:t}=e.contents.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicShelfRenderer,r=[],{thumbnailUrl:s,artist:n,album:i}=F(e.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0]);return t.forEach(a=>{try{let l=M(a);l&&(l.album=i,l.artists?.length===0&&(l.artists=[{name:n}]),l.thumbnailUrl=s,r.push(l))}catch(l){console.error(l)}}),r};async function Q(e){try{let t=await z.default.post("https://music.youtube.com/youtubei/v1/browse",{json:{...c.body,browseId:e},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return pe(JSON.parse(t.body))}catch(t){return console.error(t),[]}}var k=p(require("got"));var be=e=>{let t=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0],{contents:r}=t.musicPlaylistShelfRenderer??t.musicCarouselShelfRenderer,s=[];return r.forEach(n=>{try{let i=T(n);i&&s.push(i)}catch(i){console.error(i)}}),s};async function Y(e){let t;e.startsWith("VL")||(t="VL"+e);try{let r=await k.default.post("https://music.youtube.com/youtubei/v1/browse",{json:{...c.body,browseId:t},searchParams:{alt:"json",key:"AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30"},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",origin:"https://music.youtube.com"}});return be(JSON.parse(r.body))}catch(r){return console.error(`Error in listMusicsFromPlaylist: ${r}`),[]}}var J=p(require("got"));async function K(e,t){let r=await J.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{json:{...c.body,browseId:e},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});try{return B(JSON.parse(r.body),e)}catch(s){return console.error(s),{}}}var Z=p(require("got"));async function $(e,t){let r=await Z.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{json:{...c.body,browseId:e},headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)","Accept-Language":t?.lang??"en",origin:"https://music.youtube.com"}});try{let s=P(JSON.parse(r.body).contents);return s&&(s.id=e),s}catch(s){return console.error(s),null}}0&&(module.exports={AccountType,AlbumType,GetMusicVideoBasedSuggestions,ListMusicVideosFromAlbum,ListMusicVideosFromPlaylist,PageType,SearchForAlbum,SearchForArtists,SearchForMusicVideos,SearchForPlaylists,getArtist,getPlaylist}); |
{ | ||
"name": "ipman-youtube-music", | ||
"description": "Unofficial YouTube Music API for Node.js", | ||
"version": "0.11.7", | ||
"version": "0.11.8", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "exports": "./dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62693
200