Last active
January 6, 2022 09:03
-
-
Save LeonLenclos/46ab63260cce4e44d76c360f488d324d to your computer and use it in GitHub Desktop.
Download drawings from scri.ch
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
""" | |
# Run this script to download scri.ch drawings. | |
python3 scrich-dl.py | |
# You can then put all the drawing to the same size with imagemagick. | |
for f in *.png; do convert $f -gravity CENTER -extent 1920x1080 $f; done; | |
# And make a video from them with ffmpeg. | |
ffmpeg -r 25 -f image2 -s 1920x1080 -pattern_type glob -i "*.png" -vcodec libx264 -crf 25 -pix_fmt yuv420p anim.mp4 | |
""" | |
import urllib.request | |
http_errors_allowed = 100 | |
i = 0 | |
def dec_to_base(num, base): | |
base_num = "" | |
while num>0: | |
dig = int(num%base) | |
if dig<10: | |
base_num += str(dig) | |
else: | |
base_num += chr(ord('a')+dig-10) | |
num //= base | |
base_num = base_num[::-1] | |
return base_num | |
while http_errors_allowed > 0: | |
i+=1 | |
url = 'http://scri.ch/{}.png'.format(dec_to_base(i, 36)) | |
path = '{:05d}.png'.format(i) | |
print('download {} to {}'.format(url, path)) | |
try: | |
urllib.request.urlretrieve(url, path) | |
except urllib.error.HTTPError as e: | |
print('HTTP error', e) | |
http_errors_allowed -= 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment