Added ability to copy books to shared drive
This commit is contained in:
parent
edabd932de
commit
71c1086e05
Binary file not shown.
|
@ -1,5 +1,13 @@
|
||||||
from libgen_api import *
|
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):
|
def searchBook(book, unattended=False):
|
||||||
s = LibgenSearch()
|
s = LibgenSearch()
|
||||||
|
@ -36,6 +44,8 @@ def downloadBook(bookDict):
|
||||||
r = requests.get(bookDict['link'], allow_redirects=True)
|
r = requests.get(bookDict['link'], allow_redirects=True)
|
||||||
open(bookDict['title']+'.epub', 'wb').write(r.content)
|
open(bookDict['title']+'.epub', 'wb').write(r.content)
|
||||||
print('Book Downloaded!')
|
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):
|
def main(argv):
|
||||||
|
|
2
config.ini
Normal file
2
config.ini
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[data]
|
||||||
|
folder_location = z:\books\
|
|
@ -1,2 +1,3 @@
|
||||||
libgen_api==1.0.0
|
libgen_api==1.0.0
|
||||||
nicegui==1.2.2
|
nicegui==1.2.2
|
||||||
|
configparser=3.11.2
|
Loading…
Reference in New Issue
Block a user