Skip to content

Commit

Permalink
Preparations for other regions
Browse files Browse the repository at this point in the history
  • Loading branch information
npanuhin committed Dec 17, 2023
1 parent 796684f commit f4c9646
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,9 @@ One API file consists of an array of image data:


[^1]: These files are not a typical [API](https://en.wikipedia.org/wiki/API), but they are used to retrieve all valuable information. In some sence they are the Interface of my Application (though not really a Programming Interface)

### Copyright

All images are property of their respective owners (Microsoft, Getty Images, etc.), see the `copyright` field for more details.

Microsoft's official statement regarding wallpaper downloads is: "**Use of this image is restricted to wallpaper only.**"
16 changes: 14 additions & 2 deletions src/Region.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ def __init__(self, region):
self.path = mkpath(os.path.dirname(__file__), '../api', self.country.upper())
self.api_path = mkpath(self.path, self.country.lower() + '.json')

os.makedirs(self.path, exist_ok=True)

self.gcloud_images_path = mkpath(self.country.upper(), 'images')

@property
def mkt(self):
return f'{self.lang}-{self.country.upper()}'

def read_api(self) -> str:
if not os.path.exists(self.api_path):
return []

with open(self.api_path, 'r', encoding='utf-8') as file:
return json.load(file)

Expand All @@ -28,6 +33,13 @@ def __repr__(self):
return f'Region({self.mkt})'


# ------------------------------------------------------- Regions ------------------------------------------------------

# Canada - English: en-ca | Canada - French: fr-ca | China: zh-cn | China - English: en-cn | France: fr-fr
# Germany: de-de | India: en-in | Japan: ja-jp | United Kingdom: en-gb | United States: en-us | International: en-ww

# REGIONS = ['AU', 'CA', 'CN', 'DE', 'FR', 'IN', 'JP', 'ES', 'GB', 'US']
# REGIONS = ['en-ca', 'fr-ca', 'zh-cn', 'en-cn', 'fr-fr', 'de-de', 'en-in', 'ja-jp', 'en-gb', 'en-us', 'en-ww']
REGIONS = list(map(Region, ['en-US']))
# REGIONS = ['en-CA', 'fr-CA', 'zh-CN', 'en-CN', 'fr-FR', 'de-DE', 'en-IN', 'ja-JP', 'en-GB', 'en-US']
REGIONS = ['en-US']

REGIONS = list(map(Region, REGIONS))
1 change: 1 addition & 0 deletions src/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def update(region: Region):
region.write_api(
postprocess_api(list(api_by_date.values()))
)
print()


def update_all():
Expand Down

0 comments on commit f4c9646

Please sign in to comment.