Basic vuepress@1.9.7

This commit is contained in:
Zechariah Tan 2022-03-29 13:23:17 +08:00
parent 14a4f1a12c
commit 7be05d30d8
7 changed files with 8280 additions and 45 deletions

View File

@ -5,6 +5,7 @@
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](https://npmjs.com/package/ytmusic-api) 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](https://npmjs.com/package/ytmusic-api)
## Motivation ## Motivation
I used to use [youtube-music-api](https://npmjs.com/package/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. I used to use [youtube-music-api](https://npmjs.com/package/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. 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.
@ -20,34 +21,6 @@ Because of this, I decided to build my own version of a youtube music api with T
- Albums - Albums
- Playlists - Playlists
## Installation
```
$ npm i ytmusic-api
```
## Usage
Import YTMusic from the npm package
```ts
// TypeScript
import YTMusic from "ytmusic-api"
// JavaScript
const YTMusic = require("ytmusic-api")
```
Create an instance of the class `YTMusic`.
Then, call the `initialize()` to initialize the API before using the API anywhere
```ts
const ytmusic = new YTMusic()
ytmusic.initialize().then(() => {
// Use API here
})
```
### Methods to fetch data ### Methods to fetch data
#### `getSearchSuggestions` #### `getSearchSuggestions`
@ -286,7 +259,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| Name | Data Type | Description | | Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------ | | :--------- | :---------------------------------- | :------------------ |
| type | `"SONG"` | Type of data | | type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID | | videoId | `string` | YouTube Video ID |
| name | `string` | Name | | name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Artists | | artists | [ArtistBasic](#ArtistBasic)`[]` | Artists |
| album | [AlbumBasic](#AlbumBasic) | Album | | album | [AlbumBasic](#AlbumBasic) | Album |
@ -298,7 +271,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| Name | Data Type | Description | | Name | Data Type | Description |
| :-------------- | :---------------------------------- | :--------------------- | | :-------------- | :---------------------------------- | :--------------------- |
| type | `"SONG"` | Type of data | | type | `"SONG"` | Type of data |
| videoId | `string` | YouTube Video ID | | videoId | `string` | YouTube Video ID |
| name | `string` | Name | | name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Artists | | artists | [ArtistBasic](#ArtistBasic)`[]` | Artists |
| duration | `number` | Duration in seconds | | duration | `number` | Duration in seconds |
@ -312,7 +285,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| Name | Data Type | Description | | Name | Data Type | Description |
| :--------- | :---------------------------------- | :------------------------------ | | :--------- | :---------------------------------- | :------------------------------ |
| type | `"VIDEO"` | Type of data | | type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID | | videoId | `string` | YouTube Video ID |
| name | `string` | Name | | name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video | | artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video |
| views | `number` | View count | | views | `number` | View count |
@ -324,7 +297,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| Name | Data Type | Description | | Name | Data Type | Description |
| :---------- | :---------------------------------- | :------------------------------------- | | :---------- | :---------------------------------- | :------------------------------------- |
| type | `"VIDEO"` | Type of data | | type | `"VIDEO"` | Type of data |
| videoId | `string` | YouTube Video ID | | videoId | `string` | YouTube Video ID |
| name | `string` | Name | | name | `string` | Name |
| artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video | | artists | [ArtistBasic](#ArtistBasic)`[]` | Channels that created the video |
| views | `number` | View count | | views | `number` | View count |
@ -338,10 +311,10 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
#### `ArtistBasic` #### `ArtistBasic`
| Name | Data Type | Description | | Name | Data Type | Description |
| :------- | :--------------- | :---------- | | :------- | :-------- | :---------- |
| artistId | `string` | Artist ID | | artistId | `string` | Artist ID |
| name | `string` | Name | | name | `string` | Name |
#### `ArtistDetailed` #### `ArtistDetailed`
@ -360,7 +333,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| artistId | `string` | Artist ID | | artistId | `string` | Artist ID |
| name | `string` | Name | | name | `string` | Name |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails | | thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description | | description | `string` | Description |
| subscribers | `number` | Number of subscribers the Artist has | | subscribers | `number` | Number of subscribers the Artist has |
| topSongs | `Omit<`[SongDetailed](#SongDetailed)`, "duration">[]` | Top Songs from Artist | | topSongs | `Omit<`[SongDetailed](#SongDetailed)`, "duration">[]` | Top Songs from Artist |
| topAlbums | [AlbumDetailed](#AlbumDetailed)`[]` | Top Albums from Artist | | topAlbums | [AlbumDetailed](#AlbumDetailed)`[]` | Top Albums from Artist |
@ -395,7 +368,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
| artists | [ArtistBasic](#ArtistBasic)`[]` | Creators of the Album | | artists | [ArtistBasic](#ArtistBasic)`[]` | Creators of the Album |
| year | `number` | Publication Year | | year | `number` | Publication Year |
| thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails | | thumbnails | [ThumbnailFull](#ThumbnailFull)`[]` | Thumbnails |
| description | `string` | Description | | description | `string` | Description |
| songs | [SongDetailed](#SongDetailed)`[]` | Songs in the Album | | songs | [SongDetailed](#SongDetailed)`[]` | Songs in the Album |
#### `PlaylistFull` #### `PlaylistFull`
@ -414,6 +387,7 @@ ytmusic.getPlaylistVideos("OLAK5uy_nRb467jR73IXKybwzw22_rTYIJ808x4Yc").then(play
[SongDetailed](#SongDetailed) or [VideoDetailed](#VideoDetailed) or [ArtistDetailed](#ArtistDetailed) or [AlbumDetailed](#AlbumDetailed) or [PlaylistFull](#PlaylistFull) [SongDetailed](#SongDetailed) or [VideoDetailed](#VideoDetailed) or [ArtistDetailed](#ArtistDetailed) or [AlbumDetailed](#AlbumDetailed) or [PlaylistFull](#PlaylistFull)
## Credits ## Credits
A lot of the credit should go to [youtube-music-api](https://npmjs.com/package/youtube-music-api). I build this package as a refactored and tested version of youtube-music-api with TypeScript annotations A lot of the credit should go to [youtube-music-api](https://npmjs.com/package/youtube-music-api). I build this package as a refactored and tested version of youtube-music-api with TypeScript annotations
## Testing ## Testing

29
docs/.vuepress/config.ts Normal file
View File

@ -0,0 +1,29 @@
import { defineConfig } from "vuepress/config"
export default defineConfig({
title: "YTMusic API",
description: "Unofficial YouTube Music API for TypeScript",
themeConfig: {
repo: "zS1L3NT/ts-npm-ytmusic-api",
searchPlaceholder: "Search",
smoothScroll: true,
//@ts-ignore
displayAllHeaders: true,
activeHeaderLinks: true,
nav: [
{ text: "Home", link: "/" },
{ text: "Docs", link: "/docs/getting-started.html" }
],
sidebar: [
{
title: "Documentation",
collapsable: false,
sidebarDepth: 2,
children: [
["/docs/getting-started", "Getting Started"],
["/docs/references", "References"]
]
}
]
}
})

12
docs/README.md Normal file
View File

@ -0,0 +1,12 @@
---
home: true
actionText: Get Started
actionLink: /docs/getting-started.html
features:
- title: YouTube Music Scraper
details: YTMusic API scrapes https://music.youtube.com for results and formats it for you
- title: TypeScript Support
details: You will receive TypeScript annotations when calling YouTube Music API with this package
- title: Type Error Detection
details: If there are type errors at runtime, the bug will be spotted and will show in the console
---

View File

@ -0,0 +1,49 @@
# Getting Started
## Overview
YTMusic API is an npm package that scrapes data from YouTube Music and formats it for you.
## Installation
<code-group>
<code-block title="npm">
```bash
npm i ytmusic-api
```
</code-block>
<code-block title="yarn">
```bash
yarn add ytmusic-api
```
</code-block>
<code-block title="pnpm">
```bash
pnpm i ytmusic-api
```
</code-block>
</code-group>
## Usage
Import YTMusic from the npm package
```ts
// ES6 Import
import YTMusic from "ytmusic-api"
// Node Require
const YTMusic = require("ytmusic-api")
```
Create an instance of the class `YTMusic`.
Then, call the `initialize()` to initialize the API before using the API anywhere
```ts
const ytmusic = new YTMusic()
ytmusic.initialize().then(() => {
// Use API here
})
```

49
docs/docs/references.md Normal file
View File

@ -0,0 +1,49 @@
# References
## `YTMusic` methods
### `getSearchSuggestions`
### `search`
### `getSong`
### `getVideo`
### `getArtist`
### `getArtistVideo`
### `getArtistAlbums`
### `getAlbum`
### `getPlaylist`
### `getPlaylistVideos`
## Interfaces
### `ThumbnailFull`
### `SongDetailed`
### `SongFull`
### `VideoDetailed`
### `VideoFull`
### `ArtistBasic`
### `ArtistDetailed`
### `ArtistFull`
### `AlbumBasic`
### `AlbumDetailed`
### `AlbumFull`
### `PlaylistFull`

View File

@ -11,7 +11,9 @@
"url": "https://github.com/zS1L3NT/ts-npm-ytmusic-api" "url": "https://github.com/zS1L3NT/ts-npm-ytmusic-api"
}, },
"scripts": { "scripts": {
"test": "ts-mocha --timeout 10000 src/__tests__/**/*.spec.ts" "test": "ts-mocha --timeout 10000 src/__tests__/**/*.spec.ts",
"docs:dev": "vuepress dev docs",
"docs:build": "vuepress build docs"
}, },
"dependencies": { "dependencies": {
"axios": "^0.25.0", "axios": "^0.25.0",
@ -25,7 +27,9 @@
"mocha": "^9.2.2", "mocha": "^9.2.2",
"mocha.parallel": "^0.15.6", "mocha.parallel": "^0.15.6",
"ts-mocha": "^9.0.2", "ts-mocha": "^9.0.2",
"typescript": "^4.5.5" "typescript": "^4.5.5",
"validate-any": "1.3.1",
"vuepress": "^1.9.7"
}, },
"keywords": [ "keywords": [
"youtube", "youtube",

File diff suppressed because it is too large Load Diff