mirror of
https://github.com/Leseratte10/acsm-calibre-plugin.git
synced 2024-12-23 01:34:36 +06:00
Make fulfill.py accept file names
This commit is contained in:
parent
222dc1fe35
commit
fa6ad1da5d
@ -41,7 +41,7 @@ def download(replyData):
|
|||||||
|
|
||||||
if (rights_xml_str is None):
|
if (rights_xml_str is None):
|
||||||
print("Building rights.xml failed!")
|
print("Building rights.xml failed!")
|
||||||
exit(1)
|
return False
|
||||||
|
|
||||||
book_name = None
|
book_name = None
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ def download(replyData):
|
|||||||
|
|
||||||
if (ret != 200):
|
if (ret != 200):
|
||||||
print("Download failed with error %d" % (ret))
|
print("Download failed with error %d" % (ret))
|
||||||
exit()
|
return False
|
||||||
|
|
||||||
with open(filename_tmp, "rb") as f:
|
with open(filename_tmp, "rb") as f:
|
||||||
book_content = f.read(10)
|
book_content = f.read(10)
|
||||||
@ -89,7 +89,7 @@ def download(replyData):
|
|||||||
zf.close()
|
zf.close()
|
||||||
|
|
||||||
print("File successfully fulfilled to " + filename)
|
print("File successfully fulfilled to " + filename)
|
||||||
exit(0)
|
return True
|
||||||
|
|
||||||
elif filetype == ".pdf":
|
elif filetype == ".pdf":
|
||||||
print("Successfully downloaded PDF, patching encryption ...")
|
print("Successfully downloaded PDF, patching encryption ...")
|
||||||
@ -104,24 +104,36 @@ def download(replyData):
|
|||||||
os.remove("tmp_" + filename)
|
os.remove("tmp_" + filename)
|
||||||
if (ret):
|
if (ret):
|
||||||
print("File successfully fulfilled to " + filename)
|
print("File successfully fulfilled to " + filename)
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
print("Errors occurred while patching " + filename)
|
print("Errors occurred while patching " + filename)
|
||||||
exit(1)
|
return False
|
||||||
exit(0)
|
|
||||||
else:
|
else:
|
||||||
print("Error: Weird filetype")
|
print("Error: Weird filetype")
|
||||||
exit(1)
|
return False
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print("Fulfilling book ...")
|
|
||||||
success, replyData = fulfill("URLLink.acsm")
|
if len(sys.argv) < 2:
|
||||||
if (success is False):
|
files = [ "URLLink.acsm" ]
|
||||||
print("Hey, that didn't work!")
|
|
||||||
print(replyData)
|
|
||||||
else:
|
else:
|
||||||
print("Downloading book ...")
|
files = sys.argv[1:]
|
||||||
download(replyData)
|
|
||||||
|
for file in files:
|
||||||
|
|
||||||
|
print("Fulfilling book '" + file + "' ...")
|
||||||
|
success, replyData = fulfill(file)
|
||||||
|
if (success is False):
|
||||||
|
print("Hey, that didn't work!")
|
||||||
|
print(replyData)
|
||||||
|
else:
|
||||||
|
print("Downloading book '" + file + "' ...")
|
||||||
|
success = download(replyData)
|
||||||
|
if (success is False):
|
||||||
|
print("That didn't work!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user