From aec0107b79a2c45ca1689ae721b0a8d28c04a1d3 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Dec 2008 09:25:48 -0800 Subject: [PATCH 1/3] Recipe for Science Daily (thanks to Darko Miletic) --- src/calibre/gui2/dialogs/jobs.py | 6 ++-- src/calibre/gui2/images/news/sciencedaily.png | Bin 0 -> 763 bytes src/calibre/web/feeds/recipes/__init__.py | 2 +- src/calibre/web/feeds/recipes/sciencedaily.py | 32 ++++++++++++++++++ 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 src/calibre/gui2/images/news/sciencedaily.png create mode 100644 src/calibre/web/feeds/recipes/sciencedaily.py diff --git a/src/calibre/gui2/dialogs/jobs.py b/src/calibre/gui2/dialogs/jobs.py index ced7f2ee10..8e22f4c43c 100644 --- a/src/calibre/gui2/dialogs/jobs.py +++ b/src/calibre/gui2/dialogs/jobs.py @@ -36,11 +36,11 @@ class JobsDialog(QDialog, Ui_JobsDialog): self.model = model self.setWindowModality(Qt.NonModal) self.setWindowTitle(__appname__ + _(' - Jobs')) - QObject.connect(self.jobs_view.model(), SIGNAL('modelReset()'), + QObject.connect(self.jobs_view.model(), SIGNAL('modelReset()'), self.jobs_view.resizeColumnsToContents) QObject.connect(self.kill_button, SIGNAL('clicked()'), self.kill_job) - QObject.connect(self, SIGNAL('kill_job(int, PyQt_PyObject)'), + QObject.connect(self, SIGNAL('kill_job(int, PyQt_PyObject)'), self.jobs_view.model().kill_job) self.pb_delegate = ProgressBarDelegate(self) self.jobs_view.setItemDelegateForColumn(2, self.pb_delegate) @@ -53,7 +53,7 @@ class JobsDialog(QDialog, Ui_JobsDialog): model = self.model for row, job in enumerate(model.jobs): if job.is_running: - self.jobs_view.dataChanged(model.index(row, 3), model.index(row, 3)) + self.jobs_view.dataChanged(model.index(row, 3), model.index(row, 3)) def kill_job(self): for index in self.jobs_view.selectedIndexes(): diff --git a/src/calibre/gui2/images/news/sciencedaily.png b/src/calibre/gui2/images/news/sciencedaily.png new file mode 100644 index 0000000000000000000000000000000000000000..ab2e1b0483b98b7b467c3e081e0d4be903b268d5 GIT binary patch literal 763 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%b@U_I1CZGssfk$L9 zkoEv$x0Bg+Ai=T%$8;bK*3S@gZ0%tN1|}6x7sn8b)4h}9JthZA9IKyYY&SvY*XE-h zfnxI|Rv%Q5`o~#z`GDaEJ+`=BHf5H{Uz}JD>$Q}MdNq{@I}0lEaG6|ieA#+}jrp_; z>oUo+kerhQxSzBkmd^2Z)%=^!KCoJ|@&c9@#;*6^)t!kH@XU_Vy zpgS$yp7V#QM2)tRQr!FEjW^}I6%3*_tdoAycKU0GnOR+The!5nX95f_m|(k$-nuQRkM#x zepT6%O=uI0q-KZVMwO+SB*zp&-Z!p3E( zFJ8>h;Obm8i{aD#IR_8!X5iu9ug!NUFk)>Q15@MeA2q!eGFz`)k5`k4OU%jnSiu}> z%5>pcnfG(2g{-%3AOE^b<-fIj>)EoU3;K@k6V3d`$e=IKdpz Date: Sun, 21 Dec 2008 09:51:25 -0800 Subject: [PATCH 2/3] Recipe for Forbes magazine (thanks to Darko Miletic) --- src/calibre/web/feeds/recipes/__init__.py | 2 +- src/calibre/web/feeds/recipes/forbes.py | 37 +++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/calibre/web/feeds/recipes/forbes.py diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 830a1b635d..0769a82c66 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -18,7 +18,7 @@ recipe_modules = [ 'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times', 'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas', 'science_news', 'the_nation', 'lrb', 'harpers_full', 'liberation', - 'linux_magazine', 'telegraph_uk', 'utne', 'sciencedaily' + 'linux_magazine', 'telegraph_uk', 'utne', 'sciencedaily', 'forbes', ] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/forbes.py b/src/calibre/web/feeds/recipes/forbes.py new file mode 100644 index 0000000000..9fa281fa09 --- /dev/null +++ b/src/calibre/web/feeds/recipes/forbes.py @@ -0,0 +1,37 @@ +from calibre.ebooks.BeautifulSoup import BeautifulSoup +from calibre.web.feeds.news import BasicNewsRecipe + +class Forbes(BasicNewsRecipe): + title = u'Forbes' + description = 'Business and Financial News' + __author__ = 'Darko Miletic' + oldest_article = 30 + max_articles_per_feed = 100 + no_stylesheets = True + html2lrf_options = ['--base-font-size', '10'] + + cover_url = u'http://www.forbes.com/media/current_covers/forbes_120_160.gif' + + feeds = [(u'Latest', u'http://www.forbes.com/news/index.xml'), + (u'Most Popular', u'http://www.forbes.com/feeds/popstories.xml'), + (u'Most Emailed', u'http://www.forbes.com/feeds/mostemailed.xml'), + (u'Faces', u'http://www.forbes.com/facesscan/index.xml'), + (u'Technology', u'http://www.forbes.com/technology/index.xml'), + (u'Personal Tech', u'http://www.forbes.com/personaltech/index.xml'), + (u'Wireless', u'http://www.forbes.com/wireless/index.xml'), + (u'Business', u'http://www.forbes.com/business/index.xml'), + (u'Sports Money', u'http://www.forbes.com/sportsmoney/index.xml'), + (u'Sports', u'http://www.forbes.com/forbeslife/sports/index.xml'), + (u'Vehicles', u'http://www.forbes.com/forbeslife/vehicles/index.xml'), + (u'Leadership', u'http://www.forbes.com/leadership/index.xml'), + (u'Careers', u'http://www.forbes.com/leadership/careers/index.xml'), + (u'Compensation', u'http://www.forbes.com/leadership/compensation/index.xml'), + (u'Managing', u'http://www.forbes.com/leadership/managing/index.xml')] + + def print_version(self, url): + raw = self.browser.open(url).read() + soup = BeautifulSoup(raw.decode('latin1', 'replace')) + print_link = soup.find('a', {'onclick':"s_linkTrackVars='prop18';s_linkType='o';s_linkName='Print';if(typeof(globalPageName)!='undefined')s_prop18=globalPageName;s_lnk=s_co(this);s_gs(s_account);"}) + if print_link is None: + return '' + return 'http://www.forbes.com' + print_link['href'] \ No newline at end of file From 81f2edc740f2f7faaba90aba4af10b1b4502d16b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 21 Dec 2008 09:59:40 -0800 Subject: [PATCH 3/3] Recipe for Time (thanks to Darko Miletic) --- src/calibre/gui2/images/news/time.png | Bin 0 -> 282 bytes src/calibre/web/feeds/recipes/__init__.py | 1 + src/calibre/web/feeds/recipes/time.py | 42 ++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 src/calibre/gui2/images/news/time.png create mode 100644 src/calibre/web/feeds/recipes/time.py diff --git a/src/calibre/gui2/images/news/time.png b/src/calibre/gui2/images/news/time.png new file mode 100644 index 0000000000000000000000000000000000000000..1939b183a62a7b75ecc284c42a55d5f9fca47ef1 GIT binary patch literal 282 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%b@U_I1CZGssfk$L9 zkoEv$x0Bg+Ai=T%$8;bK*3S@gZ0%tn$Jx`xF~s6@a!NwNkMjhUVTggHm8qGPiMg(Ug_VK9PtBPjFb%o+DVb@N W1T-w0@jd~lfx*+&&t;ucLK6T0j!qr` literal 0 HcmV?d00001 diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 0769a82c66..7006ff030d 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -19,6 +19,7 @@ recipe_modules = [ 'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas', 'science_news', 'the_nation', 'lrb', 'harpers_full', 'liberation', 'linux_magazine', 'telegraph_uk', 'utne', 'sciencedaily', 'forbes', + 'time', ] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/time.py b/src/calibre/web/feeds/recipes/time.py new file mode 100644 index 0000000000..17df0c32e9 --- /dev/null +++ b/src/calibre/web/feeds/recipes/time.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2008, Darko Miletic ' +''' +time.com +''' + +from calibre.ebooks.BeautifulSoup import BeautifulSoup +from calibre.web.feeds.news import BasicNewsRecipe + +class Time(BasicNewsRecipe): + title = u'Time' + __author__ = 'Darko Miletic' + description = 'Weekly magazine' + oldest_article = 7 + max_articles_per_feed = 100 + no_stylesheets = False + use_embedded_content = False + + cover_url = 'http://img.timeinc.net/time/rd/trunk/www/web/feds/i/logo_time_home.gif' + + keep_only_tags = [dict(name='div', attrs={'class':'tout1'})] + + feeds = [ + (u'Top Stories', u'http://feedproxy.google.com/time/topstories') + ,(u'Nation', u'http://feedproxy.google.com/time/nation') + ,(u'Business & Tech', u'http://feedproxy.google.com/time/business') + ,(u'Science & Tech', u'http://feedproxy.google.com/time/scienceandhealth') + ,(u'World', u'http://feedproxy.google.com/time/world') + ,(u'Entertainment', u'http://feedproxy.google.com/time/entertainment') + ,(u'Politics', u'http://feedproxy.google.com/time/politics') + ,(u'Travel', u'http://feedproxy.google.com/time/travel') + ] + + def print_version(self, url): + raw = self.browser.open(url).read() + soup = BeautifulSoup(raw.decode('utf8', 'replace')) + print_link = soup.find('a', {'id':'prt'}) + if print_link is None: + return '' + return 'http://www.time.com' + print_link['href']