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
952d389d
Commit
952d389d
authored
Apr 15, 2016
by
JanB
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ship config.ini with defaults; log errors to file; fix OPDS catalog name
parent
b99c793a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
46 additions
and
25 deletions
+46
-25
config.ini
config.ini
+11
-0
config.py
cps/config.py
+12
-1
feed.xml
cps/templates/feed.xml
+3
-3
index.xml
cps/templates/index.xml
+3
-3
osd.xml
cps/templates/osd.xml
+5
-5
search.xml
cps/templates/search.xml
+5
-5
web.py
cps/web.py
+5
-5
readme.md
readme.md
+2
-3
No files found.
config.ini
0 → 100644
View file @
952d389d
[General]
DB_ROOT
=
APP_DB_ROOT =
MAIN_DIR
=
LOG_DIR =
PORT
=
8083
NEWEST_BOOKS
=
60
[Advanced]
TITLE_REGEX
=
^(A|The|An|Der|Die|Das|Den|Ein|Eine|Einen|Dem|Des|Einem|Eines)
\s
+
DEVELOPMENT
=
0
PUBLIC_REG
=
0
cps/config.py
View file @
952d389d
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
# -*- coding: utf-8 -*-
import
os
import
os
import
sys
from
configobj
import
ConfigObj
from
configobj
import
ConfigObj
...
@@ -20,6 +21,9 @@ def CheckSection(sec):
...
@@ -20,6 +21,9 @@ def CheckSection(sec):
def
check_setting_str
(
config
,
cfg_name
,
item_name
,
def_val
,
log
=
True
):
def
check_setting_str
(
config
,
cfg_name
,
item_name
,
def_val
,
log
=
True
):
try
:
try
:
my_val
=
config
[
cfg_name
][
item_name
]
my_val
=
config
[
cfg_name
][
item_name
]
if
my_val
==
""
:
my_val
=
def_val
config
[
cfg_name
][
item_name
]
=
my_val
except
:
except
:
my_val
=
def_val
my_val
=
def_val
try
:
try
:
...
@@ -43,9 +47,10 @@ def check_setting_int(config, cfg_name, item_name, def_val):
...
@@ -43,9 +47,10 @@ def check_setting_int(config, cfg_name, item_name, def_val):
return
my_val
return
my_val
CheckSection
(
'General'
)
CheckSection
(
'General'
)
DB_ROOT
=
check_setting_str
(
CFG
,
'General'
,
'DB_ROOT'
,
os
.
path
.
join
(
os
.
getcwd
(),
"Calibre Library"
)
)
DB_ROOT
=
check_setting_str
(
CFG
,
'General'
,
'DB_ROOT'
,
""
)
APP_DB_ROOT
=
check_setting_str
(
CFG
,
'General'
,
'APP_DB_ROOT'
,
os
.
getcwd
())
APP_DB_ROOT
=
check_setting_str
(
CFG
,
'General'
,
'APP_DB_ROOT'
,
os
.
getcwd
())
MAIN_DIR
=
check_setting_str
(
CFG
,
'General'
,
'MAIN_DIR'
,
os
.
getcwd
())
MAIN_DIR
=
check_setting_str
(
CFG
,
'General'
,
'MAIN_DIR'
,
os
.
getcwd
())
LOG_DIR
=
check_setting_str
(
CFG
,
'General'
,
'LOG_DIR'
,
os
.
getcwd
())
PORT
=
check_setting_int
(
CFG
,
'General'
,
'PORT'
,
8083
)
PORT
=
check_setting_int
(
CFG
,
'General'
,
'PORT'
,
8083
)
NEWEST_BOOKS
=
check_setting_str
(
CFG
,
'General'
,
'NEWEST_BOOKS'
,
60
)
NEWEST_BOOKS
=
check_setting_str
(
CFG
,
'General'
,
'NEWEST_BOOKS'
,
60
)
RANDOM_BOOKS
=
check_setting_int
(
CFG
,
'General'
,
'RANDOM_BOOKS'
,
4
)
RANDOM_BOOKS
=
check_setting_int
(
CFG
,
'General'
,
'RANDOM_BOOKS'
,
4
)
...
@@ -57,10 +62,15 @@ PUBLIC_REG = bool(check_setting_int(CFG, 'Advanced', 'PUBLIC_REG', 0))
...
@@ -57,10 +62,15 @@ PUBLIC_REG = bool(check_setting_int(CFG, 'Advanced', 'PUBLIC_REG', 0))
SYS_ENCODING
=
"UTF-8"
SYS_ENCODING
=
"UTF-8"
if
DB_ROOT
==
""
:
print
"Calibre database directory (DB_ROOT) is not configured"
sys
.
exit
(
1
)
configval
=
{}
configval
=
{}
configval
[
"DB_ROOT"
]
=
DB_ROOT
configval
[
"DB_ROOT"
]
=
DB_ROOT
configval
[
"APP_DB_ROOT"
]
=
APP_DB_ROOT
configval
[
"APP_DB_ROOT"
]
=
APP_DB_ROOT
configval
[
"MAIN_DIR"
]
=
MAIN_DIR
configval
[
"MAIN_DIR"
]
=
MAIN_DIR
configval
[
"LOG_DIR"
]
=
LOG_DIR
configval
[
"PORT"
]
=
PORT
configval
[
"PORT"
]
=
PORT
configval
[
"NEWEST_BOOKS"
]
=
NEWEST_BOOKS
configval
[
"NEWEST_BOOKS"
]
=
NEWEST_BOOKS
configval
[
"DEVELOPMENT"
]
=
DEVELOPMENT
configval
[
"DEVELOPMENT"
]
=
DEVELOPMENT
...
@@ -74,6 +84,7 @@ def save_config(configval):
...
@@ -74,6 +84,7 @@ def save_config(configval):
new_config
[
'General'
][
'DB_ROOT'
]
=
configval
[
"DB_ROOT"
]
new_config
[
'General'
][
'DB_ROOT'
]
=
configval
[
"DB_ROOT"
]
new_config
[
'General'
][
'APP_DB_ROOT'
]
=
configval
[
"APP_DB_ROOT"
]
new_config
[
'General'
][
'APP_DB_ROOT'
]
=
configval
[
"APP_DB_ROOT"
]
new_config
[
'General'
][
'MAIN_DIR'
]
=
configval
[
"MAIN_DIR"
]
new_config
[
'General'
][
'MAIN_DIR'
]
=
configval
[
"MAIN_DIR"
]
new_config
[
'General'
][
'LOG_DIR'
]
=
configval
[
"LOG_DIR"
]
new_config
[
'General'
][
'PORT'
]
=
configval
[
"PORT"
]
new_config
[
'General'
][
'PORT'
]
=
configval
[
"PORT"
]
new_config
[
'General'
][
'NEWEST_BOOKS'
]
=
configval
[
"NEWEST_BOOKS"
]
new_config
[
'General'
][
'NEWEST_BOOKS'
]
=
configval
[
"NEWEST_BOOKS"
]
new_config
[
'Advanced'
]
=
{}
new_config
[
'Advanced'
]
=
{}
...
...
cps/templates/feed.xml
View file @
952d389d
...
@@ -16,11 +16,11 @@
...
@@ -16,11 +16,11 @@
<link
rel=
"search"
<link
rel=
"search"
href=
"{{url_for('feed_osd')}}"
href=
"{{url_for('feed_osd')}}"
type=
"application/opensearchdescription+xml"
/>
type=
"application/opensearchdescription+xml"
/>
<title>
library
</title>
<title>
Calibre Web
</title>
<updated>
2010-01-10T10:03:10Z
</updated>
<updated>
2010-01-10T10:03:10Z
</updated>
<author>
<author>
<name>
cytec
</name>
<name>
Calibre Web
</name>
<uri>
http
://opds-spec.org
</uri>
<uri>
http
s://github.com/janeczku/calibre-web
</uri>
</author>
</author>
{% for entry in entries %}
{% for entry in entries %}
...
...
cps/templates/index.xml
View file @
952d389d
...
@@ -16,11 +16,11 @@
...
@@ -16,11 +16,11 @@
<link
rel=
"search"
<link
rel=
"search"
href=
"{{url_for('feed_osd')}}"
href=
"{{url_for('feed_osd')}}"
type=
"application/opensearchdescription+xml"
/>
type=
"application/opensearchdescription+xml"
/>
<title>
library
</title>
<title>
Calibre Web
</title>
<updated>
2010-01-10T10:03:10Z
</updated>
<updated>
2010-01-10T10:03:10Z
</updated>
<author>
<author>
<name>
Spec Writer
</name>
<name>
Calibre Web
</name>
<uri>
http
://opds-spec.org
</uri>
<uri>
http
s://github.com/janeczku/calibre-web
</uri>
</author>
</author>
...
...
cps/templates/osd.xml
View file @
952d389d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription
xmlns=
"http://a9.com/-/spec/opensearch/1.1/"
>
<OpenSearchDescription
xmlns=
"http://a9.com/-/spec/opensearch/1.1/"
>
<LongName>
library
</LongName>
<LongName>
Calibre Web
</LongName>
<ShortName>
library
</ShortName>
<ShortName>
Calibre Web
</ShortName>
<Description>
Search the ebook catalog.
</Description>
<Description>
Calibre Web ebook catalog
</Description>
<Developer>
cytec
</Developer>
<Developer>
janeczku
</Developer>
<Contact>
iamcytec@googlemail.com
</Contact>
<Contact>
https://github.com/janeczku/calibre-web
</Contact>
<Url
type=
"text/html"
<Url
type=
"text/html"
template=
"{{url_for('search')}}?query={searchTerms}"
/>
template=
"{{url_for('search')}}?query={searchTerms}"
/>
...
...
cps/templates/search.xml
View file @
952d389d
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription
xmlns=
"http://a9.com/-/spec/opensearch/1.1/"
>
<OpenSearchDescription
xmlns=
"http://a9.com/-/spec/opensearch/1.1/"
>
<LongName>
library
</LongName>
<LongName>
Calibre Web
</LongName>
<ShortName>
library
</ShortName>
<ShortName>
Calibre Web
</ShortName>
<Description>
Search the ebook catalog.
</Description>
<Description>
Calibre Web ebook catalog
</Description>
<Developer>
cytec
</Developer>
<Developer>
janeczku
</Developer>
<Contact>
iamcytec@googlemail.com
</Contact>
<Contact>
https://github.com/janeczku/calibre-web
</Contact>
<Url
type=
"text/html"
<Url
type=
"text/html"
template=
"{{url_for('search')}}?query={searchTerms}"
/>
template=
"{{url_for('search')}}?query={searchTerms}"
/>
...
...
cps/web.py
View file @
952d389d
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
import
mimetypes
import
mimetypes
import
logging
import
logging
from
logging.handlers
import
RotatingFileHandler
import
sys
import
sys
import
textwrap
import
textwrap
mimetypes
.
add_type
(
'application/xhtml+xml'
,
'.xhtml'
)
mimetypes
.
add_type
(
'application/xhtml+xml'
,
'.xhtml'
)
...
@@ -32,13 +33,12 @@ from shutil import copyfile
...
@@ -32,13 +33,12 @@ from shutil import copyfile
app
=
(
Flask
(
__name__
))
app
=
(
Flask
(
__name__
))
# Log only in production mode.
formatter
=
logging
.
Formatter
(
#if not app.debug:
"[
%(asctime)
s] {
%(pathname)
s:
%(lineno)
d}
%(levelname)
s -
%(message)
s"
)
file_handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
file_handler
=
RotatingFileHandler
(
os
.
path
.
join
(
config
.
LOG_DIR
,
"calibre-web.log"
),
maxBytes
=
10000
,
backupCount
=
1
)
file_handler
.
setLevel
(
logging
.
INFO
)
file_handler
.
setLevel
(
logging
.
INFO
)
file_handler
.
setFormatter
(
formatter
)
app
.
logger
.
addHandler
(
file_handler
)
app
.
logger
.
addHandler
(
file_handler
)
app
.
logger_name
=
'calibre web'
app
.
logger
.
setLevel
(
logging
.
INFO
)
app
.
logger
.
info
(
'Starting Calibre Web...'
)
app
.
logger
.
info
(
'Starting Calibre Web...'
)
Principal
(
app
)
Principal
(
app
)
...
...
readme.md
View file @
952d389d
...
@@ -25,9 +25,8 @@ Also available as [Docker image](https://registry.hub.docker.com/u/janeczku/cali
...
@@ -25,9 +25,8 @@ Also available as [Docker image](https://registry.hub.docker.com/u/janeczku/cali
## Quick start
## Quick start
1.
Execute the command:
`python cps.py`
(it will throw an error)
1.
Open config.ini and set DB_ROOT to the path of the folder where your Calibre library (metadata.db) lives
2.
Edit config.ini and set DB_ROOT to the path of the folder where your Calibre library (metadata.db) lives
3.
To enable public user registration set PUBLIC_REG to 1
3.
If you want to enable public user registration set PUBLIC_REG to 1
4.
Execute the command:
`python cps.py`
4.
Execute the command:
`python cps.py`
5.
Point your browser to
`http://localhost:8083`
or
`http://localhost:8083/feed`
for the OPDS catalog
5.
Point your browser to
`http://localhost:8083`
or
`http://localhost:8083/feed`
for the OPDS catalog
...
...
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