mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Fixes #1877045 [No news content when fetching news from the Bangkok Post](https://bugs.launchpad.net/calibre/+bug/1877045)
57 lines
1.8 KiB
Plaintext
57 lines
1.8 KiB
Plaintext
from calibre.web.feeds.news import BasicNewsRecipe
|
|
|
|
|
|
def classes(classes):
|
|
q = frozenset(classes.split(' '))
|
|
return dict(attrs={
|
|
'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
|
|
|
|
|
class BangkokPostRecipe(BasicNewsRecipe):
|
|
__license__ = 'GPL v3'
|
|
__author__ = 'kwetal'
|
|
language = 'en_TH'
|
|
version = 1
|
|
|
|
title = u'Bangkok Post'
|
|
publisher = u'Post Publishing PCL'
|
|
category = u'News'
|
|
description = u'The world\'s window to Thailand'
|
|
|
|
oldest_article = 7
|
|
max_articles_per_feed = 100
|
|
|
|
no_stylesheets = True
|
|
remove_javascript = True
|
|
use_embedded_content = False
|
|
|
|
# Feeds from: http://www.bangkokpost.com/rss/
|
|
feeds = []
|
|
feeds.append(
|
|
(u'Breaking News', u'http://www.bangkokpost.com/rss/data/breakingnews.xml'))
|
|
feeds.append(
|
|
(u'Top Stories', u'http://www.bangkokpost.com/rss/data/topstories.xml'))
|
|
feeds.append((u'News', u'http://www.bangkokpost.com/rss/data/news.xml'))
|
|
feeds.append(
|
|
(u'Business', u'http://www.bangkokpost.com/rss/data/business.xml'))
|
|
feeds.append(
|
|
(u'Opinion', u'http://www.bangkokpost.com/rss/data/opinion.xml'))
|
|
feeds.append(
|
|
(u'Travel', u'http://www.bangkokpost.com/rss/data/travel.xml'))
|
|
feeds.append(
|
|
(u'Leisure', u'http://www.bangkokpost.com/rss/data/leisure.xml'))
|
|
feeds.append(
|
|
(u'Entertainment', u'http://www.bangkokpost.com/rss/data/entertainment.xml'))
|
|
feeds.append((u'Auto', u'http://www.bangkokpost.com/rss/data/auto.xml'))
|
|
feeds.append((u'Life', u'http://www.bangkokpost.com/rss/data/life.xml'))
|
|
feeds.append((u'Tech', u'http://www.bangkokpost.com/rss/data/tect.xml'))
|
|
|
|
keep_only_tags = [
|
|
classes('article-headline articl-content'),
|
|
]
|
|
|
|
def print_version(self, url):
|
|
if '.com/vdo/' in url:
|
|
url = None
|
|
return url
|