From d844bdf5a20d417d7a39a04f2db53df383cce530 Mon Sep 17 00:00:00 2001 From: Pitchaya Boonsarngsuk Date: Thu, 23 Nov 2017 00:21:55 +0000 Subject: [PATCH] Initial version --- Linedl.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 28 +++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 Linedl.py diff --git a/Linedl.py b/Linedl.py new file mode 100644 index 0000000..ffeddf2 --- /dev/null +++ b/Linedl.py @@ -0,0 +1,75 @@ +import sys +import os.path +import urllib +import zipfile +import json + +animated = False +id = "" + +if len(sys.argv)>1: + id = sys.argv[1] + if len(sys.argv)==3: animated = True +else: + id = raw_input("ID: ") + tmp = raw_input("Animated? (y/N): ") + if(tmp.lower()=="y"): animated = True +print "" + +#--------------------------- + +print "ID:", id +print "Animated:", animated +print "" + +#--------------------------- + +if os.path.exists(id+".zip"): + print id+".zip already exists, exitting." + exit() +if os.path.exists(id): + print id+" already exists, exitting." + exit() + +#--------------------------- + +ending = "/iphone/stickers@2x.zip" +if(animated): ending = "/iphone/stickerpack@2x.zip" +url = "http://dl.stickershop.line.naver.jp/products/0/0/1/"+id+ending + +#--------------------------- + +testfile = urllib.URLopener() +print "Downloading", url, "to", id+".zip" +testfile.retrieve(url, id+".zip") +print "Finished Downloading" +print "" + +#--------------------------- + +print "Extracting", id+".zip" +zip_ref = zipfile.ZipFile(id+".zip", 'r') +zip_ref.extractall(id) +zip_ref.close() +os.remove(id+".zip") +print "Extract complete, deleting", id+".zip" +print "" + +#--------------------------- + +print "Cleanning up" +data = json.load(open(id+"/productInfo.meta")) +enPackageName = data["title"]["en"] + +os.remove(id+"/productInfo.meta") +for (dirpaths, dirnames, filenames) in os.walk(id): + for filename in filenames: + if "_key" in filename: + os.remove(id+"/"+filename) + +if os.path.exists(enPackageName): + print "\""+enPackageName+"\"", "already exists, not renaming the new-download" +else: + print "Renaming to", "\""+enPackageName+"\"" + os.rename(id, enPackageName) +print "Done" \ No newline at end of file diff --git a/README.md b/README.md index 525d913..d690e21 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,30 @@ # LineStickerDownloader +Currently, only tested on Python 2.7 on Windows environment. +Downloading according to [this guide](http://blog.ldjb.uk/post/120266420762/full-resolution-line-sticker-images). + +Usage +----- +`Linedl.py` +Interactively ask the sticker set ID and weather or not to treat the sticker as Animated. +For `Animated? (y/N): `, only `y` or `Y` input is treated as `True`. All other input, including just pressing empty, will be treated as a `False` + +`Linedl.py ` +Download non-animated sticker with the provided ID. + +`Linedl.py ` +Download animated sticker with the provided ID. + + + Operation +---- +If `/` or `.zip` already exists, the program will just exit. + +Download the sticker to `.zip`. +Extract the zip to `/`. +Delete the zip. + +_Note: The part after this is only tested with non-animated sticker pack._ +Read the metadata for Sticker name. +Delete the metadata file and the lower-resolution `_key` copy of each sticker. +Rename `/` directort to `/`. \ No newline at end of file