diff --git a/sticker_dl.py b/sticker_dl.py index 99eeff5..e620480 100644 --- a/sticker_dl.py +++ b/sticker_dl.py @@ -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: ") @@ -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() @@ -68,11 +68,13 @@ 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): @@ -80,7 +82,7 @@ def get_gif(list_ids, pack_name): 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')