rkdn / bgg_collection2pdf Goto Github PK
View Code? Open in Web Editor NEWGenerate a PDF catalog of your boardgamegeek.com collection.
License: MIT License
Generate a PDF catalog of your boardgamegeek.com collection.
License: MIT License
This was requested over on BGG. It isn't clear if this will be implemented in the future or not? But here is a link to possible implementation method:
$ python generate_pdf.py
WARNING:root:UserName: was not valid
Enter your BGG UserName: rkonigsberg
INFO:root:UserName: rkonigsberg is valid
INFO:root:starting
WARNING:root:Reading collection from bgg
Traceback (most recent call last):
File "generate_pdf.py", line 377, in <module>
items = read_collection(config)
File "generate_pdf.py", line 273, in read_collection
collection_response = bgg_getter('collection',params, config)
File "generate_pdf.py", line 97, in bgg_getter
logging.info("Sleeping " + str(config.sleep_time) + " Seconds: " + (error.find('message').text if error != None else str(status)))
AttributeError: 'NoneType' object has no attribute 'text'
$
davidmcdougal@Davids-MacBook-Air bgg_collection2pdf-main % python3 generate_pdf.py --username davidmcdougal
Traceback (most recent call last):
File "/Users/davidmcdougal/Downloads/bgg_collection2pdf-main/generate_pdf.py", line 3, in
import requests
ModuleNotFoundError: No module named 'requests'
davidmcdougal@Davids-MacBook-Air bgg_collection2pdf-main %
My entry for "Funkoverse Strategy Game: Space Jam A New Legacy 100" returns nothing back for the image URL. The script then errors out with:
Traceback (most recent call last):
File "./generate_pdf.py", line 463, in <module>
download_image(config, game_info)
File "./generate_pdf.py", line 227, in download_image
res = requests.get(game_info.image, stream = True)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 70, in get
return request('get', url, params=params, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/api.py", line 56, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 474, in request
prep = self.prepare_request(req)
File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 407, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/usr/lib/python3.6/site-packages/requests/models.py", line 302, in prepare
self.prepare_url(url, params)
File "/usr/lib/python3.6/site-packages/requests/models.py", line 382, in prepare_url
raise MissingSchema(error)
requests.exceptions.MissingSchema: Invalid URL 'None': No schema supplied. Perhaps you meant http://None?
I got around the error with a simple None check in download_image, though the resulting output still reference a non-existent image:
#Download the image to the local cache.
if (game_info.image is None):
logging.warning(game_info.name + " has no image url")
else:
res = requests.get(game_info.image, stream = True)
if res.status_code == 200:
logging.info("Writing: " + collection_info.game_name + " boxart to " + os.path.join(config.images_path, game_info.obj_id + ".jpg"))
with open(os.path.join(config.images_path, game_info.obj_id + ".jpg"), 'wb') as f:
shutil.copyfileobj(res.raw, f)
Perhaps adding a "no image" placeholder jpg and referencing that in the output in this case?
I assume that we should work with the version-specific image for a game, in cases where users have specified which version they own.
Simple fix - that information is already included in collection.xml. Pull request submitted to make this change.
There may be something that can be done to patch this issue in the script. However, it seems to be occurring in ElementTree.py
I'm unable to reproduce the issue with Python 3.10.2
WARNING:root:UserName: was not valid
Enter your BGG UserName: packrat84
INFO:root:UserName: packrat84 is valid
INFO:root:starting
WARNING:root:Reading ./collection.xml
Traceback (most recent call last):
File "/mnt/c/users/frankk/OneDrive/Boredgames/BGG/bgg_collection2pdf/generate_pdf.py", line 391, in <module>
thisgameitems = ElementTree.fromstring(file.read())
File "/usr/lib/python3.9/xml/etree/ElementTree.py", line 1348, in XML
return parser.close()
xml.etree.ElementTree.ParseError: no element found: line 1, column 0
It looks like the main entry name from BGG is going into the titles of the entries on the page, but the alphabetical order instead follows the (invisible) version name. You can see this pretty early in my collection (fiddly_bits) with Werewolf (version: Are You a Werewolf?), Miscellaneous Game Collection (version: 56 Games), and two versions of the Decktet (Decktet and Double Decktet) which have become separated.
It may or may not be an issue for you that my two versions of the Decktet are being displayed as separate entries as well. Usually BGG doesn't double the entries like this when listing games with multiple versions, but you still may want to.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.