Initial version
This commit is contained in:
75
Linedl.py
Normal file
75
Linedl.py
Normal file
@@ -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"
|
||||
28
README.md
28
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 <id>`
|
||||
Download non-animated sticker with the provided ID.
|
||||
|
||||
`Linedl.py <id> <anyText>`
|
||||
Download animated sticker with the provided ID.
|
||||
|
||||
|
||||
Operation
|
||||
----
|
||||
If `<id>/` or `<id>.zip` already exists, the program will just exit.
|
||||
|
||||
Download the sticker to `<id>.zip`.
|
||||
Extract the zip to `<id>/`.
|
||||
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 `<id>/` directort to `<stickerName>/`.
|
||||
Reference in New Issue
Block a user