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
2a975515
Commit
2a975515
authored
Oct 27, 2021
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add douban metadata provider
parent
857584a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
douban.py
cps/metadata_provider/douban.py
+42
-0
No files found.
cps/metadata_provider/douban.py
0 → 100644
View file @
2a975515
# -*- coding: utf-8 -*-
import
requests
from
cps.services.Metadata
import
Metadata
class
Google
(
Metadata
):
__name__
=
"豆瓣"
__id__
=
"douban"
__url__
=
"http://192.168.1.90:8085"
def
search
(
self
,
query
,
__
):
if
self
.
active
:
val
=
list
()
result
=
requests
.
get
(
self
.
__url__
+
"/v2/book/search?q="
+
query
.
replace
(
" "
,
"+"
))
for
r
in
result
.
json
()[
'books'
]:
v
=
dict
()
v
[
'id'
]
=
r
[
'id'
]
v
[
'title'
]
=
r
[
'title'
]
v
[
'authors'
]
=
r
.
get
(
'author'
,
[])
v
[
'description'
]
=
r
.
get
(
'summary'
,
""
)
v
[
'publisher'
]
=
r
.
get
(
'publisher'
,
""
)
v
[
'publishedDate'
]
=
r
.
get
(
'pubdate'
,
""
)
v
[
'tags'
]
=
[
i
[
"name"
]
for
i
in
r
.
get
(
'tags'
)]
if
r
.
get
(
'tags'
)
else
[]
if
r
.
get
(
'rating'
):
rating
=
float
(
r
.
get
(
'rating'
)
.
get
(
'average'
))
/
2.0
else
:
rating
=
0
v
[
'rating'
]
=
rating
if
r
.
get
(
'image'
):
v
[
'cover'
]
=
r
[
'image'
]
else
:
v
[
'cover'
]
=
"/../../../static/generic_cover.jpg"
v
[
'source'
]
=
{
"id"
:
self
.
__id__
,
"description"
:
"豆瓣图书"
,
"link"
:
"https://book.douban.com/"
}
v
[
'url'
]
=
self
.
__url__
+
"/v2/book/"
+
r
[
'id'
]
val
.
append
(
v
)
return
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