Skip to content

Commit

Permalink
Update proxycache.py
Browse files Browse the repository at this point in the history
  • Loading branch information
moraroy authored Dec 10, 2024
1 parent 8ba5bb7 commit ce48851
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions proxycache/proxycache.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,22 +177,7 @@ def handle_artwork(self, game_id, art_type, dimensions):
logger.info(f"Sending request to: {url}")
response = limited_request(url, headers)
data = response.json()

# Check for image quality, dimension, or alternate style information and store all metadata
artwork_data = {
'images': [{
'url': image['url'],
'width': image.get('width'),
'height': image.get('height'),
'style': image.get('style', 'default'),
} for image in data.get('data', [])],
'other_metadata': {
'image_quality': data.get('quality', 'high'),
'last_updated': data.get('last_updated', str(datetime.now())),
}
}

api_cache[cache_key] = {'data': artwork_data, 'timestamp': datetime.now()}
api_cache[cache_key] = {'data': data, 'timestamp': datetime.now()}
logger.info(f"Storing in cache: {cache_key}")
except Exception as e:
logger.error(f"Error making API call: {e}")
Expand All @@ -205,16 +190,8 @@ def handle_artwork(self, game_id, art_type, dimensions):
self.send_response(500)
self.end_headers()
self.wfile.write(b'Invalid response from API')
logger.error(f"Artwork for Game ID {game_id} ({art_type}) with dimensions {dimensions} not found. Error: No 'data' in response.")
return

# Log why artwork wasn't found (if any)
if not data.get('data', []):
logger.error(f"Artwork for Game ID {game_id} ({art_type}) with dimensions {dimensions} not found. Error: No artwork data.")
self.send_response(404)
self.end_headers()
self.wfile.write(b'Artwork not found')

self.send_response(200)
self.end_headers()
self.wfile.write(json.dumps(data).encode())
Expand Down

0 comments on commit ce48851

Please sign in to comment.