Skip to content

Commit

Permalink
Changed site for scraping animated stickers. Now in apng instead of gif.
Browse files Browse the repository at this point in the history
Adding automatic apng2gif program call later.
  • Loading branch information
doubleplusc committed Sep 26, 2016
1 parent 71025f5 commit 2f25ac6
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions sticker_dl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def main():
print("\nThis pack contains stickers for", pack_name)

if """"hasAnimation":true""" in pack_meta:
pack_ext = input("\nAnimated stickers available! \nEnter png, gif, or both, anything else to exit: ")
pack_ext = input("\nAnimated stickers available! \nEnter png, apng, or both, anything else to exit: ")
else:
pack_ext = input("\nOnly static stickers available! \ny to download, anything else to exit: ")

Expand All @@ -34,10 +34,10 @@ def main():
list_ids.pop() # [4] Why pop

# [3] A less ugly way of checking menu values
menu = {'gif': (get_gif,), 'png': (get_png,), 'y': (get_png,), 'both': (get_gif, get_png)} # D'OH! Originally said tuples wouldn't work, which was strange. Thanks to doing MIT problems, I realized I used (var) instead of (var,). Former will not be considered a tuple.
menu = {'apng': (get_gif,), 'png': (get_png,), 'y': (get_png,), 'both': (get_gif, get_png)} # D'OH! Originally said tuples wouldn't work, which was strange. Thanks to doing MIT problems, I realized I used (var) instead of (var,). Former will not be considered a tuple.
if pack_ext in menu:
for choice in menu[pack_ext]:
choice(list_ids, pack_name)
choice(pack_id, list_ids, pack_name)
else:
print("Nothing done. Program exiting...")
sys.exit()
Expand Down Expand Up @@ -68,19 +68,21 @@ def validate_savepath(pack_name):
return save_name


def get_gif(list_ids, pack_name):
def get_gif(pack_id, list_ids, pack_name):
pack_name = validate_savepath(pack_name)
for x in list_ids:
save_path = os.path.join(str(pack_name), str(x) + '.gif')
url = 'http://lstk.ddns.net/animg/{}.gif'.format(x)
# save_path = os.path.join(str(pack_name), str(x) + '.gif')
save_path = os.path.join(str(pack_name), str(x) + '.apng')
# url = 'http://lstk.ddns.net/animg/{}.gif'.format(x)
url = 'https://sdl-stickershop.line.naver.jp/products/0/0/1/{}/android/animation/{}.png'.format(pack_id, x)
image = requests.get(url, stream = True)
with open(save_path, 'wb') as f:
for chunk in image.iter_content(chunk_size = 10240):
if chunk:
f.write(chunk)


def get_png(list_ids, pack_name):
def get_png(pack_id, list_ids, pack_name):
pack_name = validate_savepath(pack_name)
for x in list_ids:
save_path = os.path.join(str(pack_name), str(x) + '.png')
Expand Down

0 comments on commit 2f25ac6

Please sign in to comment.