Skip to content

Commit b16c7b8

Browse files
authored
Merge pull request #1229 from dev-hato/add_ua
ameshのタイル画像取得時にUser Agentを付与する
2 parents af092b8 + 60e928d commit b16c7b8

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

library/jma_amesh.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import requests
1616
from PIL import Image, ImageEnhance
17+
from slackbot_settings import VERSION
1718

1819

1920
@dataclass
@@ -94,7 +95,15 @@ def get_tile_image(
9495
)
9596
res = []
9697
for url in urls:
97-
res.append(Image.open(BytesIO(requests.get(url).content)))
98+
res.append(
99+
Image.open(
100+
BytesIO(
101+
requests.get(
102+
url, headers={"user-agent": f"hato-bot/{VERSION}"}
103+
).content
104+
)
105+
)
106+
)
98107
dst_image = Image.new(
99108
"RGBA", (256 * (2 * around_tiles + 1), 256 * (2 * around_tiles + 1))
100109
)

0 commit comments

Comments
 (0)