Merge remote-tracking branch 'scholary/master'
This commit is contained in:
		
						commit
						7b8b2f93a0
					
				| 
						 | 
					@ -26,7 +26,7 @@ class ComicVine(Metadata):
 | 
				
			||||||
    __name__ = "ComicVine"
 | 
					    __name__ = "ComicVine"
 | 
				
			||||||
    __id__ = "comicvine"
 | 
					    __id__ = "comicvine"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def search(self, query, __):
 | 
					    def search(self, query, generic_cover=""):
 | 
				
			||||||
        val = list()
 | 
					        val = list()
 | 
				
			||||||
        apikey = "57558043c53943d5d1e96a9ad425b0eb85532ee6"
 | 
					        apikey = "57558043c53943d5d1e96a9ad425b0eb85532ee6"
 | 
				
			||||||
        if self.active:
 | 
					        if self.active:
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,14 +26,14 @@ class Google(Metadata):
 | 
				
			||||||
    __name__ = "Google"
 | 
					    __name__ = "Google"
 | 
				
			||||||
    __id__ = "google"
 | 
					    __id__ = "google"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def search(self, query, __):
 | 
					    def search(self, query, generic_cover=""):
 | 
				
			||||||
        if self.active:
 | 
					        if self.active:
 | 
				
			||||||
            val = list()
 | 
					            val = list()
 | 
				
			||||||
            result = requests.get("https://www.googleapis.com/books/v1/volumes?q="+query.replace(" ","+"))
 | 
					            result = requests.get("https://www.googleapis.com/books/v1/volumes?q="+query.replace(" ","+"))
 | 
				
			||||||
            for r in result.json()['items']:
 | 
					            for r in result.json()['items']:
 | 
				
			||||||
                v = dict()
 | 
					                v = dict()
 | 
				
			||||||
                v['id'] = r['id']
 | 
					                v['id'] = r['id']
 | 
				
			||||||
                v['title'] = r['volumeInfo']['title']
 | 
					                v['title'] = r['volumeInfo'].get('title',"")
 | 
				
			||||||
                v['authors'] = r['volumeInfo'].get('authors', [])
 | 
					                v['authors'] = r['volumeInfo'].get('authors', [])
 | 
				
			||||||
                v['description'] = r['volumeInfo'].get('description', "")
 | 
					                v['description'] = r['volumeInfo'].get('description', "")
 | 
				
			||||||
                v['publisher'] = r['volumeInfo'].get('publisher', "")
 | 
					                v['publisher'] = r['volumeInfo'].get('publisher', "")
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,6 @@ from scholarly import scholarly
 | 
				
			||||||
 | 
					
 | 
				
			||||||
from cps.services.Metadata import Metadata
 | 
					from cps.services.Metadata import Metadata
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
class scholar(Metadata):
 | 
					class scholar(Metadata):
 | 
				
			||||||
    __name__ = "Google Scholar"
 | 
					    __name__ = "Google Scholar"
 | 
				
			||||||
    __id__ = "googlescholar"
 | 
					    __id__ = "googlescholar"
 | 
				
			||||||
| 
						 | 
					@ -32,7 +31,7 @@ class scholar(Metadata):
 | 
				
			||||||
            i = 0
 | 
					            i = 0
 | 
				
			||||||
            for publication in scholar_gen:
 | 
					            for publication in scholar_gen:
 | 
				
			||||||
                v = dict()
 | 
					                v = dict()
 | 
				
			||||||
                v['id'] = "1234" # publication['bib'].get('title')
 | 
					                v['id'] = publication['url_scholarbib'].split(':')[1]
 | 
				
			||||||
                v['title'] = publication['bib'].get('title')
 | 
					                v['title'] = publication['bib'].get('title')
 | 
				
			||||||
                v['authors'] = publication['bib'].get('author', [])
 | 
					                v['authors'] = publication['bib'].get('author', [])
 | 
				
			||||||
                v['description'] = publication['bib'].get('abstract', "")
 | 
					                v['description'] = publication['bib'].get('abstract', "")
 | 
				
			||||||
| 
						 | 
					@ -41,8 +40,8 @@ class scholar(Metadata):
 | 
				
			||||||
                    v['publishedDate'] = publication['bib'].get('pub_year')+"-01-01"
 | 
					                    v['publishedDate'] = publication['bib'].get('pub_year')+"-01-01"
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    v['publishedDate'] = ""
 | 
					                    v['publishedDate'] = ""
 | 
				
			||||||
                v['tags'] = ""
 | 
					                v['tags'] = []
 | 
				
			||||||
                v['ratings'] = 0
 | 
					                v['rating'] = 0
 | 
				
			||||||
                v['series'] = ""
 | 
					                v['series'] = ""
 | 
				
			||||||
                v['cover'] = generic_cover
 | 
					                v['cover'] = generic_cover
 | 
				
			||||||
                v['url'] = publication.get('pub_url') or publication.get('eprint_url') or "",
 | 
					                v['url'] = publication.get('pub_url') or publication.get('eprint_url') or "",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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