iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FR: Support providing cookies to download additional file qualities for already-purchased (and freely available) media

purrloftruth opened this issue · comments

Python version:
Python 3.7.2
Bandcamp-dl version:
0.0.8-12 (homebrew)
Bancamp-dl options:
n/a
url:
n/a
options:
n/a
Describe the issue:

Right now, bandcamp-dl only downloads the preview versions of files that are available from the preview player.

It would be wonderful if you could, for example, provide a login cookie to bandcamp-dl, and then be able to download music you've already purchased on bandcamp at the full list of resolutions that bandcamp provides. Alternately, if the media is available free of charge, you would not need a cookie.

It would also be nice if you could provide a login cookie and a yum code to redeem an album download right from bandcamp-dl.

Additions like this would go a long way towards making bandcamp-dl more fully featured and more easily usable in a larger number of environments.

Thanks for your consideration and your hard work!!

Sounds like a good idea, we already use a "session" so would just be a matter of allowing a user to provide credentials then doing a login request if possible and retaining the session for the duration of the download process.

Would likely require me to tweak not.finished file generation to not store that info in plain text though.

I'll look into it, may require me to buy a few things for testing though so could be some time. Or I'll find someone in the discord who has to test for me.

Working on trying to login via requests to create a session, so far I've determined that Bandcamp uses KnockoutJS for its login form rather than the generic login form with a method which makes it kind of a PITA especially as JS just isn't my primary or even secondary coding language.

I've got:

var postData = {
                "user.name": self.username(),
                "login.password": self.password(),
                "login.twofactor": self.twofactorVisible() ? self.twofactor() : "",
                "login.twofactor_remember": self.twofactorVisible() ? self.twofactorRemember() : "",
                "login.from": from,
                "to_band_path": urlParams.to_band_path
};

And an obvious POST using said postData:

$.post("/login_cb", postData)

This all fires off after hitting submit which does a quick check to see if 2FA needs to be fired up and/or a Captcha, its possible that you can't just throw username and password into a payload and send it on over to /login_cb and that the information is hashed and the other values are populated. This makes things a bit complicated as my next solution would be to somehow retrieve the cookie from the users browser, which I'm frankly not comfortable doing as 1: its sketchy, and 2: everyone uses different browsers on different systems.

As much as I would liked to have added this feature in it doesn't seem feasible at least for me personally to add at the moment.

Its entirely possible this would make its way into a GUI frontend however as with most frameworks (QT, Kivy) you have access to a web view which would make displaying the login form and saving the session trivial.

Fingers crossed that someone more familiar with JS/Knockout can get a look at it at some point and make some progress towards adding this feature into the base cli app.

Note to self: Check out browser-cookie3 to see if its possible to at least do this and support some browsers.