07th-mod / resources

Resources used to play the patches
0 stars 0 forks source link

Fix broken URLs in install.bat scripts #2

Closed andOlga closed 6 years ago

enumag commented 6 years ago

Thank you!

ItaloKnox commented 6 years ago

Thanks, I guess I forgot to push the changes after releasing the last batch.

enumag commented 6 years ago

@ItaloKnox You didn't. It's just that the version number is used on two places in the URL and you only changed one of them. Also it's partially my fault too - we had a report about this for Onikakushi which I fixed but apparently neglected to check the other chapters.

ItaloKnox commented 6 years ago

Heh, that's what I get for not paying attention. I'm still trying to implement a better way of handling the links, I'll see if I can get it done this time.

andOlga commented 6 years ago

@ItaloKnox Perhaps use something along the lines of set VERSION=v3.0.1 at the top of the script, and then use %VERSION% inside the URL? That would prevent mistakes like this happening, since it would only need to be changed once.

enumag commented 6 years ago

Yep, exactly what I wanted to suggest. :-)

enumag commented 6 years ago

And there is also the possibility of pulling latest version from GitHub API.

ItaloKnox commented 6 years ago

My solution was something like that, @enumag.

curl -s https://api.github.com/repos/07th-mod/onikakushi/releases/latest | grep browser_download_url | cut -d '"' -f 4

This line outputs the link to the last version of the patch and requires no changes when new versions are released. The thing is: the link is generated but not saved, so I don't have a clue on how to actually use the link. I have very little experience with commands like that.

ItaloKnox commented 6 years ago

We could also go with the VERSION thing, much easier and requires no more dependencies for Windows. I'll push these while I try to figure how to make my version work as intended. Thanks, @tlm-2501.

andOlga commented 6 years ago

@ItaloKnox Ah, this is interesting! I wasn't familiar with the Github API providing this information. In that case, I may be able to help a little bit.

The following will produce the equivalent output on Windows (assuming PowerShell is installed, which it is by default on all supported Windows versions):

powershell -command "(convertfrom-json (invoke-webrequest https://api.github.com/repos/07th-mod/onikakushi/releases/latest).content).assets.browser_download_url"

You can then pipe the output of this to a file (with >something.txt), and feed that file to aria2c using the -i parameter, instead of specifying the URL directly.

ItaloKnox commented 6 years ago

Oh god, I can't believe I forgot we could do that even though I do it all the time. It should also work with my version but yours works out of the box already, so I won't need to update the installers with new dependencies.

Though there is a small issue you might be able to figure out. This happens when I input the .txt file with the link: firefox_2017-12-13_10-55-37

andOlga commented 6 years ago

@ItaloKnox I honestly have no idea what's happening here. I have tested my approach on my machine (running that powershell command, redirecting the output to file and using it with aria2c -i file.txt), and it works perfectly. Maybe let powershell itself handle the whole file processing thing, to eliminate the possibility of cmd doing something weird to text encodings? You'd do it like this:

powershell -command "(convertfrom-json (invoke-webrequest https://api.github.com/repos/07th-mod/onikakushi/releases/latest).content).assets.browser_download_url | set-content file.txt"

If that's not it, then I honestly don't know.

ItaloKnox commented 6 years ago

set-content file.txt seems to work this time. I guess the encoding was broken. I'll take the full installation to a test drive and see if it works well. Best case scenario we fixed this issue and won't have to deal with it again.

ItaloKnox commented 6 years ago

Ok, everything seems to be working perfectly. Thanks a lot, @tlm-2501, you really helped me. Also took this chance to fix some stuff in the code that was broken and I didn't notice.