Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open manual downloads URLs automatically #28

Merged
merged 6 commits into from
Apr 3, 2023
Merged

Open manual downloads URLs automatically #28

merged 6 commits into from
Apr 3, 2023

Conversation

PraxTube
Copy link
Contributor

It is rather annoying and slow to click on all the manual downloads. Instead the script could write the downloads a text file which can be open by a browser all at once.

With this PR, one can use

firefox-browser $(cat manual_downloads.txt)

which will open up all the URLs that were not able to download automatically. This works with any browser that can open URLs from terminal.

This way, one can simple call `browser $(cat manual_downloads.txt)` and
it automatically opens up all the manual downloads urls.
@PraxTube PraxTube marked this pull request as draft March 25, 2023 09:07
This argument is used to set the browser the user whishes to be used to
open the manual downloads.

Also fixed a typo.
@PraxTube PraxTube changed the title Write manual downloads URLs to a text file Open manual downloads URLs automatically Mar 25, 2023
@cdbbnnyCode
Copy link
Owner

This is a really good idea. Let me know when it's ready to merge.

The `shell=True` flag was added. The script `install.py` opens the
downloads automatically now.
@PraxTube PraxTube marked this pull request as ready for review March 26, 2023 09:54
@PraxTube
Copy link
Contributor Author

@cdbbnnyCode Ready to be merged from my side.

@endumiuz
Copy link

endumiuz commented Apr 2, 2023

xdg-open could be used to open urls in the default browser, or even better:

import webbrowser

browser = webbrowser.get()
browser.open_new(link)

@PraxTube
Copy link
Contributor Author

PraxTube commented Apr 2, 2023

Ah yes very true. Don't know why I made it so complicated haha. Will update it.

Use `webbrowser` to open the urls instead of the a shell command.
Modified the behaviour of the parse command too.

Idea for the change comes from @endumiuz
@PraxTube
Copy link
Contributor Author

PraxTube commented Apr 2, 2023

I didn't test the new commit. Do you guys know of a way to download a dummy modpack or something? Don't want to run 5 minute downloads just for tests.

@endumiuz
Copy link

endumiuz commented Apr 2, 2023

I think you can skip creating the txt-file and just do for url, _ in actual_manual_dls: instead of for url in urls:.

Also updated README.md usage.
@cdbbnnyCode
Copy link
Owner

Hey thanks for the updates. I was going to suggest at least not using the shell (as that adds a lot of variables in terms of complexity), but this looks much better.

@cdbbnnyCode
Copy link
Owner

Traceback (most recent call last):
  File "/home/aidan/Documents/projects/modpack-installer/install.py", line 275, in <module>
    main(args.zipfile, args.mcdir, args.forge_disable, args.open_browser)
  File "/home/aidan/Documents/projects/modpack-installer/install.py", line 171, in main
    browser.open_new(url)
  File "/usr/lib/python3.10/webbrowser.py", line 152, in open_new
    return self.open(url, 1)
  File "/usr/lib/python3.10/webbrowser.py", line 272, in open
    args = [arg.replace("%s", url).replace("%action", action)
  File "/usr/lib/python3.10/webbrowser.py", line 272, in <listcomp>
    args = [arg.replace("%s", url).replace("%action", action)
TypeError: replace() argument 2 must be str, not tuple

Looks like it crashes because each entry of actual_manual_dls is a tuple of (url, outfile).

@cdbbnnyCode
Copy link
Owner

Also, I created a test modpack for further verification
TestModpack-1.0.0.zip

@cdbbnnyCode cdbbnnyCode merged commit c9a38cd into cdbbnnyCode:master Apr 3, 2023
@PraxTube PraxTube deleted the create-downloads-text-file branch April 3, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants