cebtenzzre / tumblr-utils

A fork of tumblr-utils with Python 3 support, bug fixes, and lots of features I found useful.
GNU General Public License v3.0
40 stars 8 forks source link

Unable to backup posts, just gives me "AttributeError: 'HTTPResponse' object has no attribute 'get_content_length'" #22

Closed robobun7 closed 9 months ago

robobun7 commented 9 months ago

The backup utility used to work fine, but now every attempt to fetch a post just fails with the same error.

Caught exception while saving post [post number redacted]:
Traceback (most recent call last):
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1960, in save_post
    f.write(self.get_post())
            ^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1838, in get_post
    content = self.get_content()
              ^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1521, in get_content
    append_try('body')
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1505, in append_try
    elt = re.sub(r'''(?i)(<img\s(?:[^>]*\s)?src\s*=\s*["'])(.*?)(["'][^>]*>)''',
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\[username redacted]\AppData\Local\Programs\Python\Python311\Lib\re\__init__.py", line 185, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1690, in get_inline_image
    saved_name = self.download_media(image_url, filename=image_filename)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1782, in download_media
    return self._download_media_inner(url, get_path, path_parts, media_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\tumblr_backup.py", line 1808, in _download_media_inner
    wget_retrieve(url, dstpath, post_id=self.ident, post_timestamp=self.post['timestamp'])
  File "C:\py\tumblr-utils-master\wget.py", line 801, in __call__
    _retrieve_loop(hstat, url, file, post_id, post_timestamp, adjust_basename, self.options, self.log)
  File "C:\py\tumblr-utils-master\wget.py", line 635, in _retrieve_loop
    err, doctype = gethttp(url, hstat, doctype, logger, retry_counter, options)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\wget.py", line 253, in gethttp
    err, doctype = process_response(url, hstat, doctype, logger, retry_counter, resp)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\py\tumblr-utils-master\wget.py", line 267, in process_response
    contlen = resp.get_content_length('GET')
              ^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'HTTPResponse' object has no attribute 'get_content_length'
cebtenzzre commented 9 months ago

Duplicate of #15. You should try the latest pip-installable version, with pip install tumblr-backup. That will pull the correct version of urllib3 for you.