mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Get Books: Fix ebooks.com website change causing title and author to not be fetched
This commit is contained in:
parent
afb9d18597
commit
07203f86bd
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
import re
|
import re
|
||||||
import urllib2
|
import urllib
|
||||||
from contextlib import closing
|
from contextlib import closing
|
||||||
|
|
||||||
from lxml import html
|
from lxml import html
|
||||||
@ -47,7 +47,7 @@ class EbookscomStore(BasicStoreConfig, StorePlugin):
|
|||||||
d.exec_()
|
d.exec_()
|
||||||
|
|
||||||
def search(self, query, max_results=10, timeout=60):
|
def search(self, query, max_results=10, timeout=60):
|
||||||
url = 'http://www.ebooks.com/SearchApp/SearchResults.net?term=' + urllib2.quote(query)
|
url = 'http://www.ebooks.com/SearchApp/SearchResults.net?term=' + urllib.quote_plus(query)
|
||||||
|
|
||||||
br = browser()
|
br = browser()
|
||||||
|
|
||||||
@ -66,15 +66,12 @@ class EbookscomStore(BasicStoreConfig, StorePlugin):
|
|||||||
|
|
||||||
cover_url = ''.join(data.xpath('.//div[@class="img"]//img/@src'))
|
cover_url = ''.join(data.xpath('.//div[@class="img"]//img/@src'))
|
||||||
|
|
||||||
title = ''
|
title = ''.join(data.xpath(
|
||||||
author = ''
|
'descendant::span[@class="book-title"]/a/text()')).strip()
|
||||||
header_parts = data.xpath('.//div[@class="descr"]/h4//a//text()')
|
author = ''.join(data.xpath(
|
||||||
if header_parts:
|
'descendant::span[@class="author"]/a/text()')).strip()
|
||||||
title = header_parts[0]
|
if not title or not author:
|
||||||
header_parts = header_parts[1:]
|
continue
|
||||||
if header_parts:
|
|
||||||
author = ', '.join(header_parts)
|
|
||||||
|
|
||||||
|
|
||||||
counter -= 1
|
counter -= 1
|
||||||
|
|
||||||
|
@ -48,13 +48,9 @@ class SonyStore(BasicStoreConfig, StorePlugin):
|
|||||||
break
|
break
|
||||||
|
|
||||||
curr = ''.join(item.xpath('descendant::div[@class="pricing"]/descendant::*[@class="currency"]/@title')).strip()
|
curr = ''.join(item.xpath('descendant::div[@class="pricing"]/descendant::*[@class="currency"]/@title')).strip()
|
||||||
if not curr:
|
|
||||||
curr = 'USD'
|
|
||||||
amt = ''.join(item.xpath('descendant::div[@class="pricing"]/descendant::*[@class="amount"]/text()')).strip()
|
amt = ''.join(item.xpath('descendant::div[@class="pricing"]/descendant::*[@class="amount"]/text()')).strip()
|
||||||
if not amt:
|
|
||||||
amt = '0'
|
|
||||||
s = SearchResult()
|
s = SearchResult()
|
||||||
s.price = curr+' '+amt
|
s.price = (curr+' '+amt) if (curr and amt) else _('Not Available')
|
||||||
title = item.xpath('descendant::h3[@class="item"]')
|
title = item.xpath('descendant::h3[@class="item"]')
|
||||||
if not title: continue
|
if not title: continue
|
||||||
title = etree.tostring(title[0], method='text',
|
title = etree.tostring(title[0], method='text',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user