calibre/recipes/appledaily_tw.recipe
Kovid Goyal 29cd8d64ea
Change shebangs to python from python2
Also remove a few other miscellaneous references to python2
2020-08-22 18:47:51 +05:30

111 lines
6.7 KiB
Python

#!/usr/bin/env python
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe
import re
__license__ = 'GPL v3'
__author__ = 'YuLun Shih'
class AppledailyTW(BasicNewsRecipe):
__license__ = 'GPL v3'
__author__ = 'YuLun Shih'
title = u'蘋果日報 (台灣)'
description = '24 小時陪你看新聞,我們是最勁爆、最八卦、最貼近大家生活的台灣蘋果日報!'
cover_url = 'http://i.imgur.com/3pkzQbw.jpg'
masthead_url = 'http://i.imgur.com/otLZwQq.gif'
oldest_article = 1.5
max_articles_per_feed = 25
auto_cleanup = True
simultaneous_downloads = 25
language = 'zh_TW'
tags = 'news, chinese, Taiwan'
category = 'news, chinese, Taiwan'
publisher = u'蘋果日報 (台灣)'
publication_type = 'newspaper'
no_stylesheets = True
remove_empty_feeds = True
extra_css = 'img { display:block; margin: 5px auto; width: 50%;}'
remove_tags = [
{'name': 'a', 'attrs': {'href': 'mailto:.*?'}},
{'name': 'a', 'attrs': {'target': '_blank'}},
{'name': 'hr'}
]
conversion_options = {
'title': title,
'comments': description,
'tags': category,
'language': language,
'publisher': publisher,
'authors': publisher,
'linearize_tables': True
}
feeds = [
(u'頭條', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1077'),
(u'要聞', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/11'),
(u'政治', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/151'),
(u'社會', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1066'),
(u'生活', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/2724'),
(u'地方綜合', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1076'),
(u'論壇', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/824711'),
(u'法庭', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/152'),
(u'暖流', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/9499'),
(u'投訴', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/16287'),
(u'娛樂名人', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1600'),
(u'木瓜霞吐槽', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/26153'),
(u'直擊好萊塢', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/2890'),
(u'亞洲哈燒星', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/6270'),
(u'名人時尚', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1403917'),
(u'強檔新片', 'http://www.appledaily.com.tw/rss/create/kind/col/type/35151804'),
(u'勇闖星宅門', 'http://www.appledaily.com.tw/rss/create/kind/col/type/1761666'),
(u'國際頭條', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31488833'),
(u'國際新聞', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1697'),
(u'中國新聞', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/13'),
(u'雙語天下', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1945241'),
(u'體育焦點', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/2153'),
(u'大運動場', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/16289'),
(u'籃球瘋', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/16'),
(u'投打對決', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/2154'),
(u'足球新聞', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31320925'),
(u'運彩分析', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31320926'),
(u'財經焦點', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/14'),
(u'財經熱門話題', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1059'),
(u'國際財經', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1052'),
(u'投資理財', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1028'),
(u'科技3C', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1048'),
(u'金融保險', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1078'),
(u'綜合產業', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/3847'),
(u'頭家生意', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/5050'),
(u'地產焦點', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1061'),
(u'地產王', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31425399'),
(u'中古好屋王', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31477902'),
(u'家居王', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31477866'),
(u'豪宅王', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31477901'),
(u'蘋論', 'http://www.appledaily.com.tw/rss/create/kind/col/type/974972'),
(u'司馬觀點', 'http://www.appledaily.com.tw/rss/create/kind/col/type/1635487'),
(u'人間異語', 'http://www.appledaily.com.tw/rss/create/kind/col/type/2262677'),
(u'論壇', 'http://www.appledaily.com.tw/rss/create/kind/col/type/836825'),
(u'副刊頭條', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31477907'),
(u'讓我更美', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/22'),
(u'流行尖端', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/2452'),
(u'消費高手', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1619'),
(u'旅遊與探險', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/24'),
(u'美食天地', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1898'),
(u'健康醫療', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/177600'),
(u'讓我自己來', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31478018'),
(u'寵物 DIY', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/31478020'),
(u'運勢與彩券', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/6199'),
(u'3C通訊', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/23'),
(u'車市快遞', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/1540'),
(u'名采', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/25'),
(u'人間事', 'http://www.appledaily.com.tw/rss/create/kind/sec/type/17822'),
]
def preprocess_raw_html(self, raw_html, url):
raw_html = re.sub((r'<a href=".*?<br><br>.*?<\/a>'), '', raw_html)
raw_html = re.sub(
(r'<title>(.*?)[\\s]+\|.*<\/title>', r'<title>\1<\/title>'), raw_html)
return raw_html