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
3be47d6e
Commit
3be47d6e
authored
Oct 09, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit_books prepared for kobo sync
parent
25f608d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
17 deletions
+39
-17
editbooks.py
cps/editbooks.py
+3
-3
kobo.py
cps/kobo.py
+2
-13
kobo_sync_status.py
cps/kobo_sync_status.py
+34
-0
ub.py
cps/ub.py
+0
-1
No files found.
cps/editbooks.py
View file @
3be47d6e
...
...
@@ -39,14 +39,12 @@ try:
except
ImportError
:
have_scholar
=
False
from
babel
import
Locale
as
LC
from
babel.core
import
UnknownLocaleError
from
flask
import
Blueprint
,
request
,
flash
,
redirect
,
url_for
,
abort
,
Markup
,
Response
from
flask_babel
import
gettext
as
_
from
flask_login
import
current_user
,
login_required
from
sqlalchemy.exc
import
OperationalError
,
IntegrityError
from
sqlite3
import
OperationalError
as
sqliteOperationalError
from
.
import
constants
,
logger
,
isoLanguages
,
gdriveutils
,
uploader
,
helper
from
.
import
constants
,
logger
,
isoLanguages
,
gdriveutils
,
uploader
,
helper
,
kobo_sync_status
from
.
import
config
,
get_locale
,
ub
,
db
from
.
import
calibre_db
from
.services.worker
import
WorkerThread
...
...
@@ -825,6 +823,8 @@ def edit_book(book_id):
if
modif_date
:
book
.
last_modified
=
datetime
.
utcnow
()
kobo_sync_status
.
remove_synced_book
(
edited_books_id
)
calibre_db
.
session
.
merge
(
book
)
calibre_db
.
session
.
commit
()
if
config
.
config_use_google_drive
:
...
...
cps/kobo.py
View file @
3be47d6e
...
...
@@ -19,7 +19,6 @@
import
base64
import
datetime
import
sys
import
os
import
uuid
from
time
import
gmtime
,
strftime
...
...
@@ -48,7 +47,7 @@ from sqlalchemy.sql import select
import
requests
from
.
import
config
,
logger
,
kobo_auth
,
db
,
calibre_db
,
helper
,
shelf
as
shelf_lib
,
ub
,
csrf
from
.
import
config
,
logger
,
kobo_auth
,
db
,
calibre_db
,
helper
,
shelf
as
shelf_lib
,
ub
,
csrf
,
kobo_sync_status
from
.constants
import
sqlalchemy_version2
from
.helper
import
get_download_link
from
.services
import
SyncToken
as
SyncToken
...
...
@@ -214,7 +213,7 @@ def HandleSyncRequest():
else
:
books
=
changed_entries
.
limit
(
SYNC_ITEM_LIMIT
)
for
book
in
books
:
add_synced_books
(
book
.
Books
.
id
)
kobo_sync_status
.
add_synced_books
(
book
.
Books
.
id
)
formats
=
[
data
.
format
for
data
in
book
.
Books
.
data
]
if
not
'KEPUB'
in
formats
and
config
.
config_kepubifypath
and
'EPUB'
in
formats
:
helper
.
convert_book_format
(
book
.
Books
.
id
,
config
.
config_calibre_dir
,
'EPUB'
,
'KEPUB'
,
current_user
.
name
)
...
...
@@ -847,16 +846,6 @@ def get_ub_read_status(kobo_read_status):
}
return
string_to_enum_map
[
kobo_read_status
]
def
add_synced_books
(
book_id
):
synced_book
=
ub
.
KoboSyncedBooks
()
synced_book
.
user_id
=
current_user
.
id
synced_book
.
book_id
=
book_id
ub
.
session
.
add
(
synced_book
)
try
:
ub
.
session
.
commit
()
except
Exception
:
ub
.
session
.
rollback
()
def
get_or_create_reading_state
(
book_id
):
book_read
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
ReadBook
.
book_id
==
book_id
,
...
...
cps/kobo_sync_status.py
0 → 100644
View file @
3be47d6e
# -*- coding: utf-8 -*-
# This file is part of the Calibre-Web (https://github.com/janeczku/calibre-web)
# Copyright (C) 2021 OzzieIsaacs
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
flask_login
import
current_user
from
.
import
ub
def
add_synced_books
(
book_id
):
synced_book
=
ub
.
KoboSyncedBooks
()
synced_book
.
user_id
=
current_user
.
id
synced_book
.
book_id
=
book_id
ub
.
session
.
add
(
synced_book
)
ub
.
session_commit
()
def
remove_synced_book
(
book_id
):
ub
.
session
.
query
(
ub
.
KoboSyncedBooks
)
.
filter
(
ub
.
KoboSyncedBooks
.
book_id
==
book_id
)
.
delete
()
ub
.
session_commit
()
cps/ub.py
View file @
3be47d6e
...
...
@@ -27,7 +27,6 @@ from binascii import hexlify
from
flask_login
import
AnonymousUserMixin
,
current_user
from
flask_login
import
user_logged_in
from
contextlib
import
contextmanager
try
:
from
flask_dance.consumer.backend.sqla
import
OAuthConsumerMixin
...
...
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