ipman-youtube-music
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -55,2 +55,3 @@ declare enum AccountType { | ||
songsPlaylistId?: string; | ||
songs?: MusicVideoPlayable[]; | ||
albums?: AlbumPreview[]; | ||
@@ -57,0 +58,0 @@ singles?: AlbumPreview[]; |
@@ -1,1 +0,1 @@ | ||
"use strict";var re=Object.create;var R=Object.defineProperty;var se=Object.getOwnPropertyDescriptor;var ne=Object.getOwnPropertyNames;var ie=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var le=(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 ne(t))!oe.call(e,n)&&n!==r&&R(e,n,{get:()=>t[n],enumerable:!(s=se(t,n))||s.enumerable});return e};var p=(e,t,r)=>(r=e!=null?re(ie(e)):{},v(t||!e||!e.__esModule?R(r,"default",{value:e,enumerable:!0}):r,e)),ue=e=>v(R({},"__esModule",{value:!0}),e);var xe={};le(xe,{AccountType:()=>w,AlbumType:()=>y,GetMusicVideoBasedSuggestions:()=>Q,ListMusicVideosFromAlbum:()=>j,ListMusicVideosFromPlaylist:()=>K,PageType:()=>I,SearchForAlbum:()=>G,SearchForArtists:()=>_,SearchForMusicVideos:()=>D,SearchForPlaylists:()=>k,getArtist:()=>Z,getPlaylist:()=>q,getVideo:()=>te});module.exports=ue(xe);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 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}},M=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}},F=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}},ae=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}},me=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=>{let{videoDetails:t}=e;return{id:t.videoId,title:t.title,duration:parseInt(t.lengthSeconds,10),artist:{name:t.author,id:t.channelId},thumbnailUrl:t.thumbnail.thumbnails.pop()?.url,type:t.musicVideoType}},V=(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=e.header.musicImmersiveHeaderRenderer?.description?.runs?.[0]?.text??"",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=ae(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(me(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}},U=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 X=p(require("axios")),ce=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 D(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"};try{let s=await X.default.post(t,r,{headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",Origin:"https://music.youtube.com"}});return ce(s.data)}catch(s){return console.error("Error fetching data:",s),[]}}var W=p(require("axios"));var de=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=U(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function _(e,t){try{let r=await W.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",query:e},{params:{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 de(r.data)}catch(r){return console.error(r),[]}}var N=p(require("axios"));var pe=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 G(e){try{let t=await N.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIYAWoKEAkQAxAEEAUQCg%3D%3D",query:e},{params:{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(t.data)}catch(t){return console.error(t),[]}}var H=p(require("axios"));var be=(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 k(e,t){let r=await H.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIoAWoKEAoQAxAEEAUQCQ%3D%3D",query:e},{params:{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 be(r.data,t?.onlyOfficialPlaylists??!1)}catch(s){return console.error(s),[]}}var z=p(require("axios")),Re=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 Q(e){let t=await z.default.post("https://music.youtube.com/youtubei/v1/next",{...c.body,enablePersistentPlaylistPanel:!0,isAudioOnly:!0,params:"mgMDCNgE",playerParams:"igMDCNgE",tunerSettingValue:"AUTOMIX_SETTING_NORMAL",playlistId:`RDAMVM${e}`,videoId:e},{params:{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 Re(t.data)}catch{return[]}}var Y=p(require("axios")),ge=e=>{let{contents:t}=e.contents.twoColumnBrowseResultsRenderer.secondaryContents.sectionListRenderer.contents[0].musicShelfRenderer,r=[],{thumbnailUrl:s,artist:n,album:i}=M(e.contents.twoColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0]);return t.forEach(a=>{try{let l=F(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 j(e){try{let t=await Y.default.post("https://music.youtube.com/youtubei/v1/browse",{...c.body,browseId:e},{params:{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 ge(t.data)}catch(t){return console.error(t),[]}}var O=p(require("axios"));var he=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 K(e){let t;e.startsWith("VL")||(t="VL"+e);try{let r=await O.default.post("https://music.youtube.com/youtubei/v1/browse",{...c.body,browseId:t},{params:{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 he(r.data)}catch(r){return console.error(`Error in listMusicsFromPlaylist: ${r}`),[]}}var J=p(require("axios"));async function Z(e,t){let r=await J.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{...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 V(r.data,e)}catch(s){return console.error(s),{}}}var $=p(require("axios"));async function q(e,t){let r=await $.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{...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(r.data.contents);return s&&(s.id=e),s}catch(s){return console.error(s),null}}var ee=p(require("axios"));async function te(e,t){let r=await ee.default.post("https://music.youtube.com/youtubei/v1/player",{...c.body,playbackContext:{contentPlaybackContext:{autoCaptionsDefaultOn:!1,html5Preference:"HTML5_PREF_WANTS",lactMilliseconds:"411",mdxContext:{},referer:"https://music.youtube.com/",signatureTimestamp:20024,vis:10}},videoId: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(r.data)}catch(s){return console.error(s),{}}}0&&(module.exports={AccountType,AlbumType,GetMusicVideoBasedSuggestions,ListMusicVideosFromAlbum,ListMusicVideosFromPlaylist,PageType,SearchForAlbum,SearchForArtists,SearchForMusicVideos,SearchForPlaylists,getArtist,getPlaylist,getVideo}); | ||
"use strict";var se=Object.create;var h=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,le=Object.prototype.hasOwnProperty;var ue=(e,t)=>{for(var r in t)h(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ie(t))!le.call(e,n)&&n!==r&&h(e,n,{get:()=>t[n],enumerable:!(s=ne(t,n))||s.enumerable});return e};var b=(e,t,r)=>(r=e!=null?se(oe(e)):{},w(t||!e||!e.__esModule?h(r,"default",{value:e,enumerable:!0}):r,e)),ae=e=>w(h({},"__esModule",{value:!0}),e);var ye={};ue(ye,{AccountType:()=>f,AlbumType:()=>I,GetMusicVideoBasedSuggestions:()=>Y,ListMusicVideosFromAlbum:()=>O,ListMusicVideosFromPlaylist:()=>J,PageType:()=>v,SearchForAlbum:()=>G,SearchForArtists:()=>k,SearchForMusicVideos:()=>W,SearchForPlaylists:()=>z,getArtist:()=>$,getPlaylist:()=>ee,getVideo:()=>re});module.exports=ae(ye);var f=(r=>(r.REGULAR="regular",r.VERIFIED_ARTIST="BADGE_STYLE_TYPE_VERIFIED_ARTIST",r))(f||{}),I=(s=>(s.ep="EP",s.album="Album",s.single="Single",s))(I||{}),v=(s=>(s.artist="MUSIC_PAGE_TYPE_ARTIST",s.album="MUSIC_PAGE_TYPE_ALBUM",s.playlist="MUSIC_PAGE_TYPE_PLAYLIST",s))(v||{});var g="MUSIC_EXPLICIT_BADGE",x=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)},L=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:x(u)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer.badges[0].musicInlineBadgeRenderer.icon.iconType===g}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},A=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:x(e.playlistPanelVideoRenderer.lengthText.runs[0].text)}}catch{}return{youtubeId:t,title:r,artists:s,isExplicit:i,album:n,thumbnailUrl:a,duration:l}},P=(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}},T=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 p={id:"",title:"",durationStr:"",thumbnailUrl:"",artist:void 0,album:void 0};o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId&&(p.id=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint?.watchEndpoint?.videoId,p.title=o.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text,p.durationStr=o.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text,p.thumbnailUrl=o.musicResponsiveListItemRenderer.thumbnail?.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url,o.musicResponsiveListItemRenderer.flexColumns[1].musicResponsiveListItemFlexColumnRenderer.text.runs?.[0].navigationEndpoint&&(p.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&&(p.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(p))})}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}},S=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:x(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let l;try{l=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===g}catch{l=!1}return{youtubeId:t,title:r,artists:s,album:n,thumbnailUrl:i,duration:a,isExplicit:l}},M=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=L(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===g}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}},B=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:x(e.musicResponsiveListItemRenderer.fixedColumns[0].musicResponsiveListItemFixedColumnRenderer.text.runs[0].text)}}catch{}let i;try{i=e.musicResponsiveListItemRenderer?.badges[0].musicInlineBadgeRenderer.icon.iconType===g}catch{i=!1}return{youtubeId:t,artists:s,title:r,duration:n,isExplicit:i}},me=e=>{let t;try{t=e.musicTwoRowItemRenderer.title.runs[0].text}catch(l){console.error("Couldn't get title",l)}let r;try{r=L(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===g}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}},ce=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}},V=e=>{let{videoDetails:t}=e;return{id:t.videoId,title:t.title,duration:parseInt(t.lengthSeconds,10),artist:{name:t.author,id:t.channelId},thumbnailUrl:t.thumbnail.thumbnails.pop()?.url,type:t.musicVideoType}},U=(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=e.header.musicImmersiveHeaderRenderer?.description?.runs?.[0]?.text??"",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=[];try{let{contents:m}=e.contents.singleColumnBrowseResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents[0].musicShelfRenderer;for(let d of m)try{a.push({id:d.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.watchEndpoint.videoId,title:d.musicResponsiveListItemRenderer.flexColumns[0].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text,thumbnailUrl:d.musicResponsiveListItemRenderer.thumbnail.musicThumbnailRenderer.thumbnail.thumbnails.pop()?.url,artist:{name:r,id:t},album:{name:d.musicResponsiveListItemRenderer.flexColumns[3].musicResponsiveListItemFlexColumnRenderer.text.runs[0].text,id:d.musicResponsiveListItemRenderer.flexColumns[3].musicResponsiveListItemFlexColumnRenderer.text.runs[0].navigationEndpoint.browseEndpoint.browseId},type:"song",duration:0})}catch(R){console.log("Skipping track",R)}}catch(m){console.error("Couldn't get tracks",m)}let l=[],u=[];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(R=>{let y=me(R);y.type==="Single"?u.push(y):l.push(y)})}catch(m){console.error("Couldn't get albums",m)}let o=[];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(R=>{o.push(ce(R))});break}}catch(m){console.error("Couldn't get suggestedArtists",m)}let p;try{p=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:l,singles:u,thumbnails:n,songsPlaylistId:i,suggestedArtists:o,subscribers:p,songs:a}},X=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 D=b(require("axios")),de=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 W(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"};try{let s=await D.default.post(t,r,{headers:{"User-Agent":"Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)",Origin:"https://music.youtube.com"}});return de(s.data)}catch(s){return console.error("Error fetching data:",s),[]}}var _=b(require("axios"));var pe=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=X(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function k(e,t){try{let r=await _.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIgAWoKEAMQBBAJEAoQBQ%3D%3D",query:e},{params:{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 pe(r.data)}catch(r){return console.error(r),[]}}var N=b(require("axios"));var be=e=>{let{contents:t}=e.contents.tabbedSearchResultsRenderer.tabs[0].tabRenderer.content.sectionListRenderer.contents.pop().musicShelfRenderer,r=[];return t.forEach(s=>{try{let n=M(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function G(e){try{let t=await N.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIYAWoKEAkQAxAEEAUQCg%3D%3D",query:e},{params:{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(t.data)}catch(t){return console.error(t),[]}}var H=b(require("axios"));var Re=(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=P(n,t);i&&s.push(i)}catch(i){console.error(i)}}),s};async function z(e,t){let r=await H.default.post("https://music.youtube.com/youtubei/v1/search",{...c.body,params:"EgWKAQIoAWoKEAoQAxAEEAUQCQ%3D%3D",query:e},{params:{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 Re(r.data,t?.onlyOfficialPlaylists??!1)}catch(s){return console.error(s),[]}}var Q=b(require("axios")),ge=e=>{let{contents:t}=e.contents.singleColumnMusicWatchNextResultsRenderer.tabbedRenderer.watchNextTabbedResultsRenderer.tabs[0].tabRenderer.content.musicQueueRenderer.content.playlistPanelRenderer,r=[];return t.forEach(s=>{try{let n=A(s);n&&r.push(n)}catch(n){console.error(n)}}),r};async function Y(e){let t=await Q.default.post("https://music.youtube.com/youtubei/v1/next",{...c.body,enablePersistentPlaylistPanel:!0,isAudioOnly:!0,params:"mgMDCNgE",playerParams:"igMDCNgE",tunerSettingValue:"AUTOMIX_SETTING_NORMAL",playlistId:`RDAMVM${e}`,videoId:e},{params:{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 ge(t.data)}catch{return[]}}var j=b(require("axios")),he=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=B(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 O(e){try{let t=await j.default.post("https://music.youtube.com/youtubei/v1/browse",{...c.body,browseId:e},{params:{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 he(t.data)}catch(t){return console.error(t),[]}}var K=b(require("axios"));var xe=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=S(n);i&&s.push(i)}catch(i){console.error(i)}}),s};async function J(e){let t;e.startsWith("VL")||(t="VL"+e);try{let r=await K.default.post("https://music.youtube.com/youtubei/v1/browse",{...c.body,browseId:t},{params:{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 xe(r.data)}catch(r){return console.error(`Error in listMusicsFromPlaylist: ${r}`),[]}}var Z=b(require("axios"));async function $(e,t){let r=await Z.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{...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 U(r.data,e)}catch(s){return console.error(s),{}}}var q=b(require("axios"));async function ee(e,t){let r=await q.default.post("https://music.youtube.com/youtubei/v1/browse?key=AIzaSyC9XL3ZjWddXya6X74dJoCTL-WEYFDNX30",{...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=T(r.data.contents);return s&&(s.id=e),s}catch(s){return console.error(s),null}}var te=b(require("axios"));async function re(e,t){let r=await te.default.post("https://music.youtube.com/youtubei/v1/player",{...c.body,playbackContext:{contentPlaybackContext:{autoCaptionsDefaultOn:!1,html5Preference:"HTML5_PREF_WANTS",lactMilliseconds:"411",mdxContext:{},referer:"https://music.youtube.com/",signatureTimestamp:20024,vis:10}},videoId: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 V(r.data)}catch(s){return console.error(s),{}}}0&&(module.exports={AccountType,AlbumType,GetMusicVideoBasedSuggestions,ListMusicVideosFromAlbum,ListMusicVideosFromPlaylist,PageType,SearchForAlbum,SearchForArtists,SearchForMusicVideos,SearchForPlaylists,getArtist,getPlaylist,getVideo}); |
{ | ||
"name": "ipman-youtube-music", | ||
"description": "Unofficial YouTube Music API for Node.js", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "exports": "./dist/index.js", |
64677
226