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
1c630eb6
Commit
1c630eb6
authored
Dec 30, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixes from tests
parent
1c18a788
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
175 additions
and
192 deletions
+175
-192
db.py
cps/db.py
+8
-2
kobo.py
cps/kobo.py
+148
-177
kobo_auth.py
cps/kobo_auth.py
+9
-2
opds.py
cps/opds.py
+3
-3
web.py
cps/web.py
+7
-8
No files found.
cps/db.py
View file @
1c630eb6
...
...
@@ -33,7 +33,7 @@ from sqlalchemy.ext.declarative import declarative_base
session
=
None
cc_exceptions
=
[
'datetime'
,
'comments'
,
'float'
,
'composite'
,
'series'
]
cc_classes
=
{}
engine
=
None
Base
=
declarative_base
()
...
...
@@ -288,7 +288,7 @@ class Books(Base):
@
property
def
atom_timestamp
(
self
):
return
(
self
.
timestamp
or
''
)
.
replace
(
' '
,
'T
'
)
return
(
self
.
timestamp
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S+00:00'
)
or
'
'
)
class
Custom_Columns
(
Base
):
__tablename__
=
'custom_columns'
...
...
@@ -327,6 +327,7 @@ def update_title_sort(config, conn=None):
def
setup_db
(
config
):
dispose
()
global
engine
if
not
config
.
config_calibre_dir
:
config
.
invalidate
()
...
...
@@ -428,3 +429,8 @@ def dispose():
if
name
.
startswith
(
"custom_column_"
)
or
name
.
startswith
(
"books_custom_column_"
):
if
table
is
not
None
:
Base
.
metadata
.
remove
(
table
)
def
reconnect_db
(
config
):
session
.
close
()
engine
.
dispose
()
setup_db
(
config
)
cps/kobo.py
View file @
1c630eb6
This diff is collapsed.
Click to expand it.
cps/kobo_auth.py
View file @
1c630eb6
...
...
@@ -81,10 +81,17 @@ def disable_failed_auth_redirect_for_blueprint(bp):
lm
.
blueprint_login_views
[
bp
.
name
]
=
None
def
get_auth_token
():
if
"auth_token"
in
g
:
return
g
.
get
(
"auth_token"
)
else
:
return
None
@
lm
.
request_loader
def
load_user_from_kobo_request
(
request
):
if
"auth_token"
in
g
:
auth_token
=
g
.
get
(
"auth_token"
)
auth_token
=
get_auth_token
()
if
auth_token
is
not
None
:
user
=
(
ub
.
session
.
query
(
ub
.
User
)
.
join
(
ub
.
RemoteAuthToken
)
...
...
cps/opds.py
View file @
1c630eb6
...
...
@@ -276,7 +276,7 @@ def feed_languages(book_id):
isoLanguages.get(part3=entry.languages[index].lang_code).name)'''
return
render_xml_template
(
'feed.xml'
,
entries
=
entries
,
pagination
=
pagination
)
@
opds
.
route
(
"/opds/shelfindex
/
"
,
defaults
=
{
'public'
:
0
})
@
opds
.
route
(
"/opds/shelfindex"
,
defaults
=
{
'public'
:
0
})
@
opds
.
route
(
"/opds/shelfindex/<string:public>"
)
@
requires_basic_auth_if_no_ano
def
feed_shelfindex
(
public
):
...
...
@@ -378,14 +378,14 @@ def render_xml_template(*args, **kwargs):
def
feed_get_cover
(
book_id
):
return
get_book_cover
(
book_id
)
@
opds
.
route
(
"/opds/readbooks
/
"
)
@
opds
.
route
(
"/opds/readbooks"
)
@
requires_basic_auth_if_no_ano
def
feed_read_books
():
off
=
request
.
args
.
get
(
"offset"
)
or
0
return
render_read_books
(
int
(
off
)
/
(
int
(
config
.
config_books_per_page
))
+
1
,
True
,
True
)
@
opds
.
route
(
"/opds/unreadbooks
/
"
)
@
opds
.
route
(
"/opds/unreadbooks"
)
@
requires_basic_auth_if_no_ano
def
feed_unread_books
():
off
=
request
.
args
.
get
(
"offset"
)
or
0
...
...
cps/web.py
View file @
1c630eb6
...
...
@@ -43,7 +43,7 @@ from werkzeug.exceptions import default_exceptions
from
werkzeug.datastructures
import
Headers
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
.
import
constants
,
logger
,
isoLanguages
,
services
,
worker
from
.
import
constants
,
config
,
logger
,
isoLanguages
,
services
,
worker
from
.
import
searched_ids
,
lm
,
babel
,
db
,
ub
,
config
,
get_locale
,
app
from
.gdriveutils
import
getFileFromEbooksFolder
,
do_gdrive_download
from
.helper
import
common_filters
,
get_search_results
,
fill_indexpage
,
speaking_language
,
check_valid_domain
,
\
...
...
@@ -93,12 +93,12 @@ def error_http(error):
def
internal_error
(
error
):
__
,
__
,
tb
=
sys
.
exc_info
()
#
__, __, tb = sys.exc_info()
return
render_template
(
'http_error.html'
,
error_code
=
"Internal Server Error"
,
error_name
=
str
(
error
),
issue
=
True
,
error_stack
=
traceback
.
format_
tb
(
tb
),
error_stack
=
traceback
.
format_
exc
()
.
split
(
"
\n
"
),
instance
=
config
.
config_calibre_web_title
),
500
...
...
@@ -790,9 +790,7 @@ def get_tasks_status():
@
app
.
route
(
"/reconnect"
)
def
reconnect
():
db
.
session
.
close
()
db
.
engine
.
dispose
()
db
.
setup_db
()
db
.
reconnect_db
(
config
)
return
json
.
dumps
({})
@
web
.
route
(
"/search"
,
methods
=
[
"GET"
])
...
...
@@ -961,7 +959,7 @@ def advanced_search():
series
=
series
,
title
=
_
(
u"search"
),
cc
=
cc
,
page
=
"advsearch"
)
def
render_read_books
(
page
,
are_read
,
as_xml
=
False
,
order
=
None
):
def
render_read_books
(
page
,
are_read
,
as_xml
=
False
,
order
=
None
,
*
args
,
**
kwargs
):
order
=
order
or
[]
if
not
config
.
config_read_column
:
readBooks
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
))
\
...
...
@@ -984,7 +982,8 @@ def render_read_books(page, are_read, as_xml=False, order=None):
entries
,
random
,
pagination
=
fill_indexpage
(
page
,
db
.
Books
,
db_filter
,
order
)
if
as_xml
:
xml
=
render_title_template
(
'feed.xml'
,
entries
=
entries
,
pagination
=
pagination
)
currtime
=
datetime
.
datetime
.
now
()
.
strftime
(
"
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S+00:00"
)
xml
=
render_template
(
current_time
=
currtime
,
instance
=
config
.
config_calibre_web_title
,
*
args
,
**
kwargs
)
response
=
make_response
(
xml
)
response
.
headers
[
"Content-Type"
]
=
"application/xml; charset=utf-8"
return
response
...
...
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