mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
nexto plugin: migrate to buybox
This commit is contained in:
parent
08cafd1de0
commit
7b81784a08
@ -1,10 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||
|
||||
store_version = 4 # Needed for dynamic plugin loading
|
||||
store_version = 5 # Needed for dynamic plugin loading
|
||||
|
||||
__license__ = 'GPL 3'
|
||||
__copyright__ = '2011-2016, Tomasz Długosz <tomek3d@gmail.com>'
|
||||
__copyright__ = '2011-2020, Tomasz Długosz <tomek3d@gmail.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import re
|
||||
@ -26,24 +26,35 @@ from calibre.gui2.store.search_result import SearchResult
|
||||
from calibre.gui2.store.web_store_dialog import WebStoreDialog
|
||||
|
||||
|
||||
def as_base64(data):
|
||||
if not isinstance(data, bytes):
|
||||
data = data.encode('utf-8')
|
||||
ans = b64encode(data)
|
||||
if isinstance(ans, bytes):
|
||||
ans = ans.decode('ascii')
|
||||
return ans
|
||||
|
||||
|
||||
class NextoStore(BasicStoreConfig, StorePlugin):
|
||||
|
||||
def open(self, parent=None, detail_item=None, external=False):
|
||||
pid = '155711'
|
||||
aff_root = 'https://www.a4b-tracking.com/pl/stat-click-text-link/35/58/'
|
||||
|
||||
url = 'http://www.nexto.pl/'
|
||||
|
||||
aff_url = aff_root + as_base64(url)
|
||||
|
||||
url = 'http://www.nexto.pl/ebooki_c1015.xml'
|
||||
detail_url = None
|
||||
|
||||
if detail_item:
|
||||
book_id = re.search(r'p[0-9]*\.xml\Z', detail_item)
|
||||
book_id = book_id.group(0).replace('.xml','').replace('p','')
|
||||
if book_id:
|
||||
detail_url = 'http://www.nexto.pl/rf/pr?p=' + book_id + '&pid=' + pid
|
||||
detail_url = aff_root + as_base64('http://www.nexto.pl/rf/pr?p=' + book_id)
|
||||
|
||||
if external or self.config.get('open_external', False):
|
||||
open_url(QUrl(url_slash_cleaner(detail_url if detail_url else url)))
|
||||
open_url(QUrl(url_slash_cleaner(detail_url if detail_url else aff_url)))
|
||||
else:
|
||||
d = WebStoreDialog(self.gui, url, parent, detail_url)
|
||||
d = WebStoreDialog(self.gui, url, parent, detail_url if detail_url else aff_url)
|
||||
d.setWindowTitle(self.name)
|
||||
d.set_tags(self.config.get('tags', ''))
|
||||
d.exec_()
|
||||
|
Loading…
x
Reference in New Issue
Block a user