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

View File

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