From d3b77fafa57bebf24acbaead74bb825a6121a347 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20S=C3=A1=20Couto?= Date: Sun, 19 Jan 2020 17:03:38 +0100 Subject: [PATCH] done. --- libgen_upload.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 libgen_upload.py diff --git a/libgen_upload.py b/libgen_upload.py new file mode 100644 index 0000000..3e93994 --- /dev/null +++ b/libgen_upload.py @@ -0,0 +1,33 @@ +import ftplib +from ftplib import FTP +import os +import fileinput + +# connect to host, default port +ftp = FTP('ftp.libgen.lc') +# user anonymous, passwd anonymous@ +ftp.login() + +#change to the directory upload +ftp.cwd('upload') + +#list all the directory +ftp.retrlines('LIST') + +#change to the directory upload of books +ftp.cwd('/upload/_books/') + +#check what is the directory we are in +ftp.pwd() + +#ask in terminal for the file that is going to be uploaded +localfile = (input("What file do you want to upload? (include extention as example.pdf): ")) + +#use the file from the input, read binary +fp = open(localfile, 'rb') +#1024 is the block size +ftp.storbinary('STOR %s' % os.path.basename(localfile), fp, 1024) + +# close file and FTP session +fp.close() +ftp.quit()