1.6 Launch the SCANNER server (optional, required for automated periodic re-scanning of the collection)
Please note that the default settings specify a periodic scan start 2 times a day 12:00 and 0:00.
python3 manage.py sopds_scanner start --daemon
1.7 Starting the built-in HTTP / OPDS server
python3 manage.py sopds_server start --daemon
However, the best way is still to configure the HTTP / OPDS servers as Apache or Nginx
(entry point ./sopds/wsgi.py)
1.8 In order not to wait for the start of a scheduled scan, you can tell the sopds_scanner process about the need immediate scanning. You can do this by setting the configuration parameter SOPDS_SCAN_START_DIRECTLY = True two ways:
b) With the help of the Web-interface administration page http://<Yourserver>:8001/admin/
(FCONSTANCE -> Settings -> 1. General Options -> SOPDS_SCAN_START_DIRECTLY)
1.9 Access to information
If all previous steps were successful, then the library can be accessed by the following URLs:
> OPDS-version: http://<Your server>:8001/opds/
> HTTP-version: http://<Your server>:8001/
It should be taken into account that by default the project uses a simple sqlite3 database, which
is one-user. Therefore, until the scanning process is completed, the
previous attempts to access the server may result in an error
"A server error occurred." Please contact the administrator. "
To eliminate this problem, you need to use multi-user databases, for example MYSQL.
#### 2. Configuring the MySQL database (optional, but very desirable for increasing performance).
2.1 To work with a large number of books, it is highly advisable not to use sqlite, but to configure MySQL databases to work. MySQL is much faster than sqlite. In addition, SQLite is a single-user database, i.e. during scanning access to a DB it will be impossible.
To work with the Mysql database on different systems, you may need to install additional packages:
UBUNTU: sudo apt-get install python3-mysqldb
CENTOS-7: pip3 install mysqlclient
Next, you must first create a database "sopds" and a user with the necessary rights in the MySQL database,
for example, as follows:
mysql -uroot -proot_pass mysql
mysql> create database if not exists sopds default charset = utf8;
mysql> grant all on sopds. * to 'sopds' @ 'localhost' identified by 'sopds';
mysql> commit;
mysql> ^ C
2.2 Then, in the configuration file, you need to comment out the connection strings to the sqlite database and uncomment the connection string to the Mysql database:
The above MySQL configuration uses MyISAM as the database engine, which works on most versions of MySQL or MariaDB. However, if you use a relatively new version of Mysql (MariaDB> = 10.2.2, Mysql> = 5.7.9), then you can use the more modern InnoDB engine. It is somewhat faster and supports transactions, which will positively affect the integrity of the database. (On older versions of MySQL, there are problems with it because of restrictions on the maximum length of indexes.) Thus, if you have a modern version of MySQL (MariaDB> = 10.2.2, Mysql> = 5.7.9), then in the Mysql database settings, simply use the following instead of the above OPTIONS parameters:
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED
"""
}
2.5 Further it is necessary to re-execute points 1.3 - 1.8 of this instruction in order to initialize and fill the newly created database However, if you have already started the HTTP/OPDS server and the SCANNER server, you must first stop them:
python3 manage.py sopds_server stop
python3 manage.py sopds_scanner stop
#### 3. Configuring the PostgreSQL database (optional, a good option for using the SimpleOPDS program).
3.1 PostgreSQL is a good way to use SimpleOPDS.
To use PostgreSQL, it is necessary to install this database and configure it (for a detailed description, see the Internet, for example: http://alexxkn.ru/node/42 or here: http://www.fight.org.ua/database/ install_posqgresql_ubuntu.html):
editing the hba.conf file, you need to fix the following lines:
- local all all peer
- host all all 127.0.0.1/32 ident
+ local all all md5
+ host all all 127.0.0.1/32 md5
To work with the PostgreSQL database, you probably need to install an additional package of psycopg2:
pip3 install psycopg2
Next, you must first create a database "sopds" and a user with the necessary rights in the PostgreSQL database, for example, as follows:
psql -U postgres
Password for user postgres: *****
postgres=# create role sopds with password 'sopds' login;
postgres=# create database sopds with owner sopds;
postgres=# \q
3.2 Next in the configuration file, you need to comment out the connection strings to the sqlite database and decompress it accordingly the connection string to the PostgreSQL database:
3.4 Next, it is necessary to re-execute points 1.3 - 1.8 of this instruction in order to initialize and fill the newly created database However, if you have already started the HTTP/OPDS server and the SCANNER server, you must first stop them:
python3 manage.py sopds_server stop
python3 manage.py sopds_scanner stop
#### 4. Setting the conversion of fb2 to EPUB or MOBI (optionally, you can not configure it)
- First you need to download the latest version of the fb2toepub converter from the link above (the current one is already in the project) unfortunately the converter is not perfect and not all books can be converted, but most still converted
- Further, you need to copy the archive to the folder **./convert/fb2toepub** and unzip
- Next, we compile the project with the make command, as a result, the executable file fb2toepub appears in the unix_dist folder
- Use the web interface of the administrator or the following console commands to specify the path to this converter:
4.3 Converter fb2conv (converting to epub and mobi) http://www.the-ebook.org/forum/viewtopic.php?t=28447
- It is necessary to install python 2.7 and the packages lxml, cssutils:
yum install python
yum install python-lxml
yum install python-cssutils
- download the latest version of the converter from the link above (the current one is already in the fb2conv directory of the project)
- download the KindleGen utility from the Amazon website http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000234621 (the current version of the utility is already in the fb2conv directory of the project)
- copy the project archive to **./convert/fb2conv** (There are already shell scripts for starting the converter) and unzip it
- To convert to MOBI you need to archive the KindleGen utility in the directory with the converter and unzip it
- Use the web-based administrator interface or the following console commands to specify paths to the corresponding scripts:
**SOPDS_DOUBLES_HIDE** - Hides found duplicates in book issues.
(by default SOPDS_DOUBLES_HIDE = True)
**SOPDS_FB2SAX** - The program can extract metadata from FB2 by two parsers
- FB2sax is the regular parser used in SOPDS from version 0.01, this parser is faster, and retrieves metadata even from invalid FB2 files
- FB2xpath - appeared in version 0.42, works less often, does not tolerate invalid FB2
(by default SOPDS_FB2SAX = True)
**SOPDS_COVER_SHOW** - a way to show skins (False - do not show, True - extract covers on the fly and show).
(by default SOPDS COVER_SHOW = True)
**SOPDS_ZIPSCAN** - Configures the scanning of ZIP archives.
(by default SOPDS_ZIPSCAN = True)
**SOPDS_ZIPCODEPAGE** - Specify which encoding for file names is used in ZIP archives. Available encodings: cp437, cp866, cp1251, utf-8. The default encoding is cp437. Since there is no information about the encoding in which the file names are located in the ZIP archive, it is not possible to automatically determine the correct encoding for filenames, so cyrillic encodings should use cp866 encoding in order for Cyrillic file names to not look like croaks.
(default is SOPDS_ZIPCODEPAGE = "cp866")
**SOPDS_INPX_ENABLE** - If True, if an INPX file is found in the directory, the scanner does not scan its contents with the sub-htag, but loads the data from the found INPX file. The scanner believes that the archives of books themselves are located in the same directory. Those. INPX-file should be located in the folder with the archives of books.
However, please note that using data from INPX will result in the absence of annotation in the library. INPX annotations are not present !!!
(by default SOPDS_INPX_ENABLE = True)
**SOPDS_INPX_SKIP_UNCHANGED** - If True, the scanner skips re-scanning if the size of INPX has not changed.
(by default SOPDS_INPX_SKIP_UNCHANGED = True)
**SOPDS_INPX_TEST_ZIP** - If True, the scanner tries to find the archive described in the INPX. If an archive is not found, the scanner will not add the data from INPX connected to it to the database, if SOPDS_INPX_TEST_ZIP = False, then the scanner does not perform any checks, but simply adds data from INPX to the database. It's much faster.
(by default SOPDS_INPX_TEST_ZIP = False)
**SOPDS_INPX_TEST_FILES** - If True, the scanner tries to find the specific file with the book described in INPX (already inside the archives). If a file is not found, the scanner will not add this book to the database, if INPX_TEST_FILES = False, then the scanner does not perform any checks, but simply adds a book from INPX to the database. It's much faster.
(by default SOPDS_TEST_FILES = False)
**SOPDS_DELETE_LOGICAL** - True will result in the fact that if the scanner detects that the book has been deleted, the entry in the database about this book will be deleted logically (avail = 0). If the value is False, then there will be a physical deletion of such records from the database. So far only SOPDS_DELETE_LOGICAL = False.
(by default SOPDS_DELETE_LOGICAL = False)
**SOPDS_SPLITITEMS** - Sets when the number of elements in the group is reached - the group will "expand". For issuing "By Title", "By Authors", "By Series".
(the default is SOPDS_SPLITITEMS = 300)
**SOPDS_MAXITEMS** - The number of results to be displayed per page.
(the default is SOPDS_MAXITEMS = 60)
**SOPDS_FB2TOEPUB** and **SOPDS_FB2TOMOBI** set the paths to the programs - converters from FB2 to EPUB and MOBI /
(by default SOPDS_FB2TOEPUB = "")
(by default SOPDS_FB2TOMOBI = "")
**SOPDS_TEMP_DIR** specifies the path to the temporary directory, which is used to copy the original and the conversion result.
**SOPDS_TITLE_AS_FILENAME** - If True, when downloading instead of the original file name, the book will produce a transliteration of the title of the book.
(by default SOPDS_TITLE_AS_FILENAME = True)
**SOPDS_ALPHABET_MENU** - Includes an additional menu for selecting the alphabet.
(by default SOPDS_ALPHABET_MENU = True)
**SOPDS_NOCOVER_PATH** - A cover file that will be displayed for books without covers.
Parameters **SOPDS_SCAN_SHED_XXX** set the values of the template, to periodically scan the collection of books using ** manage.py sopds_scanner start **. Possible values can be found on the following page: # https://apscheduler.readthedocs.io/en/latest/modules/triggers/cron.html#module-apscheduler.triggers.cron
Changes to the following parameters via the Web interface or the command line are checked by the sopds_scanner process every 10 minutes.
In case of detection of changes, sopds_scanner automatically makes the appropriate changes to the scheduler.
(default is SOPDS_SCAN_SHED_MIN = '0')
(the default is SOPDS_SCAN_SHED_HOUR = '0,12')
(default is SOPDS_SCAN_SHED_DAY = '*')
(default is SOPDS_SCAN_SHED_DOW = '*')
**SOPDS_SCAN_START_DIRECTLY** - setting this parameter to True will cause the next check of the sopds_scanner flag (every 10 minutes)
an extraordinary scan of the collection will be launched, and the specified flag will again be reset to False.