├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── codeql-analysis.yml ├── .gitignore ├── .prettierrc ├── LICENSE ├── README.md ├── docs ├── assets │ ├── css │ │ └── main.css │ ├── images │ │ ├── icons.png │ │ ├── icons@2x.png │ │ ├── widgets.png │ │ └── widgets@2x.png │ └── js │ │ ├── main.js │ │ └── search.js ├── classes │ └── spotify.default.html ├── index.html ├── modules.html └── modules │ ├── index.html │ └── spotify.html ├── package-lock.json ├── package.json ├── src ├── Spotify.ts ├── index.ts ├── lib │ ├── API.ts │ ├── Error.ts │ ├── details │ │ ├── Atrist.ts │ │ ├── Playlist.ts │ │ └── Track.ts │ ├── download.ts │ ├── getYtlink.ts │ └── metadata.ts └── typings │ └── index.d.ts ├── tests └── index.js ├── tsconfig.json └── typedoc.json /.eslintignore: -------------------------------------------------------------------------------- 1 | **/*.js -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | parser: '@typescript-eslint/parser', 3 | extends: [ 4 | 'plugin:@typescript-eslint/recommended', 5 | ], 6 | parserOptions: { 7 | ecmaVersion: 2020, 8 | sourceType: 'module', 9 | }, 10 | rules: { 11 | 12 | }, 13 | } -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ master ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ master ] 20 | schedule: 21 | - cron: '31 5 * * 5' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'javascript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] 37 | # Learn more: 38 | # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed 39 | 40 | steps: 41 | - name: Checkout repository 42 | uses: actions/checkout@v2 43 | 44 | # Initializes the CodeQL tools for scanning. 45 | - name: Initialize CodeQL 46 | uses: github/codeql-action/init@v1 47 | with: 48 | languages: ${{ matrix.language }} 49 | # If you wish to specify custom queries, you can do so here or in a config file. 50 | # By default, queries listed here will override any specified in a config file. 51 | # Prefix the list here with "+" to use these queries and those in the config file. 52 | # queries: ./path/to/local/query, your-org/your-repo/queries@main 53 | 54 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 55 | # If this step fails, then you should remove it and run the build manually (see below) 56 | - name: Autobuild 57 | uses: github/codeql-action/autobuild@v1 58 | 59 | # ℹ️ Command-line programs to run using the OS shell. 60 | # 📚 https://git.io/JvXDl 61 | 62 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 63 | # and modify them (or add more) to build your code if your project 64 | # uses a compiled language 65 | 66 | #- run: | 67 | # make bootstrap 68 | # make release 69 | 70 | - name: Perform CodeQL Analysis 71 | uses: github/codeql-action/analyze@v1 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "semi": false, 3 | "trailingComma": "none", 4 | "singleQuote": true, 5 | "printWidth": 120, 6 | "tabWidth": 4 7 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Alen Yohannan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
URL of the Album
212 |Promise<(string|Buffer)[]>
Downloads the tracks of a playlist
236 |URL of the playlist
244 |Promise<(string|Buffer)[]>
Downloads the given spotify track
268 |Url to download
282 |file to save to
288 |buffer
if no filename is provided and string
if it is
Gets the Buffer of track from the info
312 |info of the track got from spotify.getTrack()
Gets the info the given album URL
463 |Album
473 |Gets the info of the given Artist URL
492 |Artist
502 |Gets the list of albums from the given Artists URL
521 |Albums
531 |Gets the playlist info from URL
573 |URL of the playlist
581 |Get the track details of the given track URL
604 |Track
614 |Gets the info of tracks from Album URL
633 |URL of the playlist
641 |Gets the info of tracks from playlist URL
664 |URL of the playlist
672 |Generated using TypeDoc
855 |> npm i spotifydl-core
72 |
73 |
74 | You need to intialize the Spotify
Class before acessing the methods inside it.
const Spotify = require('spotifydl-core').default
78 | //import Spotify from 'spotifydl-core'
79 |
80 | const credentials = {
81 | clientId: 'your-client-id',
82 | clientSecret: 'your-client-secret'
83 | }
84 | const spotify = new Spotify(credentials)
85 |
86 |
87 | 90 |92 |NOTE: Only some methods are shown here. Checkout the docs depth
91 |
Get Track ⏭️
93 |await spotify.getTrack(track_url)
94 |
95 | // For Example: track_url = 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab'
96 |
97 | // Input: url of the track, Type: string
98 |
99 | Download Track/Song ⬇️
100 |await spotify.downloadTrack(track_url, file_name)
101 |
102 | // For Example: track_url = 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab' & file_name = 'song.mp3'
103 |
104 | // Input: url of the track and name of the filename, Both Type: string
105 |
106 | // It'll return buffer (promise) if you don't provide any filename
107 |
108 |
109 | Get Artist 👩🎤🧑🎤
110 |await spotify.getArtist(artist_url)
111 |
112 | // For Example: artist_url = 'https://open.spotify.com/artist/3B9O5mYYw89fFXkwKh7jCS'
113 |
114 | // Input: url of the artist, Type: string
115 |
116 | Get Album 💽
117 |await spotify.getAlbum(album_url)
118 |
119 | // For Example: album_url = 'https://open.spotify.com/album/3u3WsbVPLT0fXiClx9GYD9?si=pfGAdL3VRiid0M3Ln_0DNg'
120 |
121 | // Input: url of the album, Type: string
122 |
123 | Get Playlist 🎧
124 |await spotify.getPlylist(playlist_url)
125 |
126 | // Input: url of the playlist, Type: string
127 |
128 | Download an Entire playlist
129 |await spotify.downloadPlaylist(playlist_url)
130 |
131 | //It'll return an array containing the Buffer of the songs in the playlist
132 |
133 |
134 | const fs = require('fs-extra')
137 | // Initialization and Authentication
138 | const Spotify = require('spotifydl-core').default // Import the library
139 | const spotify = new Spotify({ // Authentication
140 | clientId: 'acc6302297e040aeb6e4ac1fbdfd62c3', // <-- add your own clientId
141 | clientSecret: '0e8439a1280a43aba9a5bc0a16f3f009', // <-- add your own clientSecret
142 | })
143 | /* To learn more about clientId and Secret ,
144 | visit https://developer.spotify.com/documentation/general/guides/app-settings/
145 | */
146 |
147 | // Declaring the respective url in 'links' object
148 | const links = {
149 | artist: 'https://open.spotify.com/artist/7ky9g1jEjCsjNjZbYuflUJ?si=2To3fmc-T9KuyyrQ-Qp5KQ', // Url of the artist you want to gather info about
150 | album: 'https://open.spotify.com/album/3u3WsbVPLT0fXiClx9GYD9?si=pfGAdL3VRiid0M3Ln_0DNg', // Url of the album you want to gather info about
151 | song: 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab' // Url of the song you want to gather info about or download
152 | };
153 |
154 | // Engine
155 | (async () => {
156 | const data = await spotify.getTrack(links.song) // Waiting for the data 🥱
157 | console.log('Downloading: ', data.name, 'by:', data.artists.join(' ')) // Keep an eye on the progress
158 | const song = await spotify.downloadTrack(links.song) // Downloading goes brr brr
159 | fs.writeFileSync('song.mp3', song) // Let's write the buffer to the woofer (i mean file, hehehe)
160 | })()
161 |
162 | //spotify.verifyCredentials().then(() => Promise.all([spotify.getTrack(links.song), spotify.getAlbum(links.album), spotify.getArtistAlbums(links.artist)]).then(console.log))
163 |
164 |
165 | Generated using TypeDoc
209 |Generated using TypeDoc
109 |Generated using TypeDoc
149 |Generated using TypeDoc
119 |
Downloads the tracks of a Album
204 |