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
ec7803fa
Commit
ec7803fa
authored
Jul 08, 2021
by
Ozzie Isaacs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update python search Metadata
parent
aa2d3d2b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
52 additions
and
21 deletions
+52
-21
comicvine.py
cps/metadata_provider/comicvine.py
+3
-2
google.py
cps/metadata_provider/google.py
+2
-1
scholar.py
cps/metadata_provider/scholar.py
+3
-2
search_metadata.py
cps/search_metadata.py
+18
-2
get_meta.js
cps/static/js/get_meta.js
+25
-4
book_edit.html
cps/templates/book_edit.html
+1
-10
No files found.
cps/metadata_provider/comicvine.py
View file @
ec7803fa
...
@@ -21,13 +21,14 @@
...
@@ -21,13 +21,14 @@
import
requests
import
requests
from
cps.services.Metadata
import
Metadata
from
cps.services.Metadata
import
Metadata
apikey
=
"57558043c53943d5d1e96a9ad425b0eb85532ee6"
class
ComicVine
(
Metadata
):
class
ComicVine
(
Metadata
):
__name__
=
"ComicVine"
__name__
=
"ComicVine"
__id__
=
"comicvine"
def
search
(
self
,
query
):
def
search
(
self
,
query
):
val
=
list
()
val
=
list
()
apikey
=
"57558043c53943d5d1e96a9ad425b0eb85532ee6"
if
self
.
active
:
if
self
.
active
:
headers
=
{
headers
=
{
'User-Agent'
:
'Not Evil Browser'
# ,
'User-Agent'
:
'Not Evil Browser'
# ,
...
@@ -53,7 +54,7 @@ class ComicVine(Metadata):
...
@@ -53,7 +54,7 @@ class ComicVine(Metadata):
v
[
'series'
]
=
seriesTitle
v
[
'series'
]
=
seriesTitle
v
[
'cover'
]
=
r
[
'image'
]
.
get
(
'original_url'
)
v
[
'cover'
]
=
r
[
'image'
]
.
get
(
'original_url'
)
v
[
'source'
]
=
{
v
[
'source'
]
=
{
"id"
:
"comicvine"
,
"id"
:
self
.
__id__
,
"description"
:
"ComicVine Books"
,
"description"
:
"ComicVine Books"
,
"link"
:
"https://comicvine.gamespot.com/"
"link"
:
"https://comicvine.gamespot.com/"
}
}
...
...
cps/metadata_provider/google.py
View file @
ec7803fa
...
@@ -24,6 +24,7 @@ from cps.services.Metadata import Metadata
...
@@ -24,6 +24,7 @@ from cps.services.Metadata import Metadata
class
Google
(
Metadata
):
class
Google
(
Metadata
):
__name__
=
"Google"
__name__
=
"Google"
__id__
=
"google"
def
search
(
self
,
query
):
def
search
(
self
,
query
):
if
self
.
active
:
if
self
.
active
:
...
@@ -44,7 +45,7 @@ class Google(Metadata):
...
@@ -44,7 +45,7 @@ class Google(Metadata):
else
:
else
:
v
[
'cover'
]
=
"/../../../static/generic_cover.jpg"
v
[
'cover'
]
=
"/../../../static/generic_cover.jpg"
v
[
'source'
]
=
{
v
[
'source'
]
=
{
"id"
:
"google"
,
"id"
:
self
.
__id__
,
"description"
:
"Google Books"
,
"description"
:
"Google Books"
,
"link"
:
"https://books.google.com/"
}
"link"
:
"https://books.google.com/"
}
v
[
'url'
]
=
""
v
[
'url'
]
=
""
...
...
cps/metadata_provider/scholar.py
View file @
ec7803fa
...
@@ -29,7 +29,8 @@ from cps.services.Metadata import Metadata
...
@@ -29,7 +29,8 @@ from cps.services.Metadata import Metadata
class
scholar
(
Metadata
):
class
scholar
(
Metadata
):
__name__
=
"ComicVine"
__name__
=
"Google Scholar"
__id__
=
"googlescholar"
def
search
(
self
,
query
):
def
search
(
self
,
query
):
val
=
list
()
val
=
list
()
...
@@ -53,7 +54,7 @@ class scholar(Metadata):
...
@@ -53,7 +54,7 @@ class scholar(Metadata):
v
[
'cover'
]
=
"/../../../static/generic_cover.jpg"
v
[
'cover'
]
=
"/../../../static/generic_cover.jpg"
v
[
'url'
]
=
""
v
[
'url'
]
=
""
v
[
'source'
]
=
{
v
[
'source'
]
=
{
"id"
:
"googlescholar"
,
"id"
:
self
.
__id__
,
"description"
:
"Google Scholar"
,
"description"
:
"Google Scholar"
,
"link"
:
"https://scholar.google.com/"
"link"
:
"https://scholar.google.com/"
}
}
...
...
cps/search_metadata.py
View file @
ec7803fa
...
@@ -24,6 +24,7 @@ import sys
...
@@ -24,6 +24,7 @@ import sys
import
inspect
import
inspect
from
flask
import
Blueprint
,
request
,
Response
from
flask
import
Blueprint
,
request
,
Response
from
flask_login
import
current_user
from
flask_login
import
login_required
from
flask_login
import
login_required
from
.
import
constants
,
logger
from
.
import
constants
,
logger
...
@@ -59,14 +60,29 @@ cl = list_classes(new_list)
...
@@ -59,14 +60,29 @@ cl = list_classes(new_list)
@
meta
.
route
(
"/metadata/provider"
)
@
meta
.
route
(
"/metadata/provider"
)
@
login_required
@
login_required
def
metadata_provider
():
def
metadata_provider
():
return
""
active
=
current_user
.
view_settings
.
get
(
'metadata'
,
{})
provider
=
list
()
for
c
in
cl
:
provider
.
append
({
"name"
:
c
.
__name__
,
"active"
:
active
.
get
(
c
.
__name__
,
True
),
"id"
:
c
.
__id__
})
return
Response
(
json
.
dumps
(
provider
),
mimetype
=
'application/json'
)
@
meta
.
route
(
"/metadata/provider"
,
methods
=
[
'POST'
])
@
login_required
def
metadata_change_active_provider
():
active
=
current_user
.
view_settings
.
get
(
'metadata'
,
{})
provider
=
list
()
for
c
in
cl
:
provider
.
append
({
"name"
:
c
.
__name__
,
"active"
:
active
.
get
(
c
.
__name__
,
True
),
"id"
:
c
.
__id__
})
return
Response
(
json
.
dumps
(
provider
),
mimetype
=
'application/json'
)
@
meta
.
route
(
"/metadata/search"
,
methods
=
[
'POST'
])
@
meta
.
route
(
"/metadata/search"
,
methods
=
[
'POST'
])
@
login_required
@
login_required
def
metadata_search
():
def
metadata_search
():
query
=
request
.
form
.
to_dict
()
.
get
(
'query'
)
query
=
request
.
form
.
to_dict
()
.
get
(
'query'
)
data
=
list
()
data
=
list
()
active
=
current_user
.
view_settings
.
get
(
'metadata'
,
{})
if
query
:
if
query
:
for
c
in
cl
:
for
c
in
cl
:
data
.
extend
(
c
.
search
(
query
))
if
active
.
get
(
c
.
__name__
,
True
):
data
.
extend
(
c
.
search
(
query
))
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
return
Response
(
json
.
dumps
(
data
),
mimetype
=
'application/json'
)
cps/static/js/get_meta.js
View file @
ec7803fa
...
@@ -73,6 +73,28 @@ $(function () {
...
@@ -73,6 +73,28 @@ $(function () {
}
}
}
}
function
populate_provider
()
{
$
(
"#metadata_provider"
).
empty
();
$
.
ajax
({
url
:
getPath
()
+
"/metadata/provider"
,
type
:
"get"
,
dataType
:
"json"
,
success
:
function
success
(
data
)
{
console
.
log
(
data
);
data
.
forEach
(
function
(
provider
)
{
//$("#metadata_provider").html("<ul id=\"book-list\" class=\"media-list\"></ul>");
var
checked
=
""
;
if
(
provider
.
active
)
{
checked
=
"checked"
;
}
var
$provider_button
=
'<input type="checkbox" id="show-'
+
provider
.
name
+
'" class="pill" data-control="'
+
provider
.
id
+
'" '
+
checked
+
'><label for="show-'
+
provider
.
name
+
'">'
+
provider
.
name
+
' <span class="glyphicon glyphicon-ok"></span></label>'
$
(
"#metadata_provider"
).
append
(
$provider_button
);
});
},
});
}
$
(
"#meta-search"
).
on
(
"submit"
,
function
(
e
)
{
$
(
"#meta-search"
).
on
(
"submit"
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
keyword
=
$
(
"#keyword"
).
val
();
var
keyword
=
$
(
"#keyword"
).
val
();
...
@@ -80,10 +102,9 @@ $(function () {
...
@@ -80,10 +102,9 @@ $(function () {
});
});
$
(
"#get_meta"
).
click
(
function
()
{
$
(
"#get_meta"
).
click
(
function
()
{
populate_provider
();
var
bookTitle
=
$
(
"#book_title"
).
val
();
var
bookTitle
=
$
(
"#book_title"
).
val
();
if
(
bookTitle
)
{
$
(
"#keyword"
).
val
(
bookTitle
);
$
(
"#keyword"
).
val
(
bookTitle
);
doSearch
(
bookTitle
);
doSearch
(
bookTitle
);
}
});
});
});
});
cps/templates/book_edit.html
View file @
ec7803fa
...
@@ -241,21 +241,12 @@
...
@@ -241,21 +241,12 @@
<div
class=
"text-center"
><strong>
{{_('Click the cover to load metadata to the form')}}
</strong></div>
<div
class=
"text-center"
><strong>
{{_('Click the cover to load metadata to the form')}}
</strong></div>
</div>
</div>
<div
class=
"modal-body"
>
<div
class=
"modal-body"
>
<div
class=
"text-center padded-bottom"
>
<div
class=
"text-center padded-bottom"
id=
"metadata_provider"
>
<input
type=
"checkbox"
id=
"show-google"
class=
"pill"
data-control=
"google"
checked
>
<label
for=
"show-google"
>
Google
<span
class=
"glyphicon glyphicon-ok"
></span></label>
<input
type=
"checkbox"
id=
"show-comics"
class=
"pill"
data-control=
"comicvine"
checked
>
<label
for=
"show-comics"
>
ComicVine
<span
class=
"glyphicon glyphicon-ok"
></span></label>
<input
type=
"checkbox"
id=
"show-googlescholar"
class=
"pill"
data-control=
"googlescholar"
checked
>
<label
for=
"show-googlescholar"
>
Google Scholar
<span
class=
"glyphicon glyphicon-ok"
></span></label>
</div>
</div>
<div
id=
"meta-info"
>
<div
id=
"meta-info"
>
{{_("Loading...")}}
{{_("Loading...")}}
</div>
</div>
<!--ul id="book-list" class="media-list"></ul-->
</div>
</div>
<div
class=
"modal-footer"
>
<div
class=
"modal-footer"
>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
{{_('Close')}}
</button>
<button
type=
"button"
class=
"btn btn-default"
data-dismiss=
"modal"
>
{{_('Close')}}
</button>
...
...
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