User:Pedro Sá Couto/TW/Publish

From XPUB & Lens-Based wiki

STEPS

Library Genesis files upload was developed in 2 ways:

1. Uploading the file through ftp
2. Leaving the file in a url

WHY?

(1) In the begging of Tactical Watermarks I was not relying on the staff from Library Genesis to upload files to the library.
With the python library ftplib I was able to leave the files in a server directory from LibGen where they could afterwards republish the titles.
(2) Once the staff from Library Genesis stopped supporting the upload through FTP I had to arrange a different way to do so. Currently, all the books are moved to the directory hub.xpub.nl/watermarks/share/ where they can WGET all the process files outputed from Tactical Watermarks.

1. DEPRICATED FTP UPLOAD

import ftplib
from ftplib import FTP
import os
import fileinput
import glob

# 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()

#read the file
file = glob.glob('/Users/PSC/Desktop/book/*.pdf')
localfile = (file[0])

#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()

2. CURRENT UPLOAD

NGINX CONFIG

location /share/ {
	root /var/www;
	autoindex on;
	autoindex_exact_size off;
	autoindex_localtime on;
}