Skip to content

Commit

Permalink
fix(author-update): 🐛 use preferred region when searching updating au…
Browse files Browse the repository at this point in the history
…thors

fixes #113
  • Loading branch information
djdembeck committed Aug 12, 2024
1 parent 56d8b65 commit 743870b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Contents/Code/update_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def build_url(self):
Builds the URL for the API request.
"""
# Get the current region
self.region_override = self.region if self.region else self.prefs['region']
self.region_override = self.get_preferred_region()
# Set the region helper
region_helper = RegionTool(
region=self.region_override, content_type=self.content_type, id=self.extract_asin_from_id())
Expand Down Expand Up @@ -144,12 +144,23 @@ def extract_region_from_id(self):
log.debug('Extracted region from ASIN: ' + region)
except IndexError:
log.info('No region found in ID, using default region.')
region = 'us'
region = self.get_preferred_region()
# Save the region to the ID
self.metadata.id = self.metadata.id + '_' + region
# Set region and ASIN
return region

def get_preferred_region(self):
"""
Get the preferred region from class or preferences.
"""
try:
region = self.region
except AttributeError:
region = self.prefs['region']
log.info('Preferred region: ' + region)
return region

def log_update_metadata(self):
"""
Writes metadata information to log.
Expand Down

0 comments on commit 743870b

Please sign in to comment.