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
d39b28b0
Commit
d39b28b0
authored
Dec 08, 2020
by
OzzieIsaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for existing book format with gdrive
parent
8f36128f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
5 deletions
+9
-5
gdrive.py
cps/gdrive.py
+3
-0
worker.py
cps/services/worker.py
+1
-1
convert.py
cps/tasks/convert.py
+5
-4
No files found.
cps/gdrive.py
View file @
d39b28b0
...
...
@@ -84,6 +84,7 @@ def watch_gdrive():
if
not
config
.
config_google_drive_watch_changes_response
:
with
open
(
gdriveutils
.
CLIENT_SECRETS
,
'r'
)
as
settings
:
filedata
=
json
.
load
(
settings
)
# ToDo: Easier: rstrip('/')
if
filedata
[
'web'
][
'redirect_uris'
][
0
]
.
endswith
(
'/'
):
filedata
[
'web'
][
'redirect_uris'
][
0
]
=
filedata
[
'web'
][
'redirect_uris'
][
0
][:
-
((
len
(
'/gdrive/callback'
)
+
1
))]
else
:
...
...
@@ -123,6 +124,8 @@ def revoke_watch_gdrive():
@
gdrive
.
route
(
"/gdrive/watch/callback"
,
methods
=
[
'GET'
,
'POST'
])
def
on_received_watch_confirmation
():
if
not
config
.
config_google_drive_watch_changes_response
:
return
''
if
request
.
headers
.
get
(
'X-Goog-Channel-Token'
)
!=
gdrive_watch_callback_token
\
or
request
.
headers
.
get
(
'X-Goog-Resource-State'
)
!=
'change'
\
or
not
request
.
data
:
...
...
cps/services/worker.py
View file @
d39b28b0
...
...
@@ -110,7 +110,7 @@ class WorkerThread(threading.Thread):
# We don't use a daemon here because we don't want the tasks to just be abruptly halted, leading to
# possible file / database corruption
item
=
self
.
queue
.
get
(
timeout
=
1
)
except
queue
.
Empty
as
ex
:
except
queue
.
Empty
:
time
.
sleep
(
1
)
continue
...
...
cps/tasks/convert.py
View file @
d39b28b0
...
...
@@ -80,10 +80,11 @@ class TaskConvert(CalibreTask):
format_old_ext
=
u'.'
+
self
.
settings
[
'old_book_format'
]
.
lower
()
format_new_ext
=
u'.'
+
self
.
settings
[
'new_book_format'
]
.
lower
()
# check to see if destination format already exists -
# check to see if destination format already exists -
or if book is in database
# if it does - mark the conversion task as complete and return a success
# this will allow send to kindle workflow to continue to work
if
os
.
path
.
isfile
(
file_path
+
format_new_ext
):
if
os
.
path
.
isfile
(
file_path
+
format_new_ext
)
or
\
local_db
.
get_book_format
(
self
.
bookid
,
self
.
settings
[
'new_book_format'
]):
log
.
info
(
"Book id
%
d already converted to
%
s"
,
book_id
,
format_new_ext
)
cur_book
=
local_db
.
get_book
(
book_id
)
self
.
results
[
'path'
]
=
file_path
...
...
@@ -111,7 +112,7 @@ class TaskConvert(CalibreTask):
if
check
==
0
:
cur_book
=
local_db
.
get_book
(
book_id
)
if
os
.
path
.
isfile
(
file_path
+
format_new_ext
):
#
self.db_queue.join(
)
#
check if format is already there and replace it if so, problem with gdrive kepub upload (why?
)
new_format
=
db
.
Data
(
name
=
cur_book
.
data
[
0
]
.
name
,
book_format
=
self
.
settings
[
'new_book_format'
]
.
upper
(),
book
=
book_id
,
uncompressed_size
=
os
.
path
.
getsize
(
file_path
+
format_new_ext
))
...
...
@@ -119,7 +120,7 @@ class TaskConvert(CalibreTask):
local_db
.
session
.
merge
(
new_format
)
local_db
.
session
.
commit
()
except
SQLAlchemyError
as
e
:
local_db
.
rollback
()
local_db
.
session
.
rollback
()
log
.
error
(
"Database error:
%
s"
,
e
)
local_db
.
session
.
close
()
return
...
...
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