separate downloads and personal stash
This commit is contained in:
@@ -16,7 +16,7 @@ login_manager.login_view = 'auth.login'
|
|||||||
|
|
||||||
|
|
||||||
def create_app(config_name):
|
def create_app(config_name):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__, static_url_path='')
|
||||||
app.config.from_object(config[config_name])
|
app.config.from_object(config[config_name])
|
||||||
config[config_name].init_app(app)
|
config[config_name].init_app(app)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
from shutil import copyfile
|
||||||
from flask import render_template, session, redirect, url_for, flash, request, current_app
|
from flask import render_template, session, redirect, url_for, flash, request, current_app
|
||||||
from . import main
|
from . import main
|
||||||
from .forms import Ripper
|
from .forms import Ripper
|
||||||
@@ -16,7 +17,7 @@ def download_comic_files(soup):
|
|||||||
comic_files = []
|
comic_files = []
|
||||||
|
|
||||||
# set the image_folder name to the title of the comic
|
# 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)
|
print(image_folder)
|
||||||
|
|
||||||
# append each comic link found in the bs4 response to the comic file list
|
# 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)
|
comic_files.append(link)
|
||||||
|
|
||||||
# download the completed comic list
|
# 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
|
# create a comic archive from all images in image_folder
|
||||||
zipper.create_comic_archive(ripper.get_title(soup), 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)
|
@main.route('/', methods=accepted_methods)
|
||||||
def index():
|
def index():
|
||||||
@@ -37,6 +48,6 @@ def index():
|
|||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
soup = ripper.get_soup_obj(form.search.data, headers)
|
soup = ripper.get_soup_obj(form.search.data, headers)
|
||||||
download_comic_files(soup)
|
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)
|
return render_template('index.html', form=form)
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
<h1>Save All Comics!</h1>
|
<h1>Save All Comics!</h1>
|
||||||
<form action="" method="POST" enctype=multipart/form-data>
|
<form action="" method="POST" enctype=multipart/form-data>
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
|
<p>Please input a <a href="http://www.readallcomics.com" rel="Nofollow">Readallcomics.com</a> link</p>
|
||||||
{{ form.search(placeholder='Comic URL, eg: https://readallcomics.com/marauders-001-2019/') }}
|
{{ form.search(placeholder='Comic URL, eg: https://readallcomics.com/marauders-001-2019/') }}
|
||||||
{{ form.submit() }}
|
{{ form.submit() }}
|
||||||
</form>
|
</form>
|
||||||
|
<h2>About Saveallcomics</h2>
|
||||||
|
<p>We hope you have enjoyed using Saveallcomics! We are a totally <strong>FREE</strong> project without profit.</p>
|
||||||
|
|
||||||
|
<p>© 2019 <a href="">Saveallcomics</a>. Some rights reserved.</p>
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
<h1>Huzzah! It Worked!</h1>
|
<h1>Huzzah! It Worked!</h1>
|
||||||
|
<h2>Download {{ title }}</h2>
|
||||||
|
{% set download = title + '/' + title + '.cbr' %}
|
||||||
|
<button><a href="{{ url_for('static', filename='download/' + download) }}">{{ title }}</a></button>
|
||||||
<a href="{{ url_for('main.index') }}">« Back to Home</a>
|
<a href="{{ url_for('main.index') }}">« Back to Home</a>
|
||||||
@@ -21,6 +21,7 @@ class Config(object):
|
|||||||
'sqlite:///' + os.path.join(basedir, 'app.db')
|
'sqlite:///' + os.path.join(basedir, 'app.db')
|
||||||
UPLOAD_FOLDER = os.path.join(basedir, 'app/static/uploads')
|
UPLOAD_FOLDER = os.path.join(basedir, 'app/static/uploads')
|
||||||
STASH_FOLDER = os.path.join(UPLOAD_FOLDER, 'stash')
|
STASH_FOLDER = os.path.join(UPLOAD_FOLDER, 'stash')
|
||||||
|
DOWNLOAD_FOLDER = os.path.join(basedir, 'app/static/download')
|
||||||
CLOUD_PLATFORM = 'aws'
|
CLOUD_PLATFORM = 'aws'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user