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
22c93e23
Commit
22c93e23
authored
Mar 14, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into development
parents
f77d72fd
8c751eb5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
257 additions
and
185 deletions
+257
-185
db.py
cps/db.py
+9
-9
gdrive.py
cps/gdrive.py
+1
-1
kobo.py
cps/kobo.py
+2
-14
server.py
cps/server.py
+1
-1
caliBlur_override.css
cps/static/css/caliBlur_override.css
+5
-5
main.css
cps/static/css/main.css
+1
-1
filter_grid.js
cps/static/js/filter_grid.js
+6
-6
get_meta.js
cps/static/js/get_meta.js
+4
-4
main.js
cps/static/js/main.js
+4
-4
table.js
cps/static/js/table.js
+13
-13
ub.py
cps/ub.py
+1
-1
updater.py
cps/updater.py
+2
-1
web.py
cps/web.py
+208
-125
No files found.
cps/db.py
View file @
22c93e23
...
...
@@ -384,14 +384,14 @@ class Custom_Columns(Base):
class
AlchemyEncoder
(
json
.
JSONEncoder
):
def
default
(
self
,
o
bj
):
if
isinstance
(
o
bj
.
__class__
,
DeclarativeMeta
):
def
default
(
self
,
o
):
if
isinstance
(
o
.
__class__
,
DeclarativeMeta
):
# an SQLAlchemy class
fields
=
{}
for
field
in
[
x
for
x
in
dir
(
o
bj
)
if
not
x
.
startswith
(
'_'
)
and
x
!=
'metadata'
]:
for
field
in
[
x
for
x
in
dir
(
o
)
if
not
x
.
startswith
(
'_'
)
and
x
!=
'metadata'
]:
if
field
==
'books'
:
continue
data
=
o
bj
.
__getattribute__
(
field
)
data
=
o
.
__getattribute__
(
field
)
try
:
if
isinstance
(
data
,
str
):
data
=
data
.
replace
(
"'"
,
"
\'
"
)
...
...
@@ -411,12 +411,12 @@ class AlchemyEncoder(json.JSONEncoder):
else
:
json
.
dumps
(
data
)
fields
[
field
]
=
data
except
:
except
Exception
:
fields
[
field
]
=
""
# a json-encodable dict
return
fields
return
json
.
JSONEncoder
.
default
(
self
,
o
bj
)
return
json
.
JSONEncoder
.
default
(
self
,
o
)
class
CalibreDB
():
...
...
@@ -563,8 +563,8 @@ class CalibreDB():
def
get_book_by_uuid
(
self
,
book_uuid
):
return
self
.
session
.
query
(
Books
)
.
filter
(
Books
.
uuid
==
book_uuid
)
.
first
()
def
get_book_format
(
self
,
book_id
,
format
):
return
self
.
session
.
query
(
Data
)
.
filter
(
Data
.
book
==
book_id
)
.
filter
(
Data
.
format
==
format
)
.
first
()
def
get_book_format
(
self
,
book_id
,
f
ile_f
ormat
):
return
self
.
session
.
query
(
Data
)
.
filter
(
Data
.
book
==
book_id
)
.
filter
(
Data
.
format
==
f
ile_f
ormat
)
.
first
()
# Language and content filters for displaying in the UI
def
common_filters
(
self
,
allow_show_archived
=
False
):
...
...
@@ -742,7 +742,7 @@ class CalibreDB():
if
old_session
:
try
:
old_session
.
close
()
except
:
except
Exception
:
pass
if
old_session
.
bind
:
try
:
...
...
cps/gdrive.py
View file @
22c93e23
...
...
@@ -47,7 +47,7 @@ except ImportError as err:
current_milli_time
=
lambda
:
int
(
round
(
time
()
*
1000
))
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
gdrive_watch_callback_token
=
'target=calibreweb-watch_files'
#nosec
@
gdrive
.
route
(
"/authenticate"
)
...
...
cps/kobo.py
View file @
22c93e23
...
...
@@ -42,8 +42,7 @@ from flask import (
from
flask_login
import
current_user
from
werkzeug.datastructures
import
Headers
from
sqlalchemy
import
func
from
sqlalchemy.sql.expression
import
and_
,
or_
from
sqlalchemy.orm
import
load_only
from
sqlalchemy.sql.expression
import
and_
from
sqlalchemy.exc
import
StatementError
import
requests
...
...
@@ -893,17 +892,6 @@ def HandleProductsRequest(dummy=None):
return
redirect_or_proxy_request
()
'''@kobo.errorhandler(404)
def handle_404(err):
# This handler acts as a catch-all for endpoints that we don't have an interest in
# implementing (e.g: v1/analytics/gettests, v1/user/recommendations, etc)
if err:
print('404')
return jsonify(error=str(err)), 404
log.debug("Unknown Request received:
%
s, method:
%
s, data:
%
s", request.base_url, request.method, request.data)
return redirect_or_proxy_request()'''
def
make_calibre_web_auth_response
():
# As described in kobo_auth.py, CalibreWeb doesn't make use practical use of this auth/device API call for
# authentation (nor for authorization). We return a dummy response just to keep the device happy.
...
...
@@ -947,7 +935,7 @@ def HandleInitRequest():
store_response_json
=
store_response
.
json
()
if
"Resources"
in
store_response_json
:
kobo_resources
=
store_response_json
[
"Resources"
]
except
:
except
Exception
:
log
.
error
(
"Failed to receive or parse response from Kobo's init endpoint. Falling back to un-proxied mode."
)
if
not
kobo_resources
:
kobo_resources
=
NATIVE_KOBO_RESOURCES
()
...
...
cps/server.py
View file @
22c93e23
...
...
@@ -138,7 +138,7 @@ class WebServer(object):
return
sock
,
_readable_listen_address
(
*
address
)
@
staticmethod
def
_get_args_for_reloading
(
self
):
def
_get_args_for_reloading
():
"""Determine how the script was executed, and return the args needed
to execute it again in a new process.
Code from https://github.com/pyload/pyload. Author GammaC0de, voulter
...
...
cps/static/css/caliBlur_override.css
View file @
22c93e23
body
.serieslist.grid-view
div
.container-fluid
>
div
>
div
.col-sm-10
:
before
{
body
.serieslist.grid-view
div
.container-fluid
>
div
>
div
.col-sm-10
:
:before
{
display
:
none
;
}
.cover
.badge
{
.cover
.badge
{
position
:
absolute
;
top
:
0
;
left
:
0
;
...
...
@@ -10,15 +10,15 @@ body.serieslist.grid-view div.container-fluid > div > div.col-sm-10:before{
background-color
:
#cc7b19
;
border-radius
:
0
;
padding
:
0
8px
;
box-shadow
:
0
0
4px
rgba
(
0
,
0
,
0
,
.6
);
box-shadow
:
0
0
4px
rgba
(
0
,
0
,
0
,
0
.6
);
line-height
:
24px
;
}
.cover
{
box-shadow
:
0
0
4px
rgba
(
0
,
0
,
0
,
.6
);
box-shadow
:
0
0
4px
rgba
(
0
,
0
,
0
,
0
.6
);
}
.cover
.read
{
padding
:
0
px
0px
;
padding
:
0
0
;
line-height
:
15px
;
}
cps/static/css/main.css
View file @
22c93e23
...
...
@@ -370,7 +370,7 @@ input:-moz-placeholder { color: #454545; }
}
#searchResults
li
{
margin-bottom
:
10px
;
margin-bottom
:
10px
;
width
:
225px
;
font-family
:
Georgia
,
"Times New Roman"
,
Times
,
serif
;
list-style
:
none
;
...
...
cps/static/js/filter_grid.js
View file @
22c93e23
...
...
@@ -36,7 +36,6 @@ $("#desc").click(function() {
sortBy
:
"name"
,
sortAscending
:
true
});
return
;
});
$
(
"#asc"
).
click
(
function
()
{
...
...
@@ -52,19 +51,20 @@ $("#asc").click(function() {
sortBy
:
"name"
,
sortAscending
:
false
});
return
;
});
$
(
"#all"
).
click
(
function
()
{
// go through all elements and make them visible
$list
.
isotope
({
filter
:
function
()
{
return
true
;
}
})
return
true
;
}
});
});
$
(
".char"
).
click
(
function
()
{
var
character
=
this
.
innerText
;
$list
.
isotope
({
filter
:
function
()
{
return
this
.
attributes
[
"data-id"
].
value
.
charAt
(
0
).
toUpperCase
()
==
character
;
}
})
return
this
.
attributes
[
"data-id"
].
value
.
charAt
(
0
).
toUpperCase
()
==
character
;
}
});
});
cps/static/js/get_meta.js
View file @
22c93e23
...
...
@@ -138,8 +138,8 @@ $(function () {
seriesTitle
=
result
.
series
.
title
;
}
var
dateFomers
=
result
.
pubdate
.
split
(
"-"
);
var
publishedYear
=
parseInt
(
dateFomers
[
0
]);
var
publishedMonth
=
parseInt
(
dateFomers
[
1
]);
var
publishedYear
=
parseInt
(
dateFomers
[
0
]
,
10
);
var
publishedMonth
=
parseInt
(
dateFomers
[
1
]
,
10
);
var
publishedDate
=
new
Date
(
publishedYear
,
publishedMonth
-
1
,
1
);
publishedDate
=
formatDate
(
publishedDate
);
...
...
@@ -194,8 +194,8 @@ $(function () {
}
else
{
dateFomers
=
result
.
date_added
.
split
(
"-"
);
}
var
publishedYear
=
parseInt
(
dateFomers
[
0
]);
var
publishedMonth
=
parseInt
(
dateFomers
[
1
]);
var
publishedYear
=
parseInt
(
dateFomers
[
0
]
,
10
);
var
publishedMonth
=
parseInt
(
dateFomers
[
1
]
,
10
);
var
publishedDate
=
new
Date
(
publishedYear
,
publishedMonth
-
1
,
1
);
publishedDate
=
formatDate
(
publishedDate
);
...
...
cps/static/js/main.js
View file @
22c93e23
...
...
@@ -114,7 +114,7 @@ $(document).ready(function() {
}
});
function
C
onfirmDialog
(
id
,
dataValue
,
yesFn
,
noFn
)
{
function
c
onfirmDialog
(
id
,
dataValue
,
yesFn
,
noFn
)
{
var
$confirm
=
$
(
"#GeneralDeleteModal"
);
// var dataValue= e.data('value'); // target.data('value');
$confirm
.
modal
(
'show'
);
...
...
@@ -481,7 +481,7 @@ $(function() {
});
$
(
"#config_delete_kobo_token"
).
click
(
function
()
{
C
onfirmDialog
(
c
onfirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
data
(
'value'
),
function
(
value
)
{
...
...
@@ -509,7 +509,7 @@ $(function() {
});
$
(
"#btndeluser"
).
click
(
function
()
{
C
onfirmDialog
(
c
onfirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
data
(
'value'
),
function
(
value
){
...
...
@@ -527,7 +527,7 @@ $(function() {
});
$
(
"#delete_shelf"
).
click
(
function
()
{
C
onfirmDialog
(
c
onfirmDialog
(
$
(
this
).
attr
(
'id'
),
$
(
this
).
data
(
'value'
),
function
(
value
){
...
...
cps/static/js/table.js
View file @
22c93e23
...
...
@@ -16,7 +16,7 @@
*/
/* exported TableActions, RestrictionActions, EbookActions, responseHandler */
/* global getPath,
C
onfirmDialog */
/* global getPath,
c
onfirmDialog */
var
selections
=
[];
...
...
@@ -210,7 +210,7 @@ $(function() {
striped
:
false
});
function
domain
_h
andle
(
domainId
)
{
function
domain
H
andle
(
domainId
)
{
$
.
ajax
({
method
:
"post"
,
url
:
window
.
location
.
pathname
+
"/../../ajax/deletedomain"
,
...
...
@@ -237,12 +237,12 @@ $(function() {
}
$
(
"#domain-allow-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
if
(
value
===
2
)
{
ConfirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domain_h
andle
);
confirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domainH
andle
);
}
});
$
(
"#domain-deny-table"
).
on
(
"click-cell.bs.table"
,
function
(
field
,
value
,
row
,
$element
)
{
if
(
value
===
2
)
{
ConfirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domain_h
andle
);
confirmDialog
(
"btndeletedomain"
,
$element
.
id
,
domainH
andle
);
}
});
...
...
@@ -256,12 +256,12 @@ $(function() {
$
(
"#h3"
).
addClass
(
"hidden"
);
$
(
"#h4"
).
addClass
(
"hidden"
);
});
function
startTable
(
type
,
user
_i
d
)
{
function
startTable
(
type
,
user
I
d
)
{
$
(
"#restrict-elements-table"
).
bootstrapTable
({
formatNoMatches
:
function
()
{
return
""
;
},
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
I
d
,
rowStyle
:
function
(
row
)
{
// console.log('Reihe :' + row + " Index :" + index);
if
(
row
.
id
.
charAt
(
0
)
===
"a"
)
{
...
...
@@ -275,13 +275,13 @@ $(function() {
$
.
ajax
({
type
:
"Post"
,
data
:
"id="
+
row
.
id
+
"&type="
+
row
.
type
+
"&Element="
+
encodeURIComponent
(
row
.
Element
),
url
:
getPath
()
+
"/ajax/deleterestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/deleterestriction/"
+
type
+
"/"
+
user
I
d
,
async
:
true
,
timeout
:
900
,
success
:
function
()
{
$
.
ajax
({
method
:
"get"
,
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
I
d
,
async
:
true
,
timeout
:
900
,
success
:
function
(
data
)
{
...
...
@@ -297,7 +297,7 @@ $(function() {
$
(
"#restrict-elements-table"
).
removeClass
(
"table-hover"
);
$
(
"#restrict-elements-table"
).
on
(
"editable-save.bs.table"
,
function
(
e
,
field
,
row
)
{
$
.
ajax
({
url
:
getPath
()
+
"/ajax/editrestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/editrestriction/"
+
type
+
"/"
+
user
I
d
,
type
:
"Post"
,
data
:
row
});
...
...
@@ -305,13 +305,13 @@ $(function() {
$
(
"[id^=submit_]"
).
click
(
function
()
{
$
(
this
)[
0
].
blur
();
$
.
ajax
({
url
:
getPath
()
+
"/ajax/addrestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/addrestriction/"
+
type
+
"/"
+
user
I
d
,
type
:
"Post"
,
data
:
$
(
this
).
closest
(
"form"
).
serialize
()
+
"&"
+
$
(
this
)[
0
].
name
+
"="
,
success
:
function
()
{
$
.
ajax
({
method
:
"get"
,
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
_i
d
,
url
:
getPath
()
+
"/ajax/listrestriction/"
+
type
+
"/"
+
user
I
d
,
async
:
true
,
timeout
:
900
,
success
:
function
(
data
)
{
...
...
@@ -333,12 +333,12 @@ $(function() {
$
(
"#h1"
).
removeClass
(
"hidden"
);
});
$
(
"#get_user_column_values"
).
on
(
"click"
,
function
()
{
startTable
(
3
,
$
(
this
).
data
(
'id'
));
startTable
(
3
,
$
(
this
).
data
(
"id"
));
$
(
"#h4"
).
removeClass
(
"hidden"
);
});
$
(
"#get_user_tags"
).
on
(
"click"
,
function
()
{
startTable
(
2
,
$
(
this
).
data
(
'id'
));
startTable
(
2
,
$
(
this
).
data
(
"id"
));
$
(
this
)[
0
].
blur
();
$
(
"#h3"
).
removeClass
(
"hidden"
);
});
...
...
cps/ub.py
View file @
22c93e23
...
...
@@ -610,7 +610,7 @@ def migrate_Database(session):
"locale VARCHAR(2),"
"sidebar_view INTEGER,"
"default_language VARCHAR(3),"
"view_settings VARCHAR,"
"view_settings VARCHAR,"
"UNIQUE (nickname),"
"UNIQUE (email))"
)
conn
.
execute
(
"INSERT INTO user_id(id, nickname, email, role, password, kindle_mail,locale,"
...
...
cps/updater.py
View file @
22c93e23
...
...
@@ -272,7 +272,8 @@ class Updater(threading.Thread):
log
.
debug
(
"Could not remove:
%
s"
,
item_path
)
shutil
.
rmtree
(
source
,
ignore_errors
=
True
)
def
is_venv
(
self
):
@
staticmethod
def
is_venv
():
if
(
hasattr
(
sys
,
'real_prefix'
))
or
(
hasattr
(
sys
,
'base_prefix'
)
and
sys
.
base_prefix
!=
sys
.
prefix
):
return
os
.
sep
+
os
.
path
.
relpath
(
sys
.
prefix
,
constants
.
BASE_DIR
)
else
:
...
...
cps/web.py
View file @
22c93e23
This diff is collapsed.
Click to expand it.
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