76 lines
2.1 KiB
Python
76 lines
2.1 KiB
Python
import sys
|
|
import os.path
|
|
import urllib.request
|
|
import zipfile
|
|
import json
|
|
|
|
animated = False
|
|
sticker_set_id = ""
|
|
|
|
if len(sys.argv) > 1:
|
|
sticker_set_id = sys.argv[1]
|
|
if len(sys.argv) == 3: animated = True
|
|
else:
|
|
sticker_set_id = input("ID: ")
|
|
tmp = input("Animated? (y/N): ")
|
|
if tmp.lower() == "y": animated = True
|
|
print("")
|
|
|
|
# ---------------------------
|
|
|
|
print("ID:", sticker_set_id)
|
|
print("Animated:", animated)
|
|
print("")
|
|
|
|
# ---------------------------
|
|
|
|
if os.path.exists(sticker_set_id + ".zip"):
|
|
print(sticker_set_id + ".zip already exists, exitting.")
|
|
exit()
|
|
if os.path.exists(sticker_set_id):
|
|
print(sticker_set_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/" + sticker_set_id + ending
|
|
|
|
# ---------------------------
|
|
|
|
print("Downloading", url, "to", sticker_set_id + ".zip")
|
|
urllib.request.urlretrieve(url, sticker_set_id + ".zip")
|
|
print("Finished Downloading")
|
|
print("")
|
|
|
|
# ---------------------------
|
|
|
|
print("Extracting", sticker_set_id + ".zip")
|
|
zip_ref = zipfile.ZipFile(sticker_set_id + ".zip", 'r')
|
|
zip_ref.extractall(sticker_set_id)
|
|
zip_ref.close()
|
|
os.remove(sticker_set_id + ".zip")
|
|
print("Extract complete, deleting", sticker_set_id + ".zip")
|
|
print("")
|
|
|
|
# ---------------------------
|
|
|
|
print("Cleanning up")
|
|
with open(sticker_set_id + "/productInfo.meta", encoding='UTF-8') as f:
|
|
data = json.load(f)
|
|
enPackageName = data["title"]["en"]
|
|
|
|
os.remove(sticker_set_id + "/productInfo.meta")
|
|
for (dirpaths, dirnames, filenames) in os.walk(sticker_set_id):
|
|
for filename in filenames:
|
|
if "_key" in filename:
|
|
os.remove(sticker_set_id + "/" + filename)
|
|
|
|
if os.path.exists(enPackageName):
|
|
print("\"" + enPackageName + "\"", "already exists, not renaming the new-download")
|
|
else:
|
|
print("Renaming to", "\"" + enPackageName + "\"")
|
|
os.rename(sticker_set_id, enPackageName)
|
|
print("Done")
|