From 804868e514b6e978dd805e56047c8bbad1e72650 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 25 Nov 2019 08:26:17 +0530 Subject: [PATCH] Denik N by Robert Mihaly Fixes #1853788 [[PATCH] Add recipe for the czech newspaper Denik N](https://bugs.launchpad.net/calibre/+bug/1853788) --- recipes/denikn.cz.recipe | 106 ++++++++++++++++++++++++++++++++++++ recipes/icons/denikn.cz.png | Bin 0 -> 1105 bytes 2 files changed, 106 insertions(+) create mode 100644 recipes/denikn.cz.recipe create mode 100644 recipes/icons/denikn.cz.png diff --git a/recipes/denikn.cz.recipe b/recipes/denikn.cz.recipe new file mode 100644 index 0000000000..38e6e855d6 --- /dev/null +++ b/recipes/denikn.cz.recipe @@ -0,0 +1,106 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai +from __future__ import unicode_literals, division, absolute_import, print_function +from calibre.web.feeds.news import BasicNewsRecipe +from calibre import strftime +import locale + + +def cz_title_time(): + """ + Helper function to return date with czech locale. + """ + + orig_locale = locale.getlocale(locale.LC_TIME) + try: + locale.setlocale(locale.LC_TIME, 'cs_CZ') + except Exception: + return '' + try: + timestr = strftime('%a, %d %b %Y') + finally: + locale.setlocale(locale.LC_TIME, orig_locale) + return timestr + + +class DenikNRecipe(BasicNewsRecipe): + """ + Recipe for the RSS feed of https://denikn.cz/ + """ + + title = u'Deník N' + __author__ = 'Robert Mihaly' + publisher = u'N Media' + description = u'Deník N - Nezávislý český deník' + + # For daily feed + oldest_article = 1 + max_articles_per_feed = 20 + + # The default 120 seems too long + timeout = 30 + + # Custom title used in conversion_options below + custom_title = u'Deník N - ' + cz_title_time() + + # Select the feeds to process + feeds = [ + # (u'Vše', 'https://denikn.cz/feed'), + (u'Česko', 'https://denikn.cz/cesko/feed/'), + (u'Svět', 'https://denikn.cz/svet/feed'), + (u'Ekonomika', 'https://denikn.cz/ekonomika/feed'), + # (u'Komentáře', 'https://denikn.cz/nazory/feed'), + (u'Kultura', 'https://denikn.cz/kultura/feed'), + (u'Věda a technologie', 'https://denikn.cz/veda/feed'), + (u'Sport', 'https://denikn.cz/sport/feed'), + ] + + language = 'cs' + cover_url = 'https://denikn.cz/wp-content/themes/dn-2-cz/logo.svg' + remove_javascript = True + + publication_type = 'newspaper' + tags = 'news' + + # This could be 'optional', but there isn't much content if not subscribed + needs_subscription = True + # None auto-detects, otherwise 'utf8' could be also used + encoding = None + + # Full articles are not embedded + use_embedded_content = False + + auto_cleanup = True + remove_empty_feeds = True + + ignore_duplicate_articles = {'title', 'url'} + + compress_news_images = True + scale_news_images_to_device = True + + resolve_internal_links = True + + # Use gzip transfers + handle_gzip = True + + # Add custom title with Czech dates and correctly display publisher + conversion_options = { + 'title' : custom_title, + # 'comments' : description, + # 'tags' : tags, + # 'language' : language, + 'publisher' : publisher, + # 'authors' : publisher, + # 'smarten_punctuation' : True + } + + # Handle login here + def get_browser(self): + br = BasicNewsRecipe.get_browser(self) + if self.username is not None and self.password is not None: + br.open('https://predplatne.denikn.cz/sign/in/') + br.select_form(id='frm-signInForm') + br['username'] = self.username + br['password'] = self.password + br.submit() + return br diff --git a/recipes/icons/denikn.cz.png b/recipes/icons/denikn.cz.png new file mode 100644 index 0000000000000000000000000000000000000000..7ed28e2c5ad6b3beaaeabadc2ba52d4e7b94551a GIT binary patch literal 1105 zcmaJ=TSyd97#_2S60PVVs2&_f2#a9RmYj#+;YU$rM7$H%uxrOIn&IsU8SUa zs)z~-dg!HsULr)wXiexI5kZ7Sk(aQfXC>&VhwY5I+C$sGnREWb_kI8MoNH;`Syr;C zgdm8rc%z)a`#Nu}D#rgx-`ZBZZA8%&YK846tvY}Zb=U^TxT$u41W@(f<8MHiAc`xD zWD2E}CP9NHt$G+bW7?Qa5aGIvt!iBWk!_&Eup-p#=o5-G^a!;tq_B!Dfli~b&jGD{ z%}K4VOXGE_u9ggE1T0_zq>>r4+j50WgqqhC@Y%a&C~_Wxx+2s1VkB!v+{G;N$!P%L`nHT>L2P&C%P1gdAJ+g{=tHiI6QYOgf#W z(*YVf9Sq0wJj41Kzu$)uKDXCGYQ|@|6?p|2xSC_w$bc5=p1114n*yCupaqShJD_f8ppd#ob zA?(gqv859t=ypPzlq9lJQ8mNz?5*9&?~c&gU!`g=3Kl z>Me5h!m-E&xeN}5@jClgr}I~Me7xh*++t&C@_~iN-NAGH{3|?<-^8Alret)ed|NJ; zdu<+mSX=$dIFJ>Exv5X1yTqT})P~ z^A@+Vd3^Vkv~i|fy?vE1xA)(msEHRZ?;K&RG3hd0B%%8QfqHnVC^VUR+8=xStbB9H y^!~LQ(faQf0;|uKZn%DN>hr<+v0s-CttcfvY~T;kH*`M$ literal 0 HcmV?d00001