Added ability to copy books to shared drive

This commit is contained in:
kassarole 2023-03-28 22:10:40 -04:00
parent edabd932de
commit 71c1086e05
4 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,13 @@
from libgen_api import *
import requests, sys, getopt
import requests, sys, getopt, configparser, shutil, os
config = configparser.ConfigParser()
try:
config.read('config.ini')
except Exception as e:
print(e)
print('Config file not found. Please ensure conf.ini is in the same \
location as bookrequest.py')
def searchBook(book, unattended=False):
s = LibgenSearch()
@ -36,6 +44,8 @@ def downloadBook(bookDict):
r = requests.get(bookDict['link'], allow_redirects=True)
open(bookDict['title']+'.epub', 'wb').write(r.content)
print('Book Downloaded!')
os.makedirs(config['data']['folder_location'] + '\\' + bookDict['author'])
shutil.move(bookDict['title']+'.epub', config['data']['folder_location'] + '\\' + bookDict['author'] + '\\' + bookDict['title']+'.epub')
def main(argv):

2
config.ini Normal file
View File

@ -0,0 +1,2 @@
[data]
folder_location = z:\books\

View File

@ -1,2 +1,3 @@
libgen_api==1.0.0
nicegui==1.2.2
configparser=3.11.2