iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums
The Unlicense
956 stars 108 forks source link

Private tracks bypass - ONLY if private tracks are accessible online #216

Open ArmSob opened 8 months ago

ArmSob commented 8 months ago

Hello,

I have modified some bit of code because I have a subscription to an artist that allow me to listen online only if I have paid. Otherwise, tracks are not available for listening. As there is not functional API to connect with credentials I found the following bypass. After downloading source code, parse html and look for links that start by "t4.bcbits". Replace links album["tracks"]["url"] by the found link.

I will create a PR if I find time to clean my code

Have a great day

:)

ArmSob commented 8 months ago

Replace lines 83 to 88 by

            if lyrics:
                track['lyrics'] = self.get_track_lyrics(f"{artist_url}{track['title_link']}#lyrics")
            if track['file'] is not None:
                track = self.get_track_metadata(track)
                album['tracks'].append(track)
            else:
                html = open("/path/to/html_file.html")
                soup = BeautifulSoup(html, "html.parser")
                bandcamp_json_ = BandcampJSON(soup, debugging).generate()
                page_json_ = {}
                for entry_ in bandcamp_json_:
                    page_json_ = {**page_json_, **json.loads(entry_)}
                track["file"] = {'mp3-v0': page_json_["trackinfo"][i]['file']["mp3-v0"]}
                track = self.get_track_metadata(track)
                album['tracks'].append(track)

And replace /path/to/html_file.html by the path to your html file. Be careful, links are temporary, so it is important to execute right after saving html file, or regenerate html file when needed.

Evolution0 commented 8 months ago

I had an idea sometime back to add the ability to login and save the session data but I never got around to it as I don't own anything on bandcamp to test with.