Fork of ytmusic-api
Go to file
SAROND f9664fe267 feat(YTMusic): implement continuous pagination in getHome method
This commit introduces the ability to fetch and parse additional pages of content in the `getHome` method of the `YTMusic` class by utilizing a continuation token. The previous implementation only fetched the initial page of content. Now, after parsing the initial page, the method checks for a continuation token and continues to fetch and parse subsequent pages until no continuation token is found, allowing for complete retrieval of home page content.

Additionally, there has been a minor change in the `SongParser.parseSearchResult` method where the logic to identify the title and artist from search results has been simplified due to the impossibility of distinguishing them with the current data structure. The new approach uses fixed positions in the columns array to assign title and artist.
2024-01-16 04:05:42 +04:00
.github/workflows 🐛 add back publish step and update readme.md 2023-07-30 00:28:06 +08:00
src feat(YTMusic): implement continuous pagination in getHome method 2024-01-16 04:05:42 +04:00
.editorconfig timely update 2023-12-22 03:25:11 +08:00
.eslintrc.json timely update 2023-12-22 03:25:11 +08:00
.gitignore Migrated to using vuepress@2.0.0-beta 2022-03-29 16:45:00 +08:00
.npmignore 📝 simplify documentation 2023-12-28 04:35:45 +08:00
.prettierrc timely update 2023-12-22 03:25:11 +08:00
LICENSE Updated LICENSE 2022-03-28 03:31:43 +08:00
README.md add ability to change locale 2024-01-13 12:18:09 +08:00
bun.lockb ⬆️ upgrade arktype to v1.0.29-alpha 2024-01-13 12:01:43 +08:00
package.json add ability to change locale 2024-01-13 12:18:09 +08:00
tsconfig.json 🐛 fix cjs support gone issue 2024-01-13 00:08:32 +08:00

README.md

YTMusic API

License Languages Top Language Commit Activity Last commit

YouTube Music API (Unofficial) is a YouTube Music data scraper. It comes with TypeScript support API for return types. The NPM package can be found here

Motivation

I used to use youtube-music-api as my youtube music api data scraper. I liked looking into the source code of how it works but it never made sense to me. I also didn't like that there were no TypeScript annotations for the return types of methods. Because of this, I decided to build my own version of a youtube music api with TypeScript annotations, testing and written in a way I can understand.

Features

  • TypeScript Support for data return types
    • Data from YouTube can be inconsistent but YTMusic API has been tested and the data matches the TypeScript types 95% of the time
  • Scrape information directly from YouTube Music API
    • Search Suggestions
    • Songs
    • Videos
    • Artists
    • Albums
    • Playlists
    • Lyrics

Usage

import YTMusic from "ytmusic-api"

const ytmusic = new YTMusic()
await ytmusic.initialize(/* Optional: Custom cookies */)

ytmusic.search("Never gonna give you up").then(songs => {
	console.log(songs)
})

Credits

A lot of the credit should go to youtube-music-api. I build this package as a refactored and tested version of youtube-music-api with TypeScript annotations

Testing

YTMusic API's data return types are tested with Bun Test. To run the tests, run the command

$ bun test

Built with

  • NodeJS
    • TypeScript
      • @types/tough-cookie
      • @typescript-eslint/eslint-plugin
      • @typescript-eslint/parser
      • bun-types
      • typescript
    • ESLint
      • eslint
      • eslint-config-prettier
      • eslint-plugin-simple-import-sort
      • prettier
    • Miscellaneous
      • arktype
      • axios
      • tough-cookie