patrickkfkan / bandcamp-fetch

Library for scraping Bandcamp content.
44 stars 3 forks source link

Getting/setting cookie doesn't work #6

Closed polyclick closed 10 months ago

polyclick commented 10 months ago

I've tried the method as described here to get the session cookie. At the moment I don't get HQ urls back.

I've tried both Chrome & Firefox, made sure I was logged out before starting. I also tried different albums because I thought some just might not have the HQ property at all.

Any Idea?

PS: the session cookie value looks different in Chrome vs Firefox, both none of both work for me.

Cheers!

polyclick commented 10 months ago

Ok, further investigation, I do get the streamUrlHQ property back. But not on the bcfetch.album.getInfo method but on the bcfetch.track.getInfo.

Maybe the example in the readme section is wrong? Or should the album endpoint support getting back the HQ url?

patrickkfkan commented 10 months ago

Just tested bcfetch.album.getInfo() on an album that I purchased. Each element of the tracks array does contain streamUrlHQ.

import bcfetch from 'bandcamp-fetch';

const albumUrl = 'https://anitatatlow.bandcamp.com/album/lights';  // Album I purchased

const params = {
  albumUrl,
  albumImageFormat: 'art_app_large',
  artistImageFormat: 'bio_featured'
};

bcfetch.setCookie(<my cookie>);  // Set cookie

bcfetch.album.getInfo(params).then((results) => {
  console.log(JSON.stringify(results, null, 2));
});

Result:

{
  "type": "album",
  "name": "Lights",
  "url": "https://anitatatlow.bandcamp.com/album/lights",
  "numTracks": 5,
  "keywords": [
    "Ambient",
    "acoustic dream pop",
    "ambient electronic",
    "dark ambient",
    "female vocals",
    "Hong Kong"
  ],
  "description": "Atmospheric and mesmerising in equal measure, this solo EP from Hong Kong based artist Anita Tatlow reflects on life, loss and the lights in between. Her signature ethereal vocals soaring over cinematic ambient production, Lights is a five-track EP that is nostalgic, inspiring, and deeply evocative.",
  "releaseDate": "04 Aug 2023 00:00:00 GMT",
  "artist": {
    "name": "Anita Tatlow",
    "url": "https://anitatatlow.bandcamp.com"
  },
  "releases": [
    {
      "name": "Lights",
      "format": "DigitalFormat",
      "description": "Includes high-quality download in MP3, FLAC and more. Paying supporters also get unlimited streaming via the free Bandcamp app.",
      "url": "https://anitatatlow.bandcamp.com/album/lights",
      "imageUrl": "https://f4.bcbits.com/img/a0879817121_10.jpg"
    }
  ],
  "tracks": [
    {
      "name": "When the Lights Are Gone",
      "duration": 203.013,
      "streamUrl": "https://bandcamp.com/stream_redirect?enc=mp3-128&track_id=3267467401...",
      "streamUrlHQ": "https://t4.bcbits.com/stream/1f85096e7280baa680d2e9d78a5402a5/mp3-v0/...",
      "position": 1,
      "url": "https://anitatatlow.bandcamp.com/track/when-the-lights-are-gone"
    },
    ...
  ],
  "imageUrl": "https://f4.bcbits.com/img/a0879817121_16.jpg",
  "label": {
    "name": "Echoes Blue Music",
    "url": "https://store.echoesblue.com"
  },
  "publisher": {
    "name": "Anita Tatlow",
    "url": "https://anitatatlow.bandcamp.com",
    "description": "Anita is a vocal artist and musician, currently living in Hong Kong. Best known for her ethereal vocals and her work with Salt of the Sound and Narrow Skies, Anita has collaborated with numerous independent artists worldwide and released music on prominent labels including Monstercat Silk, Sekora, AMG records, and Echoes Blue Music.",
    "imageUrl": "https://f4.bcbits.com/img/0026553681_28.jpg"
  }
}