ddg
This commit is contained in:
parent
bceb5e6d4a
commit
ecf782af64
3 changed files with 45 additions and 2 deletions
|
@ -8,6 +8,7 @@ import lookupbyisbn
|
||||||
import openlibrary
|
import openlibrary
|
||||||
import worldcat
|
import worldcat
|
||||||
import google
|
import google
|
||||||
|
import duckduckgo
|
||||||
|
|
||||||
providers = [
|
providers = [
|
||||||
('openlibrary', 'olid'),
|
('openlibrary', 'olid'),
|
||||||
|
@ -18,7 +19,8 @@ providers = [
|
||||||
]
|
]
|
||||||
|
|
||||||
def find(title, author=None, publisher=None, date=None):
|
def find(title, author=None, publisher=None, date=None):
|
||||||
results = google.find(title=title, author=author, publisher=publisher, date=date)
|
#results = google.find(title=title, author=author, publisher=publisher, date=date)
|
||||||
|
results = duckduckgo.find(title=title, author=author, publisher=publisher, date=date)
|
||||||
'''
|
'''
|
||||||
results = openlibrary.find(title=title, author=author, publisher=publisher, date=date)
|
results = openlibrary.find(title=title, author=author, publisher=publisher, date=date)
|
||||||
for r in results:
|
for r in results:
|
||||||
|
|
39
oml/meta/duckduckgo.py
Normal file
39
oml/meta/duckduckgo.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
|
from __future__ import division
|
||||||
|
|
||||||
|
import ox.web.duckduckgo
|
||||||
|
import stdnum.isbn
|
||||||
|
|
||||||
|
from .utils import find_isbns
|
||||||
|
|
||||||
|
|
||||||
|
def find(title, author=None, publisher=None, date=None):
|
||||||
|
print 'duckduckgo.find', title, author, publisher, date
|
||||||
|
query = title
|
||||||
|
if author:
|
||||||
|
if isinstance(author, list):
|
||||||
|
author = ' '.join(author)
|
||||||
|
query += ' ' + author
|
||||||
|
query += ' isbn'
|
||||||
|
isbns = []
|
||||||
|
for r in ox.web.duckduckgo.find(query):
|
||||||
|
isbns += find_isbns(' '.join(r))
|
||||||
|
results = []
|
||||||
|
done = set()
|
||||||
|
for isbn in isbns:
|
||||||
|
if isbn not in done:
|
||||||
|
key = 'isbn%d'%len(isbn)
|
||||||
|
#r = lookup(key, isbn)
|
||||||
|
#r['mainid'] = key
|
||||||
|
r = {
|
||||||
|
key: isbn,
|
||||||
|
'mainid': key
|
||||||
|
}
|
||||||
|
results.append(r)
|
||||||
|
done.add(isbn)
|
||||||
|
if len(isbn) == 10:
|
||||||
|
done.add(stdnum.isbn.to_isbn13(isbn))
|
||||||
|
if len(isbn) == 13:
|
||||||
|
done.add(stdnum.isbn.to_isbn10(isbn))
|
||||||
|
return results
|
|
@ -19,7 +19,7 @@ def find(title, author=None, publisher=None, date=None):
|
||||||
isbns = []
|
isbns = []
|
||||||
for r in ox.web.google.find(query):
|
for r in ox.web.google.find(query):
|
||||||
isbns += find_isbns(' '.join(r))
|
isbns += find_isbns(' '.join(r))
|
||||||
|
print isbns, 'google'
|
||||||
results = []
|
results = []
|
||||||
done = set()
|
done = set()
|
||||||
for isbn in isbns:
|
for isbn in isbns:
|
||||||
|
@ -35,4 +35,6 @@ def find(title, author=None, publisher=None, date=None):
|
||||||
done.add(isbn)
|
done.add(isbn)
|
||||||
if len(isbn) == 10:
|
if len(isbn) == 10:
|
||||||
done.add(stdnum.isbn.to_isbn13(isbn))
|
done.add(stdnum.isbn.to_isbn13(isbn))
|
||||||
|
if len(isbn) == 13:
|
||||||
|
done.add(stdnum.isbn.to_isbn10(isbn))
|
||||||
return results
|
return results
|
||||||
|
|
Loading…
Reference in a new issue