Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
D
douban-api-proxy
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
douban-api-proxy
Commits
837fc498
Commit
837fc498
authored
Mar 21, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Letterize authors
parent
4664b478
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
4 deletions
+36
-4
opds.py
cps/opds.py
+29
-4
index.xml
cps/templates/index.xml
+7
-0
No files found.
cps/opds.py
View file @
837fc498
...
...
@@ -27,7 +27,7 @@ from functools import wraps
from
flask
import
Blueprint
,
request
,
render_template
,
Response
,
g
,
make_response
,
abort
from
flask_login
import
current_user
from
sqlalchemy.sql.expression
import
func
,
text
,
or_
,
and_
from
sqlalchemy.sql.expression
import
func
,
text
,
or_
,
and_
,
true
from
werkzeug.security
import
check_password_hash
from
.
import
constants
,
logger
,
config
,
db
,
calibre_db
,
ub
,
services
,
get_locale
,
isoLanguages
...
...
@@ -97,6 +97,15 @@ def feed_normal_search():
return
feed_search
(
request
.
args
.
get
(
"query"
,
""
)
.
strip
())
@
opds
.
route
(
"/opds/books"
)
@
requires_basic_auth_if_no_ano
def
feed_books
():
off
=
request
.
args
.
get
(
"offset"
)
or
0
entries
,
__
,
pagination
=
calibre_db
.
fill_indexpage
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
0
,
db
.
Books
,
True
,
[
db
.
Books
.
sort
])
return
render_xml_template
(
'feed.xml'
,
entries
=
entries
,
pagination
=
pagination
)
@
opds
.
route
(
"/opds/new"
)
@
requires_basic_auth_if_no_ano
def
feed_new
():
...
...
@@ -151,13 +160,29 @@ def feed_hot():
@
requires_basic_auth_if_no_ano
def
feed_authorindex
():
off
=
request
.
args
.
get
(
"offset"
)
or
0
entries
=
calibre_db
.
session
.
query
(
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
))
.
label
(
'id'
),
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
))
.
label
(
'name'
))
\
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
.
filter
(
calibre_db
.
common_filters
())
\
.
group_by
(
func
.
upper
(
func
.
substr
(
db
.
Authors
.
sort
,
1
,
1
)))
.
all
()
# ToDo: Add All to list -> All: id = 0
pagination
=
Pagination
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
config
.
config_books_per_page
,
len
(
entries
))
return
render_xml_template
(
'feed.xml'
,
listelements
=
entries
,
folder
=
'opds.feed_letter_author'
,
pagination
=
pagination
)
@
opds
.
route
(
"/opds/author/letter/<book_id>"
)
@
requires_basic_auth_if_no_ano
def
feed_letter_author
(
book_id
):
off
=
request
.
args
.
get
(
"offset"
)
or
0
letter
=
true
()
if
book_id
==
"0"
else
func
.
upper
(
db
.
Authors
.
sort
)
.
startswith
(
book_id
)
entries
=
calibre_db
.
session
.
query
(
db
.
Authors
)
.
join
(
db
.
books_authors_link
)
.
join
(
db
.
Books
)
\
.
filter
(
calibre_db
.
common_filters
())
\
.
filter
(
calibre_db
.
common_filters
())
.
filter
(
letter
)
\
.
group_by
(
text
(
'books_authors_link.author'
))
\
.
order_by
(
db
.
Authors
.
sort
)
.
limit
(
config
.
config_books_per_page
)
\
.
offset
(
off
)
.
offset
(
off
)
.
all
()
pagination
=
Pagination
((
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
),
config
.
config_books_per_page
,
len
(
calibre_db
.
session
.
query
(
db
.
Authors
)
.
all
()
))
len
(
entries
))
return
render_xml_template
(
'feed.xml'
,
listelements
=
entries
,
folder
=
'opds.feed_author'
,
pagination
=
pagination
)
...
...
cps/templates/index.xml
View file @
837fc498
...
...
@@ -14,6 +14,13 @@
<name>
{{instance}}
</name>
<uri>
https://github.com/janeczku/calibre-web
</uri>
</author>
<entry>
<title>
{{_('Alphabetical Books')}}
</title>
<link
href=
"{{url_for('opds.feed_books')}}"
type=
"application/atom+xml;profile=opds-catalog"
/>
<id>
{{url_for('opds.feed_books')}}
</id>
<updated>
{{ current_time }}
</updated>
<content
type=
"text"
>
{{_('Books sorted alphabetically')}}
</content>
</entry>
<entry>
<title>
{{_('Hot Books')}}
</title>
<link
href=
"{{url_for('opds.feed_hot')}}"
type=
"application/atom+xml;profile=opds-catalog"
/>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment