Homebrew / homebrew-cask

🍻 A CLI workflow for the administration of macOS applications distributed as binaries
https://brew.sh
BSD 2-Clause "Simplified" License
20.85k stars 10.67k forks source link

Casks for Dynamic URL downloads #80477

Closed khrj closed 4 years ago

khrj commented 4 years ago

Hi. Is there a way to make a cask for software that does not have a constant URL (i.e. A request is sent to get an on demand URL via javascript everytime)? For Eg. Flashforge's Flashprint Thanks

vladimyr commented 4 years ago

Read this https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#using-a-block-to-defer-code-execution But be warned that casks with URL block won't get accepted in stable repo i.e. here. https://github.com/Homebrew/homebrew-cask/pull/79918#issuecomment-608440175

khrj commented 4 years ago

Read this https://github.com/Homebrew/homebrew-cask/blob/master/doc/cask_language_reference/stanzas/url.md#using-a-block-to-defer-code-execution But be warned that casks with URL block won't get accepted in stable repo i.e. here. #79918 (comment)

Hi, Thanks for replying. I took a look at that page, but I didn't completely understand it. On the flashprint download page, you first have to click software download on the left, and then click a download button beside the flashprint version you want. How do I simulate the click? Could you guide me? Thank you

miccal commented 4 years ago

@KhushrajRathod try looking here instead:

http://en.flashforge.com/download-center

This one appears to provide direct download links.

vladimyr commented 4 years ago

Adding to previous @miccal's comment. You can obtain JSON containing all downloadable software items together with their permanent? download URLs using following snippet:

curl 'https://cn.api.flashforge.com/api/officialWebsite/v1/download?order=desc&sortBy=issue_date&category=8' -H 'Site-Language: en_US'

Their download center works the same way. It is a SPA application that uses ajax to fetch it.

khrj commented 4 years ago

@KhushrajRathod try looking here instead:

http://en.flashforge.com/download-center

This one appears to provide direct download links.

Thanks, and those seem more or less like permanent ones too. The only problem is they don't contain FlashPrint 4.2.0, but only till FlashPrint 4.1.0. So it seems like a URL which was discontinued to me. Another thing to notice there is that the site does not provide SSL (Self-signed), so that's another reason it seems outdated

khrj commented 4 years ago

Adding to previous @miccal's comment. You can obtain JSON containing all downloadable software items together with their permanent? download URLs using following snippet:

curl 'https://cn.api.flashforge.com/api/officialWebsite/v1/download?order=desc&sortBy=issue_date&category=8' -H 'Site-Language: en_US'

Their download center works the same way. It is a SPA application that uses ajax to fetch it.

Thank you, I'll look into this soon

khrj commented 4 years ago

@vladimyr @miccal Thank you for your help, it seems like the download URLs are, as a matter of fact, permanent, only that their file names look auto-generated, which put me off. I've compared http://en.flashforge.com/download-center and https://www.flashforge.com/download-center, and both lead to the same urls. I've tried making multiple requests to the api, and they always give me the same download link. I've also tried using different browsers, with/without tor, and they always lead to the same URL.

vladimyr commented 4 years ago

Great, glad that worked for you!