|
|
@ -25,7 +25,7 @@ import sys
|
|
|
|
import datetime
|
|
|
|
import datetime
|
|
|
|
from functools import wraps
|
|
|
|
from functools import wraps
|
|
|
|
|
|
|
|
|
|
|
|
from flask import Blueprint, request, render_template, Response, g, make_response
|
|
|
|
from flask import Blueprint, request, render_template, Response, g, make_response, abort
|
|
|
|
from flask_login import current_user
|
|
|
|
from flask_login import current_user
|
|
|
|
from sqlalchemy.sql.expression import func, text, or_, and_
|
|
|
|
from sqlalchemy.sql.expression import func, text, or_, and_
|
|
|
|
from werkzeug.security import check_password_hash
|
|
|
|
from werkzeug.security import check_password_hash
|
|
|
@ -165,7 +165,10 @@ def feed_author(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.authors.any(db.Authors.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
db.Books, db.Books.authors.any(db.Authors.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/publisher")
|
|
|
|
@opds.route("/opds/publisher")
|
|
|
@ -186,7 +189,10 @@ def feed_publisher(book_id):
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.publishers.any(db.Publishers.id == book_id),
|
|
|
|
db.Books, db.Books.publishers.any(db.Publishers.id == book_id),
|
|
|
|
[db.Books.timestamp.desc()])
|
|
|
|
[db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/category")
|
|
|
|
@opds.route("/opds/category")
|
|
|
@ -206,7 +212,10 @@ def feed_category(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.tags.any(db.Tags.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
db.Books, db.Books.tags.any(db.Tags.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/series")
|
|
|
|
@opds.route("/opds/series")
|
|
|
@ -226,7 +235,10 @@ def feed_series(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.series.any(db.Series.id == book_id), [db.Books.series_index])
|
|
|
|
db.Books, db.Books.series.any(db.Series.id == book_id), [db.Books.series_index])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/ratings")
|
|
|
|
@opds.route("/opds/ratings")
|
|
|
|
@requires_basic_auth_if_no_ano
|
|
|
|
@requires_basic_auth_if_no_ano
|
|
|
@ -250,7 +262,11 @@ def feed_ratings(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.ratings.any(db.Ratings.id == book_id),[db.Books.timestamp.desc()])
|
|
|
|
db.Books, db.Books.ratings.any(db.Ratings.id == book_id),[db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/formats")
|
|
|
|
@opds.route("/opds/formats")
|
|
|
@ -274,7 +290,11 @@ def feed_format(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.data.any(db.Data.format == book_id.upper()), [db.Books.timestamp.desc()])
|
|
|
|
db.Books, db.Books.data.any(db.Data.format == book_id.upper()), [db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/language")
|
|
|
|
@opds.route("/opds/language")
|
|
|
|
@opds.route("/opds/language/")
|
|
|
|
@opds.route("/opds/language/")
|
|
|
@ -305,20 +325,23 @@ def feed_languages(book_id):
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
entries, __, pagination = fill_indexpage((int(off) / (int(config.config_books_per_page)) + 1),
|
|
|
|
db.Books, db.Books.languages.any(db.Languages.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
db.Books, db.Books.languages.any(db.Languages.id == book_id), [db.Books.timestamp.desc()])
|
|
|
|
|
|
|
|
if len(entries):
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=entries, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/shelfindex", defaults={'public': 0})
|
|
|
|
@opds.route("/opds/shelfindex") #, defaults={'public': 0})
|
|
|
|
@opds.route("/opds/shelfindex/<string:public>")
|
|
|
|
# @opds.route("/opds/shelfindex/<string:public>")
|
|
|
|
@requires_basic_auth_if_no_ano
|
|
|
|
@requires_basic_auth_if_no_ano
|
|
|
|
def feed_shelfindex(public):
|
|
|
|
def feed_shelfindex():
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
off = request.args.get("offset") or 0
|
|
|
|
if public != 0:
|
|
|
|
# if public != 0:
|
|
|
|
shelf = g.public_shelfes
|
|
|
|
shelf = g.shelves_access
|
|
|
|
number = len(shelf)
|
|
|
|
number = len(shelf)
|
|
|
|
else:
|
|
|
|
#else:
|
|
|
|
shelf = g.user.shelf
|
|
|
|
#shelf = g.user.shelf
|
|
|
|
number = shelf.count()
|
|
|
|
# number = shelf.count()
|
|
|
|
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
|
|
|
|
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
|
|
|
|
number)
|
|
|
|
number)
|
|
|
|
return render_xml_template('feed.xml', listelements=shelf, folder='opds.feed_shelf', pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', listelements=shelf, folder='opds.feed_shelf', pagination=pagination)
|
|
|
@ -346,6 +369,8 @@ def feed_shelf(book_id):
|
|
|
|
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
|
|
|
|
pagination = Pagination((int(off) / (int(config.config_books_per_page)) + 1), config.config_books_per_page,
|
|
|
|
len(result))
|
|
|
|
len(result))
|
|
|
|
return render_xml_template('feed.xml', entries=result, pagination=pagination)
|
|
|
|
return render_xml_template('feed.xml', entries=result, pagination=pagination)
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
return abort(404)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@opds.route("/opds/download/<book_id>/<book_format>/")
|
|
|
|
@opds.route("/opds/download/<book_id>/<book_format>/")
|
|
|
|