From aeb57e9a249cb3fffe89dc0193d85f0cce2e576b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jul 2011 09:30:11 -0600 Subject: [PATCH 1/4] Fix #804367 (Advent Vega not recognised) --- src/calibre/devices/android/driver.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py index 08ecbd1ee3..685d1286eb 100644 --- a/src/calibre/devices/android/driver.py +++ b/src/calibre/devices/android/driver.py @@ -101,6 +101,9 @@ class ANDROID(USBMS): # ZTE 0x19d2 : { 0x1353 : [0x226] }, + # Advent + 0x0955 : { 0x7100 : [0x9999] }, # This is the same as the Notion Ink Adam + } EBOOK_DIR_MAIN = ['eBooks/import', 'wordplayer/calibretransfer', 'Books'] EXTRA_CUSTOMIZATION_MESSAGE = _('Comma separated list of directories to ' From b2da9d4d933f0b497fc0007162ae1c2644684a48 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jul 2011 09:45:44 -0600 Subject: [PATCH 2/4] ... --- recipes/buenosaireseconomico.recipe | 7 +++---- src/calibre/gui2/book_details.py | 2 -- .../gui2/store/stores/archive_org_plugin.py | 3 +++ src/calibre/gui2/store/stores/bn_plugin.py | 17 ++++++++--------- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/recipes/buenosaireseconomico.recipe b/recipes/buenosaireseconomico.recipe index 2de02c7c10..ccfdd5aca0 100644 --- a/recipes/buenosaireseconomico.recipe +++ b/recipes/buenosaireseconomico.recipe @@ -5,7 +5,6 @@ www.diariobae.com ''' from calibre import strftime from calibre.web.feeds.news import BasicNewsRecipe -from calibre.ebooks.BeautifulSoup import Tag class BsAsEconomico(BasicNewsRecipe): title = 'Buenos Aires Economico' @@ -22,8 +21,8 @@ class BsAsEconomico(BasicNewsRecipe): cover_url = strftime('http://www.diariobae.com/imgs_portadas/%Y%m%d_portadasBAE.jpg') masthead_url = 'http://www.diariobae.com/img/logo_bae.png' remove_empty_feeds = True - publication_type = 'newspaper' - extra_css = """ + publication_type = 'newspaper' + extra_css = """ body{font-family: Georgia,"Times New Roman",Times,serif} #titulo{font-size: x-large} #epi{font-size: small; font-style: italic; font-weight: bold} @@ -43,7 +42,7 @@ class BsAsEconomico(BasicNewsRecipe): ,dict(attrs={'id':'barra_tw'}) ] remove_attributes = ['data-count','data-via'] - + feeds = [ (u'Argentina' , u'http://www.diariobae.com/rss/argentina.xml' ) ,(u'Valores' , u'http://www.diariobae.com/rss/valores.xml' ) diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py index c1592a59fc..51f0a8d701 100644 --- a/src/calibre/gui2/book_details.py +++ b/src/calibre/gui2/book_details.py @@ -5,8 +5,6 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import urllib2 - from PyQt4.Qt import (QPixmap, QSize, QWidget, Qt, pyqtSignal, QUrl, QPropertyAnimation, QEasingCurve, QApplication, QFontInfo, QSizePolicy, QPainter, QRect, pyqtProperty, QLayout, QPalette, QMenu) diff --git a/src/calibre/gui2/store/stores/archive_org_plugin.py b/src/calibre/gui2/store/stores/archive_org_plugin.py index b2ea4e04f1..6972c604ce 100644 --- a/src/calibre/gui2/store/stores/archive_org_plugin.py +++ b/src/calibre/gui2/store/stores/archive_org_plugin.py @@ -30,6 +30,9 @@ class ArchiveOrgStore(BasicStoreConfig, OpenSearchStore): The opensearch feed only returns a subset of formats that are available. We want to get a list of all formats that the user can get. ''' + from calibre import browser + from contextlib import closing + from lxml import html br = browser() with closing(br.open(search_result.detail_item, timeout=timeout)) as nf: idata = html.fromstring(nf.read()) diff --git a/src/calibre/gui2/store/stores/bn_plugin.py b/src/calibre/gui2/store/stores/bn_plugin.py index abe789ad76..aa30ffe677 100644 --- a/src/calibre/gui2/store/stores/bn_plugin.py +++ b/src/calibre/gui2/store/stores/bn_plugin.py @@ -7,7 +7,6 @@ __copyright__ = '2011, John Schember ' __docformat__ = 'restructuredtext en' import random -import re from contextlib import closing from lxml import html @@ -22,13 +21,13 @@ from calibre.gui2.store.search_result import SearchResult from calibre.gui2.store.web_store_dialog import WebStoreDialog class BNStore(BasicStoreConfig, StorePlugin): - + def open(self, parent=None, detail_item=None, external=False): pub_id = 'sHa5EXvYOwA' # Use Kovid's affiliate id 30% of the time. if random.randint(1, 10) in (1, 2, 3): pub_id = '0dsO3kDu/AU' - + base_url = 'http://click.linksynergy.com/fs-bin/click?id=%s&subid=&offerid=229293.1&type=10&tmpid=8433&RD_PARM1=' % pub_id url = base_url + 'http%253A%252F%252Fwww.barnesandnoble.com%252F' @@ -46,27 +45,27 @@ class BNStore(BasicStoreConfig, StorePlugin): def search(self, query, max_results=10, timeout=60): query = query.replace(' ', '-') url = 'http://www.barnesandnoble.com/s/%s?store=ebook&sze=%s' % (query, max_results) - + br = browser() - + counter = max_results with closing(br.open(url, timeout=timeout)) as f: doc = html.fromstring(f.read()) for data in doc.xpath('//ul[contains(@class, "result-set")]/li[contains(@class, "result")]'): if counter <= 0: break - + id = ''.join(data.xpath('.//div[contains(@class, "image")]/a/@href')) if not id: continue cover_url = ''.join(data.xpath('.//div[contains(@class, "image")]//img/@src')) - + title = ''.join(data.xpath('.//p[@class="title"]//span[@class="name"]/text()')) author = ', '.join(data.xpath('.//ul[@class="contributors"]//li[position()>1]//a/text()')) price = ''.join(data.xpath('.//table[@class="displayed-formats"]//a[@class="subtle"]/text()')) - + counter -= 1 - + s = SearchResult() s.cover_url = cover_url s.title = title.strip() From d76f1ee48abd616c0ea0c61a9229293b1224ddde Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jul 2011 09:48:55 -0600 Subject: [PATCH 3/4] Updated Zaman Gazetesi --- recipes/zaman.recipe | 67 +++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 16 deletions(-) diff --git a/recipes/zaman.recipe b/recipes/zaman.recipe index 064b2c265a..4a2e9e8069 100644 --- a/recipes/zaman.recipe +++ b/recipes/zaman.recipe @@ -1,20 +1,55 @@ +# -*- coding: utf-8 -*- + from calibre.web.feeds.news import BasicNewsRecipe -class ZamanRecipe(BasicNewsRecipe): - title = u'Zaman' - __author__ = u'Deniz Og\xfcz' - language = 'tr' - oldest_article = 1 - max_articles_per_feed = 10 +class Zaman (BasicNewsRecipe): - cover_url = 'http://medya.zaman.com.tr/zamantryeni/pics/zamanonline.gif' - feeds = [(u'Gundem', u'http://www.zaman.com.tr/gundem.rss'), - (u'Son Dakika', u'http://www.zaman.com.tr/sondakika.rss'), - (u'Spor', u'http://www.zaman.com.tr/spor.rss'), - (u'Ekonomi', u'http://www.zaman.com.tr/ekonomi.rss'), - (u'Politika', u'http://www.zaman.com.tr/politika.rss'), - (u'D\u0131\u015f Haberler', u'http://www.zaman.com.tr/dishaberler.rss'), - (u'Yazarlar', u'http://www.zaman.com.tr/yazarlar.rss'),] + title = u'ZAMAN Gazetesi' + __author__ = u'thomass' + oldest_article = 2 + max_articles_per_feed =100 + # no_stylesheets = True + #delay = 1 + #use_embedded_content = False + encoding = 'ISO 8859-9' + publisher = 'Zaman' + category = 'news, haberler,TR,gazete' + language = 'tr' + publication_type = 'newspaper ' + extra_css = ' body{ font-family: Verdana,Helvetica,Arial,sans-serif } .introduction{font-weight: bold} .story-feature{display: block; padding: 0; border: 1px solid; width: 40%; font-size: small} .story-feature h2{text-align: center; text-transform: uppercase} ' + conversion_options = { + 'tags' : category + ,'language' : language + ,'publisher' : publisher + ,'linearize_tables': False + } + cover_img_url = 'https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/188140_81722291869_2111820_n.jpg' + masthead_url = 'http://medya.zaman.com.tr/extentions/zaman.com.tr/img/section/logo-section.png' - def print_version(self, url): - return url.replace('www.zaman.com.tr/haber.do?', 'www.zaman.com.tr/yazdir.do?') + + keep_only_tags = [dict(name='div', attrs={'id':[ 'news-detail-content']}), dict(name='td', attrs={'class':['columnist-detail','columnist_head']}) ] + remove_tags = [ dict(name='div', attrs={'id':['news-detail-news-text-font-size','news-detail-gallery','news-detail-news-bottom-social']}),dict(name='div', attrs={'class':['radioEmbedBg','radyoProgramAdi']}),dict(name='a', attrs={'class':['webkit-html-attribute-value webkit-html-external-link']}),dict(name='table', attrs={'id':['yaziYorumTablosu']}),dict(name='img', attrs={'src':['http://medya.zaman.com.tr/pics/paylas.gif','http://medya.zaman.com.tr/extentions/zaman.com.tr/img/columnist/ma-16.png']})] + + + #remove_attributes = ['width','height'] + remove_empty_feeds= True + + feeds = [ + ( u'Anasayfa', u'http://www.zaman.com.tr/anasayfa.rss'), + ( u'Son Dakika', u'http://www.zaman.com.tr/sondakika.rss'), + ( u'En çok Okunanlar', u'http://www.zaman.com.tr/max_all.rss'), + ( u'Gündem', u'http://www.zaman.com.tr/gundem.rss'), + ( u'Yazarlar', u'http://www.zaman.com.tr/yazarlar.rss'), + ( u'Politika', u'http://www.zaman.com.tr/politika.rss'), + ( u'Ekonomi', u'http://www.zaman.com.tr/ekonomi.rss'), + ( u'Dış Haberler', u'http://www.zaman.com.tr/dishaberler.rss'), + ( u'Yorumlar', u'http://www.zaman.com.tr/yorumlar.rss'), + ( u'Röportaj', u'http://www.zaman.com.tr/roportaj.rss'), + ( u'Spor', u'http://www.zaman.com.tr/spor.rss'), + ( u'Kürsü', u'http://www.zaman.com.tr/kursu.rss'), + ( u'Kültür Sanat', u'http://www.zaman.com.tr/kultursanat.rss'), + ( u'Televizyon', u'http://www.zaman.com.tr/televizyon.rss'), + ( u'Manşet', u'http://www.zaman.com.tr/manset.rss'), + + + ] From f0bf205fea4ea98703bade7d32428a0b1b5c7f6c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 1 Jul 2011 09:54:42 -0600 Subject: [PATCH 4/4] Fix #804383 (TypeError when deleting all saved searches) --- src/calibre/gui2/tag_browser/view.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py index d53167591e..295ef6f452 100644 --- a/src/calibre/gui2/tag_browser/view.py +++ b/src/calibre/gui2/tag_browser/view.py @@ -575,7 +575,9 @@ class TagsView(QTreeView): # {{{ expanded_categories, state_map = self.get_state() self._model.rebuild_node_tree(state_map=state_map) for category in expanded_categories: - self.expand(self._model.index_for_category(category)) + idx = self._model.index_for_category(category) + if idx is not None and idx.isValid(): + self.expand(idx) self.show_item_at_path(path) def show_item_at_path(self, path, box=False,