rebane2001 / matterport-dl

A downloader for matterport virtual tours
The Unlicense
320 stars 79 forks source link

401 error while downloading #104

Closed Planchee closed 2 months ago

Planchee commented 9 months ago
Downloading base page...
Doing advanced download of dollhouse/floorplan data...
Downloading static assets...
JS FILE EXTRACTED, 217.js
JS FILE EXTRACTED, 231.js
JS FILE EXTRACTED, 27.js
JS FILE EXTRACTED, 324.js
JS FILE EXTRACTED, 325.js
JS FILE EXTRACTED, 327.js
JS FILE EXTRACTED, 33.js
JS FILE EXTRACTED, 378.js
JS FILE EXTRACTED, 401.js
JS FILE EXTRACTED, 477.js
JS FILE EXTRACTED, 625.js
JS FILE EXTRACTED, 648.js
JS FILE EXTRACTED, 662.js
JS FILE EXTRACTED, 679.js
JS FILE EXTRACTED, 782.js
JS FILE EXTRACTED, 858.js
JS FILE EXTRACTED, 948.js
JS FILE EXTRACTED, 952.js
JS FILE EXTRACTED, 958.js
JS FILE EXTRACTED, 983.js
Downloading model info...
Downloading images...
Downloading graph model data...
Patching graph_GetModelDetails.json URLs
Downloading model ID: tourIDhere ...
Traceback (most recent call last):
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 121, in downloadFile
    _filename, headers = urllib.request.urlretrieve(
  File "C:\Program Files\Python310\lib\urllib\request.py", line 241, in urlretrieve
    with contextlib.closing(urlopen(url, data)) as fp:
  File "C:\Program Files\Python310\lib\urllib\request.py", line 216, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Program Files\Python310\lib\urllib\request.py", line 525, in open
    response = meth(req, response)
  File "C:\Program Files\Python310\lib\urllib\request.py", line 634, in http_response
    response = self.parent.error(
  File "C:\Program Files\Python310\lib\urllib\request.py", line 563, in error
    return self._call_chain(*args)
  File "C:\Program Files\Python310\lib\urllib\request.py", line 496, in _call_chain
    result = func(*args)
  File "C:\Program Files\Python310\lib\urllib\request.py", line 643, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 401: Unauthorized

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 680, in <module>
    initiateDownload(pageId)
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 545, in initiateDownload
    downloadPage(getPageId(url))
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 537, in downloadPage
    downloadModel(pageid, accessurl)
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 279, in downloadModel
    downloadUUID(accessurl, modeldata["job"]["uuid"])
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 48, in downloadUUID
    downloadFile(accessurl.format(
  File "C:\Users\UserID\AppData\Local\Programs\Python\Python312\matterport-dl.py", line 144, in downloadFile
    raise Exception
Exception

Successful download on November 23rd, new download today won't work anymore. Using latest update of Mu-Ramandan (commit 06/12/23). It's throwing a 401 so is Matterport is blocking something in the access through the URL?

Planchee commented 9 months ago

Fix in downloadFile seems to be working: Line 108:

def downloadFile(url, file, post_data=None):
global accessurls
url = GetOrReplaceKey(url, False)

    if "/" in file:
        makeDirs(os.path.dirname(file))
    if "?" in file:
        file = file.split('?')[0]

    # skip already downloaded files except index.html, which is really JSON possibly with newer access keys?
    if os.path.exists(file):
        logging.debug(f'Skipping url: {url} as already downloaded')
        return

    try:
        response = requests.get(url, stream=True)
        response.raise_for_status()

        with open(file, 'wb') as f:
            for chunk in response.iter_content(chunk_size=8192):
                if chunk:
                    f.write(chunk)

        logging.debug(f'Successfully downloaded: {url} to: {file}')
        return

    except requests.exceptions.HTTPError as err:
        logging.warning(
            f'URL error Handling {url} or will try alternative: {str(err)}')

        # Try again but with different accessurls (very hacky!)
        if "?t=" in url:
            for accessurl in accessurls:
                url2 = ""
                try:
                    url2 = f"{url.split('?')[0]}?{accessurl}"
                    response = requests.get(url2, stream=True)
                    response.raise_for_status()

                    with open(file, 'wb') as f:
                        for chunk in response.iter_content(chunk_size=8192):
                            if chunk:
                                f.write(chunk)

                    logging.debug(
                        f'Successfully downloaded through alt: {url2} to: {file}')
                    return
                except requests.exceptions.HTTPError as err:
                    logging.warning(
                        f'URL error alt method tried url {url2} Handling of: {str(err)}')
                    pass

        logging.error(f'Failed to succeed for url {url}')
        raise Exception

Edit; re-opened to make it visible. @Mu-ramadan.. feel free to update on your fork :)

mu-ramadan commented 9 months ago

thanks, I just fixed it.

mrflo commented 9 months ago

Hi, this is not fixing the 401 issue. I'm facing the same problem. I'm receiving {"code":"access.forbidden","message":"Forbidden","retry":false}

On file ending with .dam it seems like _50k.dam

May be they have changed their system and there is not more _50k.dam files ? I can't seem to find files with .dam extension in the browser

Anybody knows ?

hbirs commented 9 months ago

I installed the tor browser and tried it, but it failed. I replaced lines 123-128 of the last modified source code with the following code

try:
    proxies = {
        'http' : "socks5h://localhost:9150",
        'https' : "socks5h://localhost:9150"
    }
    response = session.get(url, proxies=proxies)

assets/pan/2k assets/pan/high assets/pan/low

The images in the above folders could be retrieved, but the process stopped after that.

mrflo commented 9 months ago

@hbirs with your proxy system did you still have the 401 error ? {"code":"access.forbidden","message":"Forbidden","retry":false}

vikaskedia commented 9 months ago

Try using https://github.com/mu-ramadan/matterport-dl.git it is a fork of the current project and it is 24 commits ahead and works much better and has 53 stars.

mrflo commented 9 months ago

Hi thanks vikaskedia That repo is still giving a 401 it's like the file requested 50k.dam is not existing anymore: https://cdn-2.matterport.com/models/.....f/assets/~/....._50k.dam

Anyone with the same error ?

custom90gt commented 7 months ago

I still get error 401 when trying to download and it looks like the Reddit thread is now archived. Would love to download the walkthrough of my house we just listed.

SportsApps commented 7 months ago

It's a same. Seem Matterport have change something to avoid use this folk and those genius guys have no time for try to fix it (maybe it isn't possible to do it...) I shoulded have learned programing when I was young!!!

mitchcapper commented 2 months ago

This should be fixed now, please test again on master and let us know if not.

SportsApps commented 1 month ago

This should be fixed now, please test again on master and let us know if not.

You are a genius! It works! Thanks a lot, mitchcapper.