mirror of
https://github.com/Emersont1/itchio.git
synced 2026-03-11 08:54:39 +00:00
Fixes By MatthewThomasRussell (edits by me) (#4)
* added print to url * added some more prints * added error handling for non 200 response codes and will report these errors * update error handling * forgot to actually write string to file :( * update to readme for new error logging feature * Changed file writing to use with ... as notation Co-authored-by: Matthew Russell <m.russell2@lancaster.ac.uk>
This commit is contained in:
parent
566b6b26e5
commit
406af545d2
2 changed files with 39 additions and 2 deletions
17
Readme.md
17
Readme.md
|
|
@ -22,3 +22,20 @@ python -m itchio.downloader
|
|||
```
|
||||
|
||||
This is a bit of a bodge, but it works. It essentially goes through and clicks the "Download" link on every item on the bundle's page, which adds it to your itchio library. It does not download any files. You will need the download page's URL (this will be in the bundle's email, and possibly your purchase history). It will not work with 2FA, and I'm unlikely to be able to fix it without making it far more complicated
|
||||
|
||||
|
||||
## Errors
|
||||
if a download fails it will be reported in ```errors.txt``` in the same directory as your downloads
|
||||
|
||||
An example of which could look something like this:
|
||||
```Cannot download game/asset: <Game Name>
|
||||
Publisher Name: <Publisher Name>
|
||||
Output File: <Publisher Name>/<Game Name>/<Specific Item>
|
||||
Request URL: <Some URL>
|
||||
Request Response Code: 404
|
||||
Error Reason: Not Found
|
||||
This game/asset has been skipped please download manually
|
||||
---------------------------------------------------------
|
||||
```
|
||||
|
||||
This is not a perfect solution but does prevent the whole process from crashing
|
||||
|
|
@ -2,6 +2,9 @@ import re
|
|||
import requests
|
||||
import json
|
||||
import os
|
||||
import urllib
|
||||
|
||||
|
||||
|
||||
import itchio.utils
|
||||
|
||||
|
|
@ -53,9 +56,26 @@ class Game:
|
|||
j = r.json()
|
||||
|
||||
# Download
|
||||
|
||||
url = f"https://api.itch.io/uploads/{d['id']}/download?api_key={token}&download_key_id={self.id}&uuid={j['uuid']}"
|
||||
itchio.utils.download_url(url, outfile, self.name +" - "+file)
|
||||
# response_code = urllib.request.urlopen(url).getcode()
|
||||
try:
|
||||
itchio.utils.download_url(url, outfile, self.name +" - "+file)
|
||||
except urllib.error.HTTPError as e:
|
||||
print("This one has broken!!")
|
||||
|
||||
with open('errors.txt', 'a') as f:
|
||||
f.write(f""" Cannot download game/asset: {self.game_slug}
|
||||
Publisher Name: {self.publisher_slug}
|
||||
Output File: {outfile}
|
||||
Request URL: {url}
|
||||
Request Response Code: {e.code}
|
||||
Error Reason: {e.reason}
|
||||
This game/asset has been skipped please download manually
|
||||
---------------------------------------------------------\n """)
|
||||
|
||||
continue
|
||||
|
||||
|
||||
|
||||
with open(f"{self.publisher_slug}/{self.game_slug}.json", "w") as f:
|
||||
json.dump({
|
||||
|
|
|
|||
Loading…
Reference in a new issue