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"
|
||||
Reference in New Issue
Block a user