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
6940bb9b
Commit
6940bb9b
authored
Mar 24, 2019
by
Ozzieisaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code improvement
parent
07649d04
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
22 additions
and
31 deletions
+22
-31
admin.py
cps/admin.py
+1
-1
helper.py
cps/helper.py
+5
-0
opds.py
cps/opds.py
+0
-5
unrar.js
cps/static/js/unrar.js
+4
-4
unzip.js
cps/static/js/unzip.js
+8
-9
updater.py
cps/updater.py
+0
-3
web.py
cps/web.py
+4
-9
No files found.
cps/admin.py
View file @
6940bb9b
...
@@ -529,7 +529,7 @@ def new_user():
...
@@ -529,7 +529,7 @@ def new_user():
content
.
locale
=
to_save
[
"locale"
]
content
.
locale
=
to_save
[
"locale"
]
val
=
0
val
=
0
for
key
,
v
in
to_save
.
items
():
for
key
,
_
in
to_save
.
items
():
if
key
.
startswith
(
'show'
):
if
key
.
startswith
(
'show'
):
val
+=
int
(
key
[
5
:])
val
+=
int
(
key
[
5
:])
content
.
sidebar_view
=
val
content
.
sidebar_view
=
val
...
...
cps/helper.py
View file @
6940bb9b
...
@@ -67,6 +67,11 @@ try:
...
@@ -67,6 +67,11 @@ try:
except
ImportError
:
except
ImportError
:
use_levenshtein
=
False
use_levenshtein
=
False
try
:
from
functools
import
reduce
except
ImportError
:
pass
# We're not using Python 3
def
update_download
(
book_id
,
user_id
):
def
update_download
(
book_id
,
user_id
):
check
=
ub
.
session
.
query
(
ub
.
Downloads
)
.
filter
(
ub
.
Downloads
.
user_id
==
user_id
)
.
filter
(
ub
.
Downloads
.
book_id
==
check
=
ub
.
session
.
query
(
ub
.
Downloads
)
.
filter
(
ub
.
Downloads
.
user_id
==
user_id
)
.
filter
(
ub
.
Downloads
.
book_id
==
...
...
cps/opds.py
View file @
6940bb9b
...
@@ -37,11 +37,6 @@ from werkzeug.security import check_password_hash
...
@@ -37,11 +37,6 @@ from werkzeug.security import check_password_hash
from
helper
import
fill_indexpage
from
helper
import
fill_indexpage
import
sys
import
sys
try
:
from
urllib.parse
import
quote
except
ImportError
:
from
urllib
import
quote
opds
=
Blueprint
(
'opds'
,
__name__
)
opds
=
Blueprint
(
'opds'
,
__name__
)
...
...
cps/static/js/unrar.js
View file @
6940bb9b
...
@@ -641,7 +641,7 @@ function unpack29(bstream) {
...
@@ -641,7 +641,7 @@ function unpack29(bstream) {
continue
;
continue
;
}
}
if
(
num
===
258
)
{
if
(
num
===
258
)
{
if
(
lastLength
!=
0
)
{
if
(
lastLength
!=
=
0
)
{
rarCopyString
(
lastLength
,
lastDist
);
rarCopyString
(
lastLength
,
lastDist
);
}
}
continue
;
continue
;
...
@@ -690,7 +690,7 @@ function rarReadEndOfBlock(bstream) {
...
@@ -690,7 +690,7 @@ function rarReadEndOfBlock(bstream) {
NewTable
=
!!
bstream
.
readBits
(
1
);
NewTable
=
!!
bstream
.
readBits
(
1
);
}
}
//tablesRead = !NewTable;
//tablesRead = !NewTable;
return
!
(
NewFile
||
NewTable
&&
!
rarReadTables
(
bstream
));
return
!
(
NewFile
||
(
NewTable
&&
!
rarReadTables
(
bstream
)
));
}
}
...
@@ -784,7 +784,7 @@ var RarLocalFile = function(bstream) {
...
@@ -784,7 +784,7 @@ var RarLocalFile = function(bstream) {
this
.
header
=
new
RarVolumeHeader
(
bstream
);
this
.
header
=
new
RarVolumeHeader
(
bstream
);
this
.
filename
=
this
.
header
.
filename
;
this
.
filename
=
this
.
header
.
filename
;
if
(
this
.
header
.
headType
!=
FILE_HEAD
&&
this
.
header
.
headType
!
=
ENDARC_HEAD
)
{
if
(
this
.
header
.
headType
!=
=
FILE_HEAD
&&
this
.
header
.
headType
!=
=
ENDARC_HEAD
)
{
this
.
isValid
=
false
;
this
.
isValid
=
false
;
info
(
"Error! RAR Volume did not include a FILE_HEAD header "
);
info
(
"Error! RAR Volume did not include a FILE_HEAD header "
);
}
else
{
}
else
{
...
@@ -840,7 +840,7 @@ var unrar = function(arrayBuffer) {
...
@@ -840,7 +840,7 @@ var unrar = function(arrayBuffer) {
info
(
"Found RAR signature"
);
info
(
"Found RAR signature"
);
var
mhead
=
new
RarVolumeHeader
(
bstream
);
var
mhead
=
new
RarVolumeHeader
(
bstream
);
if
(
mhead
.
headType
!=
MAIN_HEAD
)
{
if
(
mhead
.
headType
!=
=
MAIN_HEAD
)
{
info
(
"Error! RAR did not include a MAIN_HEAD header"
);
info
(
"Error! RAR did not include a MAIN_HEAD header"
);
}
else
{
}
else
{
var
localFiles
=
[];
var
localFiles
=
[];
...
...
cps/static/js/unzip.js
View file @
6940bb9b
...
@@ -179,7 +179,7 @@ var unzip = function(arrayBuffer) {
...
@@ -179,7 +179,7 @@ var unzip = function(arrayBuffer) {
info
(
" Found a Central File Header"
);
info
(
" Found a Central File Header"
);
// read all file headers
// read all file headers
while
(
bstream
.
peekNumber
(
4
)
==
zCentralFileHeaderSignature
)
{
while
(
bstream
.
peekNumber
(
4
)
==
=
zCentralFileHeaderSignature
)
{
bstream
.
readNumber
(
4
);
// signature
bstream
.
readNumber
(
4
);
// signature
bstream
.
readNumber
(
2
);
// version made by
bstream
.
readNumber
(
2
);
// version made by
bstream
.
readNumber
(
2
);
// version needed to extract
bstream
.
readNumber
(
2
);
// version needed to extract
...
@@ -264,7 +264,7 @@ function getHuffmanCodes(bitLengths) {
...
@@ -264,7 +264,7 @@ function getHuffmanCodes(bitLengths) {
return
null
;
return
null
;
}
}
// increment the appropriate bitlength count
// increment the appropriate bitlength count
if
(
blCount
[
length
]
==
undefined
)
blCount
[
length
]
=
0
;
if
(
typeof
blCount
[
length
]
===
"undefined"
)
blCount
[
length
]
=
0
;
// a length of zero means this symbol is not participating in the huffman coding
// a length of zero means this symbol is not participating in the huffman coding
if
(
length
>
0
)
blCount
[
length
]
++
;
if
(
length
>
0
)
blCount
[
length
]
++
;
...
@@ -277,7 +277,7 @@ function getHuffmanCodes(bitLengths) {
...
@@ -277,7 +277,7 @@ function getHuffmanCodes(bitLengths) {
for
(
var
bits
=
1
;
bits
<=
MAX_BITS
;
++
bits
)
{
for
(
var
bits
=
1
;
bits
<=
MAX_BITS
;
++
bits
)
{
var
length2
=
bits
-
1
;
var
length2
=
bits
-
1
;
// ensure undefined lengths are zero
// ensure undefined lengths are zero
if
(
blCount
[
length2
]
==
undefined
)
blCount
[
length2
]
=
0
;
if
(
typeof
blCount
[
length2
]
===
"undefined"
)
blCount
[
length2
]
=
0
;
code
=
(
code
+
blCount
[
bits
-
1
])
<<
1
;
code
=
(
code
+
blCount
[
bits
-
1
])
<<
1
;
nextCode
[
bits
]
=
code
;
nextCode
[
bits
]
=
code
;
}
}
...
@@ -522,11 +522,11 @@ function inflate(compressedData, numDecompressedBytes) {
...
@@ -522,11 +522,11 @@ function inflate(compressedData, numDecompressedBytes) {
bFinal
=
bstream
.
readBits
(
1
);
bFinal
=
bstream
.
readBits
(
1
);
var
bType
=
bstream
.
readBits
(
2
);
var
bType
=
bstream
.
readBits
(
2
);
blockSize
=
0
;
blockSize
=
0
;
++
numBlocks
;
//
++numBlocks;
// no compression
// no compression
if
(
bType
==
0
)
{
if
(
bType
==
0
)
{
// skip remaining bits in this byte
// skip remaining bits in this byte
while
(
bstream
.
bitPtr
!=
0
)
bstream
.
readBits
(
1
);
while
(
bstream
.
bitPtr
!=
=
0
)
bstream
.
readBits
(
1
);
var
len
=
bstream
.
readBits
(
16
);
var
len
=
bstream
.
readBits
(
16
);
bstream
.
readBits
(
16
);
bstream
.
readBits
(
16
);
// TODO: check if nlen is the ones-complement of len?
// TODO: check if nlen is the ones-complement of len?
...
@@ -535,11 +535,11 @@ function inflate(compressedData, numDecompressedBytes) {
...
@@ -535,11 +535,11 @@ function inflate(compressedData, numDecompressedBytes) {
blockSize
=
len
;
blockSize
=
len
;
}
}
// fixed Huffman codes
// fixed Huffman codes
else
if
(
bType
==
1
)
{
else
if
(
bType
==
=
1
)
{
blockSize
=
inflateBlockData
(
bstream
,
getFixedLiteralTable
(),
getFixedDistanceTable
(),
buffer
);
blockSize
=
inflateBlockData
(
bstream
,
getFixedLiteralTable
(),
getFixedDistanceTable
(),
buffer
);
}
}
// dynamic Huffman codes
// dynamic Huffman codes
else
if
(
bType
==
2
)
{
else
if
(
bType
==
=
2
)
{
var
numLiteralLengthCodes
=
bstream
.
readBits
(
5
)
+
257
;
var
numLiteralLengthCodes
=
bstream
.
readBits
(
5
)
+
257
;
var
numDistanceCodes
=
bstream
.
readBits
(
5
)
+
1
,
var
numDistanceCodes
=
bstream
.
readBits
(
5
)
+
1
,
numCodeLengthCodes
=
bstream
.
readBits
(
4
)
+
4
;
numCodeLengthCodes
=
bstream
.
readBits
(
4
)
+
4
;
...
@@ -576,8 +576,7 @@ function inflate(compressedData, numDecompressedBytes) {
...
@@ -576,8 +576,7 @@ function inflate(compressedData, numDecompressedBytes) {
if
(
symbol
<=
15
)
{
if
(
symbol
<=
15
)
{
literalCodeLengths
.
push
(
symbol
);
literalCodeLengths
.
push
(
symbol
);
prevCodeLength
=
symbol
;
prevCodeLength
=
symbol
;
}
}
else
if
(
symbol
===
16
)
{
else
if
(
symbol
===
16
)
{
var
repeat
=
bstream
.
readBits
(
2
)
+
3
;
var
repeat
=
bstream
.
readBits
(
2
)
+
3
;
while
(
repeat
--
)
{
while
(
repeat
--
)
{
literalCodeLengths
.
push
(
prevCodeLength
);
literalCodeLengths
.
push
(
prevCodeLength
);
...
...
cps/updater.py
View file @
6940bb9b
...
@@ -341,9 +341,6 @@ class Updater(threading.Thread):
...
@@ -341,9 +341,6 @@ class Updater(threading.Thread):
else
:
else
:
status
[
'success'
]
=
False
status
[
'success'
]
=
False
status
[
'message'
]
=
_
(
u'Could not fetch update information'
)
status
[
'message'
]
=
_
(
u'Could not fetch update information'
)
# a new update is available
status
[
'history'
]
=
parents
[::
-
1
]
return
json
.
dumps
(
status
)
return
json
.
dumps
(
status
)
return
''
return
''
...
...
cps/web.py
View file @
6940bb9b
...
@@ -41,7 +41,6 @@ from sqlalchemy.sql.expression import text, func, true, false, not_
...
@@ -41,7 +41,6 @@ from sqlalchemy.sql.expression import text, func, true, false, not_
import
json
import
json
import
datetime
import
datetime
from
iso639
import
languages
as
isoLanguages
from
iso639
import
languages
as
isoLanguages
import
re
import
gdriveutils
import
gdriveutils
from
redirect
import
redirect_back
from
redirect
import
redirect_back
from
cps
import
lm
,
babel
,
ub
,
config
,
get_locale
,
language_table
,
app
,
db
from
cps
import
lm
,
babel
,
ub
,
config
,
get_locale
,
language_table
,
app
,
db
...
@@ -69,7 +68,7 @@ except ImportError:
...
@@ -69,7 +68,7 @@ except ImportError:
feature_support
[
'goodreads'
]
=
False
feature_support
[
'goodreads'
]
=
False
try
:
try
:
from
functools
import
reduce
,
wraps
from
functools
import
wraps
except
ImportError
:
except
ImportError
:
pass
# We're not using Python 3
pass
# We're not using Python 3
...
@@ -84,11 +83,6 @@ try:
...
@@ -84,11 +83,6 @@ try:
except
ImportError
:
except
ImportError
:
sort
=
sorted
# Just use regular sort then, may cause issues with badly named pages in cbz/cbr files
sort
=
sorted
# Just use regular sort then, may cause issues with badly named pages in cbz/cbr files
try
:
from
urllib.parse
import
quote
except
ImportError
:
from
urllib
import
quote
from
flask
import
Blueprint
from
flask
import
Blueprint
# Global variables
# Global variables
...
@@ -944,7 +938,8 @@ def advanced_search():
...
@@ -944,7 +938,8 @@ def advanced_search():
series
=
series
,
title
=
_
(
u"search"
),
cc
=
cc
,
page
=
"advsearch"
)
series
=
series
,
title
=
_
(
u"search"
),
cc
=
cc
,
page
=
"advsearch"
)
def
render_read_books
(
page
,
are_read
,
as_xml
=
False
,
order
=
[]):
def
render_read_books
(
page
,
are_read
,
as_xml
=
False
,
order
=
None
):
order
=
order
or
[]
if
not
config
.
config_read_column
:
if
not
config
.
config_read_column
:
readBooks
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
))
\
readBooks
=
ub
.
session
.
query
(
ub
.
ReadBook
)
.
filter
(
ub
.
ReadBook
.
user_id
==
int
(
current_user
.
id
))
\
.
filter
(
ub
.
ReadBook
.
is_read
is
True
)
.
all
()
.
filter
(
ub
.
ReadBook
.
is_read
is
True
)
.
all
()
...
@@ -1271,7 +1266,7 @@ def profile():
...
@@ -1271,7 +1266,7 @@ def profile():
current_user
.
locale
=
to_save
[
"locale"
]
current_user
.
locale
=
to_save
[
"locale"
]
val
=
0
val
=
0
for
key
,
v
in
to_save
.
items
():
for
key
,
_
in
to_save
.
items
():
if
key
.
startswith
(
'show'
):
if
key
.
startswith
(
'show'
):
val
+=
int
(
key
[
5
:])
val
+=
int
(
key
[
5
:])
current_user
.
sidebar_view
=
val
current_user
.
sidebar_view
=
val
...
...
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