Works better on windows now
This commit is contained in:
MrTyton 2021-07-01 07:16:34 -04:00
parent c94ad354ab
commit a16654503d
2 changed files with 15 additions and 16 deletions

View File

@ -7,11 +7,11 @@ from optparse import OptionParser
import re
from configparser import ConfigParser
from tempfile import mkdtemp
from shutil import rmtree
from shutil import rmtree, copyfile
import socket
from time import strftime, localtime
import os
import errno
from errno import ENOENT
from multiprocessing import Pool
@ -73,7 +73,7 @@ def touch(fname, times=None):
utime(fname, times)
url_parsers = [(re.compile('(fanfiction.net/s/\d*)/?.*'), "www."), #ffnet
url_parsers = [(re.compile('(fanfiction.net/s/\d*/?).*'), "www."), #ffnet
(re.compile('(archiveofourown.org/works/\d*)/?.*'), ""), #ao3
(re.compile('(fictionpress.com/s/\d*)/?.*'), ""), #fictionpress
(re.compile('(royalroad.com/fiction/\d*)/?.*'), ""), #royalroad
@ -149,15 +149,10 @@ def downloader(args):
# story is not in calibre
cur = url
moving = 'cd "{}" && '.format(loc)
res = check_output(
'cp personal.ini {}/personal.ini'.format(loc),
shell=True,
stderr=STDOUT,
stdin=PIPE,
).decode('utf-8')
output += log('\tRunning: {}fanficfare -u "{}" --update-cover'.format(
copyfile("personal.ini", "{}/personal.ini".format(loc))
output += log('\tRunning: {}python -m fanficfare.cli -u "{}" --update-cover --non-interactive'.format(
moving, cur), 'BLUE', live)
res = check_output('{}fanficfare -u "{}" --update-cover'.format(
res = check_output('{}python -m fanficfare.cli -u "{}" --update-cover'.format(
moving, cur), shell=True, stderr=STDOUT, stdin=PIPE).decode('utf-8')
check_regexes(res)
if chapter_difference.search(res) or more_chapters.search(res):
@ -167,7 +162,7 @@ def downloader(args):
if line:
output += log("\t\t{}".format(line), 'WARNING', live)
res = check_output(
'{}fanficfare -u "{}" --force --update-cover'.format(
'{}python -m fanficfare.cli -u "{}" --force --update-cover --non-interactive'.format(
moving, cur), shell=True, stderr=STDOUT, stdin=PIPE).decode('utf-8')
check_regexes(res)
cur = get_files(loc, '.epub', True)[0]
@ -248,8 +243,8 @@ def main(user, password, server, label, inout_file, path, live):
try:
with open(devnull, 'w') as nullout:
call(['calibredb'], stdout=nullout, stderr=nullout)
except OSError:
if errno == ENOENT:
except OSError as e:
if e.errno == errno.ENOENT:
log("Calibredb is not installed on this system. Cannot search the calibre library or update it.", 'FAIL')
return

View File

@ -1,6 +1,8 @@
from io import StringIO
import re
from subprocess import check_output, STDOUT
from time import sleep
import ntpath
from os import utime
from os.path import join
@ -63,7 +65,7 @@ def main(options):
for line in buf.readlines():
r = searcher(line)
if r:
story = r.group(1).strip()
story = ntpath.basename(r.group(1).strip())
stripper = True
for notify in enable_notifications(options):
notify.send_notification("New Fanfiction Download", story)
@ -180,4 +182,6 @@ if __name__ == "__main__":
raise ValueError(
"Can't strip tags from calibre library without a library location.")
while(True):
main(options)
sleep(60)