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
93a9f651
Commit
93a9f651
authored
Sep 30, 2018
by
bodybybuddha
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://github.com/janeczku/calibre-web
into 621
parents
a7386ecb
5a2ed58d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
235 additions
and
192 deletions
+235
-192
book_formats.py
cps/book_formats.py
+4
-2
converter.py
cps/converter.py
+1
-1
gdriveutils.py
cps/gdriveutils.py
+11
-16
reverseproxy.py
cps/reverseproxy.py
+39
-0
server.py
cps/server.py
+4
-5
messages.po
cps/translations/de/LC_MESSAGES/messages.po
+1
-1
web.py
cps/web.py
+175
-167
No files found.
cps/book_formats.py
View file @
93a9f651
...
...
@@ -123,9 +123,11 @@ def pdf_preview(tmp_file_path, tmp_dir):
def
get_versions
():
if
not
use_generic_pdf_cover
:
IVersion
=
ImageVersion
.
MAGICK_VERSION
IVersion
=
ImageVersion
.
MAGICK_VERSION
WVersion
=
ImageVersion
.
VERSION
else
:
IVersion
=
_
(
u'not installed'
)
WVersion
=
_
(
u'not installed'
)
if
use_pdf_meta
:
PVersion
=
'v'
+
PyPdfVersion
else
:
...
...
@@ -134,4 +136,4 @@ def get_versions():
XVersion
=
'v'
+
'.'
.
join
(
map
(
str
,
lxmlversion
))
else
:
XVersion
=
_
(
u'not installed'
)
return
{
'Image Magick'
:
IVersion
,
'PyPdf'
:
PVersion
,
'lxml'
:
XVersion
}
return
{
'Image Magick'
:
IVersion
,
'PyPdf'
:
PVersion
,
'lxml'
:
XVersion
,
'Wand Version'
:
WVersion
}
cps/converter.py
View file @
93a9f651
...
...
@@ -45,5 +45,5 @@ def versioncheck():
elif
ub
.
config
.
config_ebookconverter
==
2
:
return
versionCalibre
()
else
:
return
{
'ebook_converter'
:
''
}
return
{
'ebook_converter'
:
_
(
u'not configured'
)
}
cps/gdriveutils.py
View file @
93a9f651
...
...
@@ -149,19 +149,19 @@ def getDrive(drive=None, gauth=None):
drive
.
auth
.
Refresh
()
return
drive
def
listRootFolders
(
drive
=
None
):
drive
=
getDrive
(
drive
)
def
listRootFolders
():
drive
=
getDrive
(
Gdrive
.
Instance
()
.
drive
)
folder
=
"'root' in parents and mimeType = 'application/vnd.google-apps.folder' and trashed = false"
fileList
=
drive
.
ListFile
({
'q'
:
folder
})
.
GetList
()
return
fileList
def
getEbooksFolder
(
drive
=
None
):
def
getEbooksFolder
(
drive
):
return
getFolderInFolder
(
'root'
,
config
.
config_google_drive_folder
,
drive
)
def
getFolderInFolder
(
parentId
,
folderName
,
drive
=
Non
e
):
drive
=
getDrive
(
drive
)
def
getFolderInFolder
(
parentId
,
folderName
,
driv
e
):
#
drive = getDrive(drive)
query
=
""
if
folderName
:
query
=
"title = '
%
s' and "
%
folderName
.
replace
(
"'"
,
"
\\
'"
)
...
...
@@ -190,7 +190,6 @@ def getEbooksFolderId(drive=None):
def
getFile
(
pathId
,
fileName
,
drive
):
# drive = getDrive(Gdrive.Instance().drive)
metaDataFile
=
"'
%
s' in parents and trashed = false and title = '
%
s'"
%
(
pathId
,
fileName
.
replace
(
"'"
,
"
\\
'"
))
fileList
=
drive
.
ListFile
({
'q'
:
metaDataFile
})
.
GetList
()
...
...
@@ -200,8 +199,8 @@ def getFile(pathId, fileName, drive):
return
fileList
[
0
]
def
getFolderId
(
path
,
drive
=
None
):
drive
=
getDrive
(
drive
)
def
getFolderId
(
path
,
drive
):
#
drive = getDrive(drive)
currentFolderId
=
getEbooksFolderId
(
drive
)
sqlCheckPath
=
path
if
path
[
-
1
]
==
'/'
else
path
+
'/'
storedPathName
=
session
.
query
(
GdriveId
)
.
filter
(
GdriveId
.
path
==
sqlCheckPath
)
.
first
()
...
...
@@ -249,7 +248,7 @@ def getFileFromEbooksFolder(path, fileName):
return
None
def
copyDriveFileRemote
(
drive
,
origin_file_id
,
copy_title
):
'''
def copyDriveFileRemote(drive, origin_file_id, copy_title):
drive = getDrive(drive)
copied_file = {'title': copy_title}
try:
...
...
@@ -258,7 +257,7 @@ def copyDriveFileRemote(drive, origin_file_id, copy_title):
return drive.CreateFile({'id': file_data['id']})
except errors.HttpError as error:
print ('An error occurred:
%
s'
%
error)
return
None
return None
'''
# Download metadata.db from gdrive
...
...
@@ -347,7 +346,6 @@ def uploadFileToEbooksFolder(destFile, f):
def
watchChange
(
drive
,
channel_id
,
channel_type
,
channel_address
,
channel_token
=
None
,
expiration
=
None
):
# drive = getDrive(drive)
# Watch for all changes to a user's Drive.
# Args:
# service: Drive API service instance.
...
...
@@ -390,8 +388,6 @@ def watchFile(drive, file_id, channel_id, channel_type, channel_address,
Raises:
apiclient.errors.HttpError: if http request to create channel fails.
"""
# drive = getDrive(drive)
body
=
{
'id'
:
channel_id
,
'type'
:
channel_type
,
...
...
@@ -413,8 +409,6 @@ def stopChannel(drive, channel_id, resource_id):
Raises:
apiclient.errors.HttpError: if http request to create channel fails.
"""
# drive = getDrive(drive)
# service=drive.auth.service
body
=
{
'id'
:
channel_id
,
'resourceId'
:
resource_id
...
...
@@ -423,7 +417,6 @@ def stopChannel(drive, channel_id, resource_id):
def
getChangeById
(
drive
,
change_id
):
# drive = getDrive(drive)
# Print a single Change resource information.
#
# Args:
...
...
@@ -454,11 +447,13 @@ def updateDatabaseOnEdit(ID,newPath):
storedPathName
.
path
=
newPath
session
.
commit
()
# Deletes the hashes in database of deleted book
def
deleteDatabaseEntry
(
ID
):
session
.
query
(
GdriveId
)
.
filter
(
GdriveId
.
gdrive_id
==
ID
)
.
delete
()
session
.
commit
()
# Gets cover file from gdrive
def
get_cover_via_gdrive
(
cover_path
):
df
=
getFileFromEbooksFolder
(
cover_path
,
'cover.jpg'
)
...
...
cps/reverseproxy.py
0 → 100644
View file @
93a9f651
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class
ReverseProxied
(
object
):
"""Wrap the application in this middleware and configure the
front-end server to add these headers, to let you quietly bind
this to a URL other than / and to an HTTP scheme that is
different than what is used locally.
Code courtesy of: http://flask.pocoo.org/snippets/35/
In nginx:
location /myprefix {
proxy_pass http://127.0.0.1:8083;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Script-Name /myprefix;
}
"""
def
__init__
(
self
,
application
):
self
.
app
=
application
def
__call__
(
self
,
environ
,
start_response
):
script_name
=
environ
.
get
(
'HTTP_X_SCRIPT_NAME'
,
''
)
if
script_name
:
environ
[
'SCRIPT_NAME'
]
=
script_name
path_info
=
environ
.
get
(
'PATH_INFO'
,
''
)
if
path_info
and
path_info
.
startswith
(
script_name
):
environ
[
'PATH_INFO'
]
=
path_info
[
len
(
script_name
):]
scheme
=
environ
.
get
(
'HTTP_X_SCHEME'
,
''
)
if
scheme
:
environ
[
'wsgi.url_scheme'
]
=
scheme
servr
=
environ
.
get
(
'HTTP_X_FORWARDED_SERVER'
,
''
)
if
servr
:
environ
[
'HTTP_HOST'
]
=
servr
return
self
.
app
(
environ
,
start_response
)
cps/server.py
View file @
93a9f651
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
socket
import
error
as
SocketError
import
sys
import
os
import
signal
import
web
try
:
from
gevent.pywsgi
import
WSGIServer
...
...
@@ -19,8 +19,6 @@ except ImportError:
from
tornado
import
version
as
tornadoVersion
gevent_present
=
False
import
web
class
server
:
...
...
@@ -29,7 +27,7 @@ class server:
def
__init__
(
self
):
signal
.
signal
(
signal
.
SIGINT
,
self
.
killServer
)
signal
.
signal
(
signal
.
SIGTERM
,
self
.
killServer
)
signal
.
signal
(
signal
.
SIGTERM
,
self
.
killServer
)
def
start_gevent
(
self
):
try
:
...
...
@@ -68,7 +66,8 @@ class server:
ssl_options
=
ssl
)
http_server
.
listen
(
web
.
ub
.
config
.
config_port
)
self
.
wsgiserver
=
IOLoop
.
instance
()
self
.
wsgiserver
.
start
()
# wait for stop signal
self
.
wsgiserver
.
start
()
# wait for stop signal
self
.
wsgiserver
.
close
(
True
)
if
self
.
restart
==
True
:
...
...
cps/translations/de/LC_MESSAGES/messages.po
View file @
93a9f651
...
...
@@ -1173,7 +1173,7 @@ msgstr "Pfad zu Konvertertool"
#: cps/templates/config_edit.html:199
msgid "Location of Unrar binary"
msgstr "
O
fad zum UnRar Programm"
msgstr "
P
fad zum UnRar Programm"
#: cps/templates/config_edit.html:215 cps/templates/layout.html:82
#: cps/templates/login.html:4
...
...
cps/web.py
View file @
93a9f651
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