From 1c56b03f95505f13da3612634271d0c729cadc95 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 13 May 2009 09:42:48 -0700 Subject: [PATCH] New recipes for HRT and RTS by Darko Miletic --- src/calibre/gui2/images/news/hrt.png | Bin 0 -> 606 bytes src/calibre/gui2/images/news/rts.png | Bin 0 -> 458 bytes src/calibre/web/feeds/recipes/__init__.py | 2 +- src/calibre/web/feeds/recipes/recipe_hrt.py | 66 ++++++++++++++++++++ src/calibre/web/feeds/recipes/recipe_rts.py | 60 ++++++++++++++++++ 5 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 src/calibre/gui2/images/news/hrt.png create mode 100644 src/calibre/gui2/images/news/rts.png create mode 100644 src/calibre/web/feeds/recipes/recipe_hrt.py create mode 100644 src/calibre/web/feeds/recipes/recipe_rts.py diff --git a/src/calibre/gui2/images/news/hrt.png b/src/calibre/gui2/images/news/hrt.png new file mode 100644 index 0000000000000000000000000000000000000000..828819e226825ea2bbdf022b0104aa8f19131d1f GIT binary patch literal 606 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*U87#Q0mB1L(l)>N-JP5IrO9_# zR5obbi2T96Cg`_*kXoqM>@Ar&$*FUdHgbBt=I4mG5z(<>Q%Bp828l_3cYHs$amF1} zfwJ`v8o3YOnc4n%UiyPZRffNJ%dPL*)zs*IwOYi)5hk+3{q5?bXU~dj>&Ms5Vk=>&W=wZ1_8BJOo5%VVN*e<*I*K#v6d&0`ehpM+sb8Bc^scuR{moDkW@%QnNK$6-z*Z`*<(-V4|6)O=dfY$k0ul_}EiQe@W6j5(oMGV{O9 zd;VNpTE)}w=fg>dJ{`LIroPVXN7apMtv?M9KH^oLcqO)c|DOA040X9*87vr1RQ*U5dG+Mjn0LK>{@b?fO$hXV;(a!r`SyQHukhUqW9sWan{|9|TBUHprBiYR&wCx8 z)6at(RrofUEOKCQ$@#>$Y^vnPpp~0!{`Swfd0yxA5w~RC{r??a{S#_T@ZeY{^kCY2 zA-BU(waKz`vyb|*a4@d?$@W)SE@t}zrJ5}(&E`e`<43i`HKHWBC^fMpRW}7lFc=va zSn3*>>KYn{7+6{vTUdd(=2iv<`5bHNVH$GtQ!>*kF*Fz&SeY7InHoVf6ikfz57fZm M>FVdQ&MBb@02*iXy8r+H literal 0 HcmV?d00001 diff --git a/src/calibre/gui2/images/news/rts.png b/src/calibre/gui2/images/news/rts.png new file mode 100644 index 0000000000000000000000000000000000000000..278f45edd7af222703cb4d11cc6711967a97cc13 GIT binary patch literal 458 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Y)RhkE)4%caKYZ?lYt_f1s;*b zK-vS0-A-oPfdtD69Mgd`SU*F|v9*VRoX?&vjv*GOk51m0d)Pq0Ri1h4_9kx8FAQ0C z)vYD+F1HrQS2T;Td2e?!<6t_bEfM7~cW)Eh0&eFck&9Hye_p*i@q4BGch3L3i-q6U zzKJh5H*-11uC(l2tDISB(_Xl$hlVODX>Px!cIZwCbCaRZM3J3s-?zUPkw5fH@%z2w z`sMTHKM=Uq9C3Y}%-N}nJz36K2462N>zXqskW;p^E|-g6=*udXmTkF$6Sqjp>fboR zIy-~mQJwtkw`PKWE6?ZucKmT?X%xrmgFjLuXE8aL$1{BY%(Z;(t}4c`NKV!Ro6c?TrIoRT6^LtYWnhrcv8EoTAvZrIGp!OsgP{RXwUvPdM8mHV^EjXe22WQ% Jmvv4FO#mNWrN#gN literal 0 HcmV?d00001 diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 4d2adfb1c0..ae1ae24131 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -42,7 +42,7 @@ recipe_modules = ['recipe_' + r for r in ( 'moneynews', 'der_standard', 'diepresse', 'nzz_ger', 'hna', 'seattle_times', 'scott_hanselman', 'coding_horror', 'twitchfilms', 'stackoverflow', 'telepolis_artikel', 'zaobao', 'usnews', - 'straitstimes', 'index_hu', 'pcworld_hu', + 'straitstimes', 'index_hu', 'pcworld_hu', 'hrt', 'rts', )] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/recipe_hrt.py b/src/calibre/web/feeds/recipes/recipe_hrt.py new file mode 100644 index 0000000000..d07b214e02 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_hrt.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2009, Darko Miletic ' + +''' +www.hrt.hr +''' + +import re +from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag + +class HRT(BasicNewsRecipe): + title = 'HRT: Vesti' + __author__ = 'Darko Miletic' + description = 'News from Croatia' + publisher = 'HRT' + category = 'news, politics, Croatia, HRT' + no_stylesheets = True + encoding = 'utf-8' + use_embedded_content = False + language = _("Croatian") + lang = 'hr-HR' + extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} body{font-family: serif1, serif} .article_description{font-family: serif1, serif}' + + html2lrf_options = [ + '--comment', description + , '--category', category + , '--publisher', publisher + ] + + html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"' + + + preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] + + keep_only_tags = [dict(name='div', attrs={'class':'bigVijest'})] + + remove_tags = [dict(name=['object','link','embed'])] + + remove_tags_after = dict(name='div', attrs={'class':'nsAuthor'}) + + feeds = [ + (u'Vijesti' , u'http://www.hrt.hr/?id=316&type=100&rss=vijesti' ) + ,(u'Sport' , u'http://www.hrt.hr/?id=316&type=100&rss=sport' ) + ,(u'Zabava' , u'http://www.hrt.hr/?id=316&type=100&rss=zabava' ) + ,(u'Filmovi i serije' , u'http://www.hrt.hr/?id=316&type=100&rss=filmovi' ) + ,(u'Dokumentarni program', u'http://www.hrt.hr/?id=316&type=100&rss=dokumentarci') + ,(u'Glazba' , u'http://www.hrt.hr/?id=316&type=100&rss=glazba' ) + ,(u'Kultura' , u'http://www.hrt.hr/?id=316&type=100&rss=kultura' ) + ,(u'Mladi' , u'http://www.hrt.hr/?id=316&type=100&rss=mladi' ) + ,(u'Manjine' , u'http://www.hrt.hr/?id=316&type=100&rss=manjine' ) + ,(u'Radio' , u'http://www.hrt.hr/?id=316&type=100&rss=radio' ) + ] + + def preprocess_html(self, soup): + soup.html['xml:lang'] = self.lang + soup.html['lang'] = self.lang + mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)]) + mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")]) + soup.head.insert(0,mlang) + soup.head.insert(1,mcharset) + for item in soup.findAll(style=True): + del item['style'] + return self.adeify_images(soup) diff --git a/src/calibre/web/feeds/recipes/recipe_rts.py b/src/calibre/web/feeds/recipes/recipe_rts.py new file mode 100644 index 0000000000..57ee346d62 --- /dev/null +++ b/src/calibre/web/feeds/recipes/recipe_rts.py @@ -0,0 +1,60 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2009, Darko Miletic ' + +''' +www.rts.rs +''' + +import re +from calibre.web.feeds.news import BasicNewsRecipe +from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag + +class RTS(BasicNewsRecipe): + title = 'RTS: Vesti' + __author__ = 'Darko Miletic' + description = 'News from Serbia' + publisher = 'RTS' + category = 'news, politics, Serbia, RTS' + no_stylesheets = True + encoding = 'utf-8' + use_embedded_content = True + language = _("Serbian") + lang = 'sr-Latn-RS' + extra_css = '@font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} body{font-family: serif1, serif} .article_description{font-family: serif1, serif}' + + html2lrf_options = [ + '--comment', description + , '--category', category + , '--publisher', publisher + ] + + html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"' + + + preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')] + + feeds = [ + (u'Vesti' , u'http://www.rts.rs/page/stories/sr/rss.html' ) + ,(u'Srbija' , u'http://www.rts.rs/page/stories/sr/rss/9/Srbija.html' ) + ,(u'Region' , u'http://www.rts.rs/page/stories/sr/rss/11/Region.html' ) + ,(u'Svet' , u'http://www.rts.rs/page/stories/sr/rss/10/Svet.html' ) + ,(u'Hronika' , u'http://www.rts.rs/page/stories/sr/rss/135/Hronika.html' ) + ,(u'Drustvo' , u'http://www.rts.rs/page/stories/sr/rss/125/Dru%C5%A1tvo.html') + ,(u'Ekonomija' , u'http://www.rts.rs/page/stories/sr/rss/13/Ekonomija.html' ) + ,(u'Nauka' , u'http://www.rts.rs/page/stories/sr/rss/14/Nauka.html' ) + ,(u'Kultura' , u'http://www.rts.rs/page/stories/sr/rss/16/Kultura.html' ) + ,(u'Zanimljivosti' , u'http://www.rts.rs/page/stories/sr/rss/15/Zanimljivosti.html') + ,(u'Sport' , u'http://www.rts.rs/page/sport/sr/rss.html' ) + ] + + def preprocess_html(self, soup): + soup.html['xml:lang'] = self.lang + soup.html['lang'] = self.lang + mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)]) + mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=UTF-8")]) + soup.head.insert(0,mlang) + soup.head.insert(1,mcharset) + return self.adeify_images(soup) +