~ubuntu-branches/debian/sid/calibre/sid

« back to all changes in this revision

Viewing changes to src/calibre/gui2/store/stores/woblink_plugin.py

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2014-02-27 07:48:06 UTC
  • mto: This revision was merged to the branch mainline in revision 74.
  • Revision ID: package-import@ubuntu.com-20140227074806-64wdebb3ptosxhhx
Tags: upstream-1.25.0+dfsg
Import upstream version 1.25.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
2
 
3
3
from __future__ import (unicode_literals, division, absolute_import, print_function)
4
 
store_version = 5  # Needed for dynamic plugin loading
 
4
store_version = 7  # Needed for dynamic plugin loading
5
5
 
6
6
__license__ = 'GPL 3'
7
 
__copyright__ = '2011-2013, Tomasz Długosz <tomek3d@gmail.com>'
 
7
__copyright__ = '2011-2014, Tomasz Długosz <tomek3d@gmail.com>'
8
8
__docformat__ = 'restructuredtext en'
9
9
 
10
10
import re
44
44
            d.exec_()
45
45
 
46
46
    def search(self, query, max_results=10, timeout=60):
47
 
        url = 'http://woblink.com/katalog-e-book?query=' + urllib.quote_plus(query.encode('utf-8'))
 
47
        url = 'http://woblink.com/katalog-ebooki?query=' + urllib.quote_plus(query.encode('utf-8'))
48
48
        if max_results > 10:
49
49
            if max_results > 20:
50
50
                url += '&limit=30'
56
56
        counter = max_results
57
57
        with closing(br.open(url, timeout=timeout)) as f:
58
58
            doc = html.fromstring(f.read())
59
 
            for data in doc.xpath('//div[@class="nw_katalog_lista_ksiazka"]'):
 
59
            for data in doc.xpath('//div[@class="nw_katalog_lista_ksiazka "]'):
60
60
                if counter <= 0:
61
61
                    break
62
62
 
66
66
 
67
67
                cover_url = ''.join(data.xpath('.//div[@class="nw_katalog_lista_ksiazka_okladka nw_okladka"]/a[1]/img/@src'))
68
68
                title = ''.join(data.xpath('.//h2[@class="nw_katalog_lista_ksiazka_detale_tytul"]/a[1]/text()'))
69
 
                author = ', '.join(data.xpath('.//h3[@class="nw_katalog_lista_ksiazka_detale_autor"]/a/text()'))
 
69
                author = ', '.join(data.xpath('.//p[@class="nw_katalog_lista_ksiazka_detale_autor"]/a/text()'))
70
70
                price = ''.join(data.xpath('.//div[@class="nw_katalog_lista_ksiazka_opcjezakupu_cena"]/span/text()'))
71
71
                price = re.sub('\.', ',', price)
72
72
                formats = ', '.join(data.xpath('.//p[@class="nw_katalog_lista_ksiazka_detale_formaty"]/span/text()'))