Skip to content

Instantly share code, notes, and snippets.

@LeonLenclos
Last active January 6, 2022 09:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeonLenclos/46ab63260cce4e44d76c360f488d324d to your computer and use it in GitHub Desktop.
Save LeonLenclos/46ab63260cce4e44d76c360f488d324d to your computer and use it in GitHub Desktop.
Download drawings from scri.ch
"""
# 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