This is a Node.js project that allows you to download songs from a Spotify playlist using YouTube as the source. The script uses the Spotify Web API to fetch playlist details, searches for each track on YouTube, and downloads the audio files.
Before running the script, make sure you have the following installed on your machine:
- Node.js (https://nodejs.org)
- npm (Node Package Manager) (comes with Node.js)
- Clone this repository to your local machine.
git clone https://github.com/Abhi6722/AudioHives
- Change into the project directory.
cd AudioHives
- Install the required npm packages.
npm install
- Obtain your Spotify API credentials (Client ID and Client Secret) and update them in the
config.js
file:
// config.js
module.exports = {
spotify: {
clientId: 'YOUR_SPOTIFY_CLIENT_ID',
clientSecret: 'YOUR_SPOTIFY_CLIENT_SECRET',
},
youtube: {
apiKey: 'YOUR_YOUTUBE_API_KEY',
},
};
- To start the download process, simply run:
npm start
- The script will run the index.js file and then we can open the http://localhost:8888/login and login into our Spotify Account and then after that we can see the Access token in our terminal.
- Now we have to copy the access token and paste
getMe.js
file in the token variable.
const token = "YOUR_GENERATED_ACCESS_TOKEN";
- Now we have to run the getMe.js file in another terminal using the command
node getMe.js
- The script will fetch the playlist details from Spotify, search for each track on YouTube, and download the audio files. The downloaded songs will be saved in the
songs
directory.
- Make sure you have the required npm packages installed as mentioned in the
package.json
file. - The script will download the audio of the first YouTube search result for each track. If you want to customize this behavior, you can modify the
downloadYouTubeVideo
function in theyoutube.js
file.
This project is licensed under the MIT License - see the LICENSE file for details.
This project uses the Spotify Web API and YouTube API to fetch playlist details and download songs, respectively.