commit d3b77fafa57bebf24acbaead74bb825a6121a347 Author: Pedro Sá Couto Date: Sun Jan 19 17:03:38 2020 +0100 done. 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()