From 1271ab33c45df6da4df95e8ceeb2d367f9b1bfbd Mon Sep 17 00:00:00 2001 From: doubaniux Date: Thu, 25 Feb 2021 21:52:28 +0100 Subject: [PATCH] update steam scraper --- common/scraper.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/scraper.py b/common/scraper.py index b9be4fcd..75942691 100644 --- a/common/scraper.py +++ b/common/scraper.py @@ -193,6 +193,8 @@ class AbstractScraper: raw_img = img_response.content content_type = img_response.headers.get('Content-Type') ext = guess_extension(content_type.partition(';')[0].strip()) + else: + ext = None return raw_img, ext @@ -1132,10 +1134,16 @@ class SteamGameScraper(AbstractScraper): brief = content.xpath( "//div[@class='game_description_snippet']/text()")[0].strip() - img_url = content.xpath("//img[@class='game_header_image_full']/@src")[ - 0].replace("header.jpg", "library_600x900.jpg") + img_url = content.xpath( + "//img[@class='game_header_image_full']/@src" + )[0].replace("header.jpg", "library_600x900.jpg") raw_img, ext = self.download_image(img_url) + # no 600x900 picture + if raw_img is None: + img_url = content.xpath("//img[@class='game_header_image_full']/@src")[0] + raw_img, ext = self.download_image(img_url) + data = { 'title': title, 'other_title': None,