Fixed google scholar issues
This commit is contained in:
parent
222929e741
commit
4edd1914b4
|
@ -19,21 +19,17 @@
|
||||||
from scholarly import scholarly
|
from scholarly import scholarly
|
||||||
|
|
||||||
from cps.services.Metadata import Metadata
|
from cps.services.Metadata import Metadata
|
||||||
import pprint
|
|
||||||
pp = pprint.PrettyPrinter(indent=4)
|
|
||||||
|
|
||||||
class scholar(Metadata):
|
class scholar(Metadata):
|
||||||
__name__ = "Google Scholar"
|
__name__ = "Google Scholar"
|
||||||
__id__ = "googlescholar"
|
__id__ = "googlescholar"
|
||||||
|
|
||||||
def search(self, query, generic_cover=None):
|
def search(self, query, generic_cover=""):
|
||||||
val = list()
|
val = list()
|
||||||
if self.active:
|
if self.active:
|
||||||
scholar_gen = scholarly.search_pubs(' '.join(query.split('+')))
|
scholar_gen = scholarly.search_pubs(' '.join(query.split('+')))
|
||||||
i = 0
|
i = 0
|
||||||
for publication in scholar_gen:
|
for publication in scholar_gen:
|
||||||
print(f"PUBLICATION {i + 1}")
|
|
||||||
pp.pprint(publication)
|
|
||||||
v = dict()
|
v = dict()
|
||||||
v['id'] = publication['url_scholarbib'].split(':')[1]
|
v['id'] = publication['url_scholarbib'].split(':')[1]
|
||||||
v['title'] = publication['bib'].get('title')
|
v['title'] = publication['bib'].get('title')
|
||||||
|
@ -58,7 +54,6 @@ class scholar(Metadata):
|
||||||
i += 1
|
i += 1
|
||||||
if (i >= 10):
|
if (i >= 10):
|
||||||
break
|
break
|
||||||
pp.pprint(val)
|
|
||||||
return val
|
return val
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,9 +103,9 @@ def metadata_search():
|
||||||
data = list()
|
data = list()
|
||||||
active = current_user.view_settings.get('metadata', {})
|
active = current_user.view_settings.get('metadata', {})
|
||||||
if query:
|
if query:
|
||||||
static_cover = url_for('static', filename='generic_cover.jpg')
|
generic_cover = ""
|
||||||
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
|
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:
|
||||||
meta = {executor.submit(c.search, query, static_cover): c for c in cl if active.get(c.__id__, True)}
|
meta = {executor.submit(c.search, query, generic_cover): c for c in cl if active.get(c.__id__, True)}
|
||||||
for future in concurrent.futures.as_completed(meta):
|
for future in concurrent.futures.as_completed(meta):
|
||||||
data.extend(future.result())
|
data.extend(future.result())
|
||||||
return Response(json.dumps(data), mimetype='application/json')
|
return Response(json.dumps(data), mimetype='application/json')
|
||||||
|
|
|
@ -40,7 +40,7 @@ $(function () {
|
||||||
$("#book_title").val(book.title);
|
$("#book_title").val(book.title);
|
||||||
$("#tags").val(uniqueTags.join(", "));
|
$("#tags").val(uniqueTags.join(", "));
|
||||||
$("#rating").data("rating").setValue(Math.round(book.rating));
|
$("#rating").data("rating").setValue(Math.round(book.rating));
|
||||||
if(book.cover !== null){
|
if(book.cover){
|
||||||
$(".cover img").attr("src", book.cover);
|
$(".cover img").attr("src", book.cover);
|
||||||
$("#cover_url").val(book.cover);
|
$("#cover_url").val(book.cover);
|
||||||
}
|
}
|
||||||
|
@ -128,9 +128,7 @@ $(function () {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
keyword = $("#keyword").val();
|
keyword = $("#keyword").val();
|
||||||
$('.pill').each(function(){
|
$('.pill').each(function(){
|
||||||
// console.log($(this).data('control'));
|
|
||||||
$(this).data("initial", $(this).prop('checked'));
|
$(this).data("initial", $(this).prop('checked'));
|
||||||
// console.log($(this).data('initial'));
|
|
||||||
});
|
});
|
||||||
doSearch(keyword);
|
doSearch(keyword);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user