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