mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
escapemagazine plugin
This commit is contained in:
parent
80fff01cf1
commit
d43178b091
@ -1257,6 +1257,17 @@ class StoreEKnigiStore(StoreBase):
|
||||
formats = ['EPUB', 'PDF', 'HTML']
|
||||
affiliate = True
|
||||
|
||||
class StoreEscapeMagazineStore(StoreBase):
|
||||
name = 'EscapeMagazine'
|
||||
author = 'Tomasz Długosz'
|
||||
description = u'Książki elektroniczne w formie pliku komputerowego PDF. Zabezpieczone hasłem.'
|
||||
actual_plugin = 'calibre.gui2.store.stores.escapemagazine_plugin:EscapeMagazineStore'
|
||||
|
||||
drm_free_only = True
|
||||
headquarters = 'PL'
|
||||
formats = ['PDF']
|
||||
affiliate = True
|
||||
|
||||
class StoreFeedbooksStore(StoreBase):
|
||||
name = 'Feedbooks'
|
||||
description = u'Feedbooks is a cloud publishing and distribution service, connected to a large ecosystem of reading systems and social networks. Provides a variety of genres from independent and classic books.'
|
||||
@ -1485,6 +1496,7 @@ plugins += [
|
||||
StoreEBookShoppeUKStore,
|
||||
StoreEHarlequinStore,
|
||||
StoreEKnigiStore,
|
||||
StoreEscapeMagazineStore,
|
||||
StoreFeedbooksStore,
|
||||
StoreFoylesUKStore,
|
||||
StoreGandalfStore,
|
||||
|
71
src/calibre/gui2/store/stores/escapemagazine_plugin.py
Normal file
71
src/calibre/gui2/store/stores/escapemagazine_plugin.py
Normal file
@ -0,0 +1,71 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011, Tomasz Długosz <tomek3d@gmail.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
import urllib
|
||||
from contextlib import closing
|
||||
|
||||
from lxml import html
|
||||
|
||||
from PyQt4.Qt import QUrl
|
||||
|
||||
from calibre import browser, url_slash_cleaner
|
||||
from calibre.gui2 import open_url
|
||||
from calibre.gui2.store import StorePlugin
|
||||
from calibre.gui2.store.basic_config import BasicStoreConfig
|
||||
from calibre.gui2.store.search_result import SearchResult
|
||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||
|
||||
class EscapeMagazineStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
pid = '44010'
|
||||
|
||||
url = 'http://www.escapemagazine.pl/s/' + pid
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
open_url(QUrl(url_slash_cleaner(detail_item + '/s/' + pid if detail_item else url)))
|
||||
else:
|
||||
d = WebStoreDialog(self.gui, url, parent, detail_item)
|
||||
d.setWindowTitle(self.name)
|
||||
d.set_tags(self.config.get('tags', ''))
|
||||
d.exec_()
|
||||
|
||||
def search(self, query, max_results=20, timeout=60):
|
||||
url = 'http://www.escapemagazine.pl/wyszukiwarka?query=' + urllib.quote_plus(query)
|
||||
|
||||
br = browser()
|
||||
|
||||
counter = max_results
|
||||
with closing(br.open(url, timeout=timeout)) as f:
|
||||
doc = html.fromstring(f.read())
|
||||
for data in doc.xpath('//div[@class="item item_short"]'):
|
||||
if counter <= 0:
|
||||
break
|
||||
|
||||
id = ''.join(data.xpath('.//h2[@class="title"]/a[1]/@href'))
|
||||
if not id:
|
||||
continue
|
||||
|
||||
title = ''.join(data.xpath('.//h2[@class="title"]/a[1]/text()'))
|
||||
author = ''.join(data.xpath('.//div[@class="author"]/text()'))
|
||||
price = ''.join(data.xpath('.//span[@class="price_now"]/strong/text()')) + ' zł'
|
||||
cover_url = ''.join(data.xpath('.//img[@class="cover"]/@src'))
|
||||
|
||||
counter -= 1
|
||||
|
||||
s = SearchResult()
|
||||
s.cover_url = cover_url
|
||||
s.title = title.strip()
|
||||
s.author = author.strip()
|
||||
s.price = price
|
||||
s.detail_item = 'http://www.escapemagazine.pl' + id.strip()
|
||||
s.drm = SearchResult.DRM_UNLOCKED
|
||||
s.formats = 'PDF'
|
||||
|
||||
yield s
|
Loading…
x
Reference in New Issue
Block a user