Started setting up very simple front end for cicking off download process. Also added a new method to check if there is any missing url metadata and what mangas it effects.
This commit is contained in:
41
main.py
41
main.py
@@ -1,12 +1,13 @@
|
|||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy
|
||||||
from flask import Flask, jsonify
|
from flask import Flask, jsonify, render_template, request
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
|
||||||
PATH = '/download'
|
PATH = '/download'
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__,
|
||||||
|
template_folder="templates")
|
||||||
|
|
||||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://mdownload:mdownload@192.168.86.198:3306/Downloads'
|
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://mdownload:mdownload@192.168.86.198:3306/Downloads'
|
||||||
@@ -35,6 +36,9 @@ class url_metadata(db.Model):
|
|||||||
flag = db.Column(db.Text)
|
flag = db.Column(db.Text)
|
||||||
base_url = db.Column(db.VARCHAR(length=10000))
|
base_url = db.Column(db.VARCHAR(length=10000))
|
||||||
|
|
||||||
|
@app.route('/', methods=['GET'])
|
||||||
|
def index():
|
||||||
|
return render_template("index.html")
|
||||||
|
|
||||||
@app.route('/download', methods=['GET'])
|
@app.route('/download', methods=['GET'])
|
||||||
def download():
|
def download():
|
||||||
@@ -51,9 +55,9 @@ def download():
|
|||||||
book['title'] = each.manga.name
|
book['title'] = each.manga.name
|
||||||
book['command'] = execute
|
book['command'] = execute
|
||||||
updated.append(book)
|
updated.append(book)
|
||||||
os.system(execute)
|
# os.system(execute)
|
||||||
|
missing = check(passin=1)
|
||||||
return jsonify(manga=updated)
|
return jsonify(manga=updated, missingFlags=missing[0], missingManga=missing[1])
|
||||||
|
|
||||||
@app.route('/upload', methods=['GET'])
|
@app.route('/upload', methods=['GET'])
|
||||||
def upload_jason():
|
def upload_jason():
|
||||||
@@ -102,5 +106,32 @@ def active():
|
|||||||
|
|
||||||
return jsonify(active=activbooks)
|
return jsonify(active=activbooks)
|
||||||
|
|
||||||
|
@app.route('/check/', methods=['GET'])
|
||||||
|
def check(passin=0):
|
||||||
|
passin=passin
|
||||||
|
missingManga = []
|
||||||
|
missingFlags = []
|
||||||
|
providerFlags = []
|
||||||
|
mangaFlags = manga.query.with_entities(manga.url_flag).distinct()
|
||||||
|
providerFlagResult = url_metadata.query.all()
|
||||||
|
for each in providerFlagResult:
|
||||||
|
providerFlags.append(each.flag)
|
||||||
|
for each in mangaFlags:
|
||||||
|
if each.url_flag not in providerFlags:
|
||||||
|
missingFlags.append(each.url_flag)
|
||||||
|
for each in missingFlags:
|
||||||
|
mangaInfo = {}
|
||||||
|
badManga = manga.query.filter_by(url_flag=each).all()
|
||||||
|
for each in badManga:
|
||||||
|
mangaInfo['name'] = each.name
|
||||||
|
mangaInfo['url_flag'] = each.url_flag
|
||||||
|
mangaInfo['active'] = each.active
|
||||||
|
missingManga.append(mangaInfo)
|
||||||
|
|
||||||
|
if passin == 1:
|
||||||
|
return missingFlags, missingManga
|
||||||
|
else:
|
||||||
|
return jsonify(missingFlags=missingFlags, missingManga=missingManga)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host='0.0.0.0', debug=True)
|
app.run(host='0.0.0.0', debug=True)
|
||||||
|
|||||||
10
templates/index.html
Normal file
10
templates/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Title</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<button>Butttttton</button>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user