Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How would you get artists and albums with this client, if possible? #78

Closed
tacohitbox opened this issue Jun 19, 2022 · 12 comments
Labels
fixed question Further information is requested Stale

Comments

@tacohitbox
Copy link

tacohitbox commented Jun 19, 2022

Question

I looked around the documentation, and I see no mention of getting albums from YT Music at the moment. Is it possible to at the moment, and if not, can you add it?

Also you can get some artist metadata but I believe it's different than what YouTube Music responds with. Is it possible to get more information, like top tracks?

Many thanks.

Sample Code

I tried reading the album IDs as playlists with no luck. Example below.

const Yt = require("youtubei.js");

(async function() {
  let yt = await new Yt({gl: "US"});
  let a = await yt.getPlaylist("MPREb_iYZbnszRqas", {client: "YTMUSIC"});
  console.log(a);
})();

I did something similar with artist IDs and got some but not all of the information I need.

const Yt = require("youtubei.js");

(async function() {
  let yt = await new Yt({gl: "US"});
  let a = await yt.getChannel("UCXWUt1Cu2hVZYTaJ44ddusA", {client: "YTMUSIC"});
  console.log(a);
})();
@tacohitbox tacohitbox added the question Further information is requested label Jun 19, 2022
@tacohitbox tacohitbox changed the title [QUESTION] How would you get albums with this client, if possible? [QUESTION] How would you get artists and albums with this client, if possible? Jun 19, 2022
@tacohitbox
Copy link
Author

Edited after I noticed I had similar trouble with artist IDs.

@LuanRT
Copy link
Owner

LuanRT commented Jun 19, 2022

Not possible in v1, but v2 will bring full support for YouTube Music. See #65.

LuanRT added a commit that referenced this issue Jun 20, 2022
Available through `Innertube#music.getArtist(id: string)`

#78
@LuanRT
Copy link
Owner

LuanRT commented Jun 20, 2022

This is now possible after 7fc9b52 & 97d4cc1. If you would like to test it simply install the dev version.

Examples:

const album = await youtube.music.getAlbum('MPREb_lM0ql53ZzAr');
const artist = await youtube.music.getArtist('UC52ZqHVQz5OoGhvbWiRal6g');

@tacohitbox
Copy link
Author

tacohitbox commented Jun 21, 2022

Other than a lot of errors on albums being but into the console, like so, it works great:

InnertubeError: Something went wrong at LikeButton!
This is a bug, please report it at https://github.com/LuanRT/YouTube.js/issues
    at Parser.formatError (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:188:9)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:155:18)
    at new Menu (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/Menu.js:10:37)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26)
    at new MusicResponsiveListItem (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicResponsiveListItem.js:52:24)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)
    at new MusicShelf (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicShelf.js:13:28)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)
    at new SectionList (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/SectionList.js:12:28)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26) {
  info: {
    stack: "TypeError: Cannot read properties of undefined (reading 'map')\n" +
      '    at new LikeButton (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/LikeButton.js:16:44)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at new Menu (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/Menu.js:10:37)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26)\n' +
      '    at new MusicResponsiveListItem (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicResponsiveListItem.js:52:24)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at new MusicShelf (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicShelf.js:13:28)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at new SectionList (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/SectionList.js:12:28)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26)'
  },
  date: 2022-06-21T05:47:11.036Z,
  version: '1.4.3'
}

@tacohitbox
Copy link
Author

The artist suggested, UC52ZqHVQz5OoGhvbWiRal6g, and all others I tried, gives this error:

TypeError: Cannot read properties of undefined (reading 'url_canonical')
    at new Album (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/ytmusic/Album.js:22:39)
    at Music.getAlbum (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/core/Music.js:88:12)

@tacohitbox
Copy link
Author

Many thanks, by the way, for helping me out :)

@LuanRT
Copy link
Owner

LuanRT commented Jun 21, 2022

The artist suggested, UC52ZqHVQz5OoGhvbWiRal6g, and all others I tried, gives this error:

TypeError: Cannot read properties of undefined (reading 'url_canonical')
    at new Album (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/ytmusic/Album.js:22:39)
    at Music.getAlbum (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/core/Music.js:88:12)

Seems like you've used getAlbum() when it should've been getArtist().

@LuanRT
Copy link
Owner

LuanRT commented Jun 21, 2022

Other than a lot of errors on albums being but into the console, like so, it works great:

Thanks for reporting that.
Those are silent errors so you don't have to worry about them for now.

@tacohitbox
Copy link
Author

The artist suggested, UC52ZqHVQz5OoGhvbWiRal6g, and all others I tried, gives this error:

TypeError: Cannot read properties of undefined (reading 'url_canonical')
    at new Album (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/ytmusic/Album.js:22:39)
    at Music.getAlbum (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/core/Music.js:88:12)

Seems like you've used getAlbum() when it should've been getArtist().

Silly mistake on my part, apologies!

@tacohitbox
Copy link
Author

InnertubeError: Something went wrong at MusicResponsiveListItem!
This is a bug, please report it at https://github.com/LuanRT/YouTube.js/issues
    at Parser.formatError (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:188:9)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:155:18)
    at new MusicShelf (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicShelf.js:13:28)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)
    at new SectionList (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/SectionList.js:12:28)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26)
    at new Tab (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/Tab.js:13:27)
    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)
    at get tabs [as tabs] (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/TabbedSearchResults.js:15:19)
    at new Search (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/ytmusic/Search.js:27:37) {
  info: {
    stack: "TypeError: Cannot read properties of undefined (reading 'page_type')\n" +
      '    at new MusicResponsiveListItem (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicResponsiveListItem.js:28:34)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at new MusicShelf (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/MusicShelf.js:13:28)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at new SectionList (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/SectionList.js:12:28)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:168:26)\n' +
      '    at new Tab (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/Tab.js:13:27)\n' +
      '    at Parser.parse (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/index.js:151:28)\n' +
      '    at get tabs [as tabs] (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/contents/classes/TabbedSearchResults.js:15:19)\n' +
      '    at new Search (/home/a/Documents/git/mollusk/node_modules/youtubei.js/lib/parser/ytmusic/Search.js:27:37)'
  },
  date: 2022-06-22T03:45:46.299Z,
  version: '1.4.3'
}

got another error for ya, while searching no copyright sounds on youtube music @LuanRT

@LuanRT
Copy link
Owner

LuanRT commented Jun 22, 2022

got another error for ya, while searching no copyright sounds on youtube music @LuanRT

Thanks! Should be fixed now (2055697).

@github-actions
Copy link
Contributor

github-actions bot commented Aug 5, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed question Further information is requested Stale
Projects
None yet
Development

No branches or pull requests

2 participants