Code Monkey home page Code Monkey logo

Comments (4)

santisoler avatar santisoler commented on September 27, 2024

Hi @tloredo. Thanks for opening this issue.

What Pooch is doing is downloading the HTML file that Dropbox gives you when you access to https://www.dropbox.com/s/5b9m1pq5qif5obf/lambda-3923-4010-phases-100.h5?dl=0. The Download button is not a regular anchor with a static link, but a dynamic button that triggers the download of the desired file.

After reading Dropbox's docs, you could force it to give you the download link by replacing the trailing dl=0 for dl=1. I just try it out and it downloaded a binary file, which I suppose is the hd5 file you want to fetch.

I'm not sure how wget is able to download the file, even if you pass the dl=0. Maybe it parses the url and uses the one with dl=1 instead.

BTW, if you are going to pass custom urls for every file in the registry, you could use and empty string for your base_url, since it won't be used at any point.

This should work:

import pooch

fetcher = pooch.create(
    path=pooch.os_cache("SOAP2-1Spot"),
    base_url="",
    registry={
    "lambda-3923-4010-phases-100.h5" : None,
    "lambda-3923-6664-phases-4.h5" : None
    },
    # Now specify custom URLs for some of the files in the registry.
    urls={
        "lambda-3923-4010-phases-100.h5" : "https://www.dropbox.com/s/5b9m1pq5qif5obf/lambda-3923-4010-phases-100.h5?dl=1",
        "lambda-3923-6664-phases-4.h5" : "https://www.dropbox.com/s/pyeapovhk4q6az0/lambda-3923-6664-phases-4.h5?dl=1"
    },
)

# These paths end up pointing to files named as indicated, but containing HTML
# corresponding to a Dropbox "can't preview" response:
full_spec_path = fetcher.fetch("lambda-3923-6664-phases-4.h5")
ca_spec_path = fetcher.fetch("lambda-3923-4010-phases-100.h5")

from pooch.

tloredo avatar tloredo commented on September 27, 2024

@santisoler, thanks so much for the quick and helpful response (and the tip about the base url string)! dl=1 does solve this problem. I wonder what wget is doing, but in any case this Pooch issue is solved.

from pooch.

santisoler avatar santisoler commented on September 27, 2024

Glad to be helpful! 🙂

from pooch.

tloredo avatar tloredo commented on September 27, 2024

Just a further followup: Some poking on Stack Exchange, after geting @santisoler's solution, suggests that Dropbox recognizes some user agents and handles requests from them in special ways. See, e.g., linux - how to download dropbox files using wget command? - Super User and curl - User-Agent affects Dropbox shared links download - Stack Overflow. The lesson being that having a Dropbox URL work with some user agents doesn't mean that URL will work for others.

from pooch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.