diff --git a/app/__init__.py b/app/__init__.py index bd840b8..ca09934 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -16,7 +16,7 @@ login_manager.login_view = 'auth.login' def create_app(config_name): - app = Flask(__name__) + app = Flask(__name__, static_url_path='') app.config.from_object(config[config_name]) config[config_name].init_app(app) diff --git a/app/main/views.py b/app/main/views.py index daefcbe..af29893 100644 --- a/app/main/views.py +++ b/app/main/views.py @@ -1,4 +1,5 @@ import os +from shutil import copyfile from flask import render_template, session, redirect, url_for, flash, request, current_app from . import main from .forms import Ripper @@ -16,7 +17,7 @@ def download_comic_files(soup): comic_files = [] # set the image_folder name to the title of the comic - image_folder = os.path.join(current_app.config['STASH_FOLDER'], ripper.get_title(soup)) + image_folder = os.path.join(current_app.config['DOWNLOAD_FOLDER'], ripper.get_title(soup)) print(image_folder) # append each comic link found in the bs4 response to the comic file list @@ -24,11 +25,21 @@ def download_comic_files(soup): comic_files.append(link) # download the completed comic list - ripper.download_img_links(comic_files, soup, current_app.config['STASH_FOLDER']) + ripper.download_img_links(comic_files, soup, current_app.config['DOWNLOAD_FOLDER']) # create a comic archive from all images in image_folder zipper.create_comic_archive(ripper.get_title(soup), image_folder) + # copy comic to stash + print('Copying comic to personal stash') + filename = ripper.get_title(soup) + '.cbr' + src = str(os.path.join(image_folder, filename)) + print(src) + dest = str(os.path.join(current_app.config['STASH_FOLDER'], filename)) + print(dest) + copyfile(src, dest) + + @main.route('/', methods=accepted_methods) def index(): @@ -37,6 +48,6 @@ def index(): if form.validate_on_submit(): soup = ripper.get_soup_obj(form.search.data, headers) download_comic_files(soup) - return render_template('success.html') + return render_template('success.html', title=ripper.get_title(soup)) return render_template('index.html', form=form) \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index 9465c18..73bfe2c 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -1,6 +1,11 @@

Save All Comics!

{{ form.hidden_tag() }} +

Please input a Readallcomics.com link

{{ form.search(placeholder='Comic URL, eg: https://readallcomics.com/marauders-001-2019/') }} {{ form.submit() }} -
\ No newline at end of file + +

About Saveallcomics

+

We hope you have enjoyed using Saveallcomics! We are a totally FREE project without profit.

+ +

© 2019 Saveallcomics. Some rights reserved.

\ No newline at end of file diff --git a/app/templates/success.html b/app/templates/success.html index 76fb975..3b83f76 100644 --- a/app/templates/success.html +++ b/app/templates/success.html @@ -1,2 +1,5 @@

Huzzah! It Worked!

+

Download {{ title }}

+{% set download = title + '/' + title + '.cbr' %} + « Back to Home \ No newline at end of file diff --git a/config.py b/config.py index b80437d..47d0609 100644 --- a/config.py +++ b/config.py @@ -21,6 +21,7 @@ class Config(object): 'sqlite:///' + os.path.join(basedir, 'app.db') UPLOAD_FOLDER = os.path.join(basedir, 'app/static/uploads') STASH_FOLDER = os.path.join(UPLOAD_FOLDER, 'stash') + DOWNLOAD_FOLDER = os.path.join(basedir, 'app/static/download') CLOUD_PLATFORM = 'aws' @staticmethod