Upgrade to python 3
This commit is contained in:
88
Linedl.py
88
Linedl.py
@@ -1,75 +1,75 @@
|
||||
import sys
|
||||
import os.path
|
||||
import urllib
|
||||
import urllib.request
|
||||
import zipfile
|
||||
import json
|
||||
|
||||
animated = False
|
||||
id = ""
|
||||
sticker_set_id = ""
|
||||
|
||||
if len(sys.argv)>1:
|
||||
id = sys.argv[1]
|
||||
if len(sys.argv)==3: animated = True
|
||||
if len(sys.argv) > 1:
|
||||
sticker_set_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 ""
|
||||
sticker_set_id = input("ID: ")
|
||||
tmp = input("Animated? (y/N): ")
|
||||
if tmp.lower() == "y": animated = True
|
||||
print("")
|
||||
|
||||
#---------------------------
|
||||
# ---------------------------
|
||||
|
||||
print "ID:", id
|
||||
print "Animated:", animated
|
||||
print ""
|
||||
print("ID:", sticker_set_id)
|
||||
print("Animated:", animated)
|
||||
print("")
|
||||
|
||||
#---------------------------
|
||||
# ---------------------------
|
||||
|
||||
if os.path.exists(id+".zip"):
|
||||
print id+".zip already exists, exitting."
|
||||
if os.path.exists(sticker_set_id + ".zip"):
|
||||
print(sticker_set_id + ".zip already exists, exitting.")
|
||||
exit()
|
||||
if os.path.exists(id):
|
||||
print id+" already exists, exitting."
|
||||
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/"+id+ending
|
||||
if animated: ending = "/iphone/stickerpack@2x.zip"
|
||||
url = "http://dl.stickershop.line.naver.jp/products/0/0/1/" + sticker_set_id + ending
|
||||
|
||||
#---------------------------
|
||||
# ---------------------------
|
||||
|
||||
testfile = urllib.URLopener()
|
||||
print "Downloading", url, "to", id+".zip"
|
||||
testfile.retrieve(url, id+".zip")
|
||||
print "Finished Downloading"
|
||||
print ""
|
||||
print("Downloading", url, "to", sticker_set_id + ".zip")
|
||||
urllib.request.urlretrieve(url, sticker_set_id + ".zip")
|
||||
print("Finished Downloading")
|
||||
print("")
|
||||
|
||||
#---------------------------
|
||||
# ---------------------------
|
||||
|
||||
print "Extracting", id+".zip"
|
||||
zip_ref = zipfile.ZipFile(id+".zip", 'r')
|
||||
zip_ref.extractall(id)
|
||||
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(id+".zip")
|
||||
print "Extract complete, deleting", id+".zip"
|
||||
print ""
|
||||
os.remove(sticker_set_id + ".zip")
|
||||
print("Extract complete, deleting", sticker_set_id + ".zip")
|
||||
print("")
|
||||
|
||||
#---------------------------
|
||||
# ---------------------------
|
||||
|
||||
print "Cleanning up"
|
||||
data = json.load(open(id+"/productInfo.meta"))
|
||||
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(id+"/productInfo.meta")
|
||||
for (dirpaths, dirnames, filenames) in os.walk(id):
|
||||
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(id+"/"+filename)
|
||||
os.remove(sticker_set_id + "/" + filename)
|
||||
|
||||
if os.path.exists(enPackageName):
|
||||
print "\""+enPackageName+"\"", "already exists, not renaming the new-download"
|
||||
print("\"" + enPackageName + "\"", "already exists, not renaming the new-download")
|
||||
else:
|
||||
print "Renaming to", "\""+enPackageName+"\""
|
||||
os.rename(id, enPackageName)
|
||||
print "Done"
|
||||
print("Renaming to", "\"" + enPackageName + "\"")
|
||||
os.rename(sticker_set_id, enPackageName)
|
||||
print("Done")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# LineStickerDownloader
|
||||
|
||||
Currently, only tested on Python 2.7 on Windows environment.
|
||||
Currently, only tested on Python 3.7 on Windows environment.
|
||||
Downloading according to [this guide](http://blog.ldjb.uk/post/120266420762/full-resolution-line-sticker-images).
|
||||
|
||||
Usage
|
||||
|
||||
Reference in New Issue
Block a user