Fixed crash when board game has no representing image
This commit is contained in:
parent
efcecacd1f
commit
18ddf5b554
1 changed files with 13 additions and 2 deletions
|
|
@ -98,13 +98,24 @@ def convert_xml_to_boardgame(boardgame_xml: ET.Element) -> boardgame_classes.Boa
|
||||||
artist = people_classes.Artist(id=artist_id, name=artist_name)
|
artist = people_classes.Artist(id=artist_id, name=artist_name)
|
||||||
artists.append(artist)
|
artists.append(artist)
|
||||||
|
|
||||||
|
if boardgame_xml.find('image') != None:
|
||||||
|
image_url = boardgame_xml.find('image').text
|
||||||
|
else:
|
||||||
|
image_url = "https://cf.geekdo-images.com/zxVVmggfpHJpmnJY9j-k1w__thumb/img/Tse35rOD2Z8Pv9EOUj4TfeMuNew=/fit-in/200x150/filters:strip_icc()/pic1657689.jpg"
|
||||||
|
|
||||||
|
if boardgame_xml.find('thumbnail') != None:
|
||||||
|
thumbnail_url = boardgame_xml.find('thumbnail').text
|
||||||
|
else:
|
||||||
|
thumbnail_url = "https://cf.geekdo-images.com/zxVVmggfpHJpmnJY9j-k1w__thumb/img/Tse35rOD2Z8Pv9EOUj4TfeMuNew=/fit-in/200x150/filters:strip_icc()/pic1657689.jpg"
|
||||||
|
|
||||||
|
|
||||||
boardgame_dict = {
|
boardgame_dict = {
|
||||||
"id" : int(boardgame_xml.get('id')),
|
"id" : int(boardgame_xml.get('id')),
|
||||||
"name" : boardgame_xml.find('name').get('value'),
|
"name" : boardgame_xml.find('name').get('value'),
|
||||||
"weight": boardgame_xml.find('statistics').find('ratings').find('averageweight').get('value'),
|
"weight": boardgame_xml.find('statistics').find('ratings').find('averageweight').get('value'),
|
||||||
"description" : html.unescape(boardgame_xml.find('description').text),
|
"description" : html.unescape(boardgame_xml.find('description').text),
|
||||||
"image_url" : boardgame_xml.find('image').text,
|
"image_url" : image_url,
|
||||||
"thumbnail_url" : boardgame_xml.find('thumbnail').text,
|
"thumbnail_url" : thumbnail_url,
|
||||||
"year_published" : int(boardgame_xml.find('yearpublished').get('value')),
|
"year_published" : int(boardgame_xml.find('yearpublished').get('value')),
|
||||||
"min_players" : int(boardgame_xml.find('minplayers').get('value')),
|
"min_players" : int(boardgame_xml.find('minplayers').get('value')),
|
||||||
"max_players" : int(boardgame_xml.find('maxplayers').get('value')),
|
"max_players" : int(boardgame_xml.find('maxplayers').get('value')),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue