AlenVelocity / spotifydl-core

Spotify Fetcher and Downloader for Node
https://alenvelocity.github.io/spotifydl-core/
MIT License
55 stars 27 forks source link

Input stream error: Status code: 403` when attempting to download tracks #18

Open Hx-Regex opened 1 month ago

Hx-Regex commented 1 month ago

Description: I am encountering an issue with the spotifydl-core library where I receive an Input stream error: Status code: 403 when attempting to download tracks. The authentication and access token retrieval are successful, but the download process fails.

Steps to Reproduce:

  1. Install the spotifydl-core library.
  2. Set up the Spotify API credentials (clientId and clientSecret).
  3. Attempt to download a track using the library.

Code Snippet: Here is the code I am using:

const fs = require('fs-extra');
const Spotify = require('spotifydl-core').default;
const ffmpegPath = require('ffmpeg-static'); // This will automatically find the path to ffmpeg

// Configure fluent-ffmpeg with the path to ffmpeg
const ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffmpegPath);

// Initialize SpotifyDL
const spotify = new Spotify({
    clientId: '___', // <-- add your own clientId
    clientSecret: '__', // <-- add your own clientSecret
});

// Declaring the respective url in 'links' object
const links = {
    artist: 'https://open.spotify.com/artist/7ky9g1jEjCsjNjZbYuflUJ?si=2To3fmc-T9KuyyrQ-Qp5KQ', // Url of the artist you want to gather info about
    album: 'https://open.spotify.com/album/3u3WsbVPLT0fXiClx9GYD9?si=pfGAdL3VRiid0M3Ln_0DNg', // Url of the album you want to gather info about
    song: 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab' // Url of the song you want to gather info about or download
};

// Engine
(async () => {
    try {
        const data = await spotify.getTrack(links.song); // Waiting for the data 🥱
        console.log('Downloading: ', data.name, 'by:', data.artists.join(' ')); // Keep an eye on the progress
        const song = await spotify.downloadTrack(links.song); // Downloading goes brr brr
        fs.writeFileSync('song.mp3', song); // Let's write the buffer to the woofer (i mean file, hehehe)
        console.log('Download complete: song.mp3');
    } catch (error) {
        console.error('Error:', error.message);
    }
})();```

**Observed Behavior**:
The script successfully retrieves the access token and attempts to download the track. However, it fails with the following error:

```vbnet
Access token: BQD2j0CfzZYTCiT8cCkNEaR_vq3VdLHbsuv0GOKsn6adUI-Y4nL0VvY-rbOaCC
Downloading:  Great Days by: Karen Aoki ハセガワダイスケ
Error: Input stream error: Status code: 403

Detailed Logs:

Access token: BQD2j0CfzZYTCiT8cCkNEaR_vq3VdLHbsuv0GOKsn6adUI-Y4nL0VvY-rbOaCC
Downloading:  Great Days by: Karen Aoki ハセガワダイスケ
Error: Input stream error: Status code: 403

Additional Information:

I tested the clientId and clientSecret keys, and they were working perfectly. The library was working properly last week without issues. I don't know if this is something on my end or an issue with the library. If anyone can confirm whether the library is still working for them, that would be of great help to me so I can investigate further if the problem is with my environment.

TreeOfSelf commented 1 month ago

Same issue here.

mrtampan commented 1 month ago

Screenshot 2024-07-21 230329

same issue bro. i think this repository need update