jtara1 / imgur_downloader

Python script/class to download an entire Imgur album in one go into a folder of your choice.
MIT License
40 stars 7 forks source link

Fails to download albums marked as mature (imgur now requires login authentication to view them) #25

Closed dragontamer8740 closed 1 year ago

dragontamer8740 commented 4 years ago

Imgur now requires that a user be logged in to view albums that have been flagged/marked as adult/mature.

imgurdl should have a means to provide authentication information. I've made a bad hack to do this, but it's not a good solution for a pull request.

All changes are to imgur_downloader/imgurdownloader.py:

For my ugly fix I replaced the following:

   try:
       self.response = urllib.request.urlopen(url=imgur_url)
       response_code = self.response.getcode()
   except Exception as e:
       self.response = False
       try:
           response_code = e.code
       except AttributeError:
           raise e
   if not self.response or self.response.getcode() != 200:

…with

    cookies=dict(authautologin="[your-auth-cookie-string]")
    self.response=requests.get(imgur_url,cookies=cookies)
    response_code = self.response.status_code
    if not self.response or self.response.status_code != 200:

Remove the line:

html = self.response.read().decode('utf-8')

and in its place put:

html=self.response.text

If anyone is to implement this properly, I'd probably either have a command line argument/config file to pull the auth cookie from, or else properly log in to imgur via username/password prompt.

jtara1 commented 4 years ago

wouldn't your-auth-cookie-string change after your login session expires? im not sure when it would expire either, maybe this solution is fine

I'd add or use user and pass in ~/.gallery-dl to just follow and borrow from their schema and config if we need to grab that info to login. gallery-dl is great, last I checked they don't cover as many imgur urls for dl tho

jtara1 commented 4 years ago

where can I find the value for authautologin

https://github.com/RipMeApp/ripme/issues/1459 https://gist.github.com/dvdsgl/743e8821f1566948068e966e32adc224

you can get it from their api, but whats required to use their api? I have my own client id and secret

dragontamer8740 commented 4 years ago

I will look around. I can't remember right now; haven't used the API in a long time but I also have an app registered for it.

You might just tell the user to register it themselves?

nick-s-b commented 4 years ago

It looks like imgur now allows you to see adult content just by clicking a button... no login needed.

God-damnit-all commented 4 years ago

I ran across some images that forced you to need to login, there was no button to view it otherwise. Might be region-specific?

jtara1 commented 1 year ago

gallery-dl supports downloading from the variety of links this project supports. I'm going to archive this repo.

Check for support for this there or report an issue there.