Worked on the out of date method a bit. All the checking logic is in place. But it adds a new record instead of updating the existing record.

This commit is contained in:
2020-05-22 23:13:30 -04:00
parent f071a67e77
commit cf80116185

20
main.py
View File

@@ -170,13 +170,15 @@ def upgrade():
@app.route('/ood/', methods=['GET'])
def ood():
added = []
url = []
base = []
name = []
y = 0
z = 0
mangaName = manga.query().all()
with open(PATH + "/tach.json", "r") as tf:
# with open("tach.json", "r") as tf:
@@ -190,6 +192,22 @@ def ood():
base.append(data["mangas"][y]["manga"][2])
y = y + 1
for each in name:
# print('start')
if manga.query.filter_by(name=name[z]).first():
result = manga.query.filter_by(name=name[z]).first()
if result.url != url[z]:
new_manga={}
# print('----' + name[z])
# print(url[z])
# print(result.url)
query = manga(name=name[z], url=url[z], url_flag=str(base[z]), view_format=0, unknown_value=0)
new_manga['title'] = name[z]
added.append(new_manga)
db.session.add(query)
z = z + 1
db.session.commit()
return jsonify(updated=added)
@app.route('/test/', methods=['GET'])
def test():