Created
January 7, 2020 03:58
-
-
Save samyok/e9569eb5146c1e533ee81605cf7c34cd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
import urllib.request | |
from PIL import Image | |
# for x in range(-225, -228): | |
# for y in range(85, 90): | |
# https://map.smpearth.com/tiles/world_the_end/flat/-8_2/z_-227_87.png | |
def second_only(i): | |
return i[1] | |
def parseImage(fn, rcs): | |
im = Image.open(fn) | |
colors = im.getcolors(im.size[0] * im.size[1]) | |
if colors: | |
colors = sorted(colors, reverse=True) | |
mapped_colors = list(map(second_only, colors)) | |
if (36, 27, 36, 255) in mapped_colors: | |
print(rcs, "found end city") | |
else: | |
print("chunk not loaded yet") | |
for x in range(-250, 0, 2): | |
for y in range(0, 100, 2): | |
coords = str(x) + '_' + str(y) | |
rcs = str(x * 32) + " " + str(y * -32) | |
print("checking coords", rcs) | |
filename = 'map/' + coords + '.png' | |
if os.path.isfile(filename): | |
parseImage(filename, rcs) | |
else: | |
f = open(filename, 'wb') | |
url = 'https://map.smpearth.com/tiles/world_the_end/flat/-8_2/z_' + coords + '.png' | |
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (twitter: @eggsthedev - scraping for moondust hehe)"}) | |
f.write(urllib.request.urlopen(req).read()) | |
f.close() | |
parseImage(filename, rcs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment