mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
The Wire by unkn0wn
This commit is contained in:
parent
cbf569bb06
commit
48ad093c4a
61
recipes/the_wire.recipe
Normal file
61
recipes/the_wire.recipe
Normal file
@ -0,0 +1,61 @@
|
||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
|
||||
class TheWire(BasicNewsRecipe):
|
||||
title = 'The Wire'
|
||||
__author__ = 'unkn0wn'
|
||||
description = 'The Wire is an Indian nonprofit news and opinion website'
|
||||
language = 'en_IN'
|
||||
masthead_url = 'https://cdn.thewire.in/wp-content/uploads/thewire-app-images/wire-logo.svg'
|
||||
|
||||
no_stylesheets = True
|
||||
remove_javascript = True
|
||||
|
||||
keep_only_tags = [
|
||||
classes(
|
||||
'title shortDesc author__name featured-image postComplete__description'
|
||||
' post-content-container thb-article-featured-image post-title '
|
||||
'sharing-counts-off post-bottom-meta'
|
||||
)
|
||||
]
|
||||
|
||||
ignore_duplicate_articles = {'title'}
|
||||
resolve_internal_links = True
|
||||
remove_empty_feeds = True
|
||||
|
||||
articles_are_obfuscated = True
|
||||
|
||||
def get_obfuscated_article(self, url):
|
||||
br = self.get_browser()
|
||||
try:
|
||||
br.open(url)
|
||||
except Exception as e:
|
||||
url = e.hdrs.get('location')
|
||||
soup = self.index_to_soup(url)
|
||||
link = soup.find('a', href=True)
|
||||
skip_sections =[ # add sections you want to skip
|
||||
'/video/', '/videos/', '/media/', 'podcast-'
|
||||
]
|
||||
if any(x in link['href'] for x in skip_sections):
|
||||
self.log('Aborting Article ', link['href'])
|
||||
self.abort_article('skipping video links')
|
||||
|
||||
self.log('Downloading ', link['href'])
|
||||
html = br.open(link['href']).read()
|
||||
pt = PersistentTemporaryFile('.html')
|
||||
pt.write(html)
|
||||
pt.close()
|
||||
return pt.name
|
||||
|
||||
feeds = []
|
||||
|
||||
sections = [
|
||||
'government', 'politics', 'law', 'business', 'economy', 'education', 'the-sciences',
|
||||
'security', 'tech', 'culture', 'environment', 'health', 'travel', 'rights',
|
||||
'labour', 'world', 'diplomacy', 'books', 'south-asia', 'caste', 'communalism',
|
||||
]
|
||||
|
||||
for sec in sections:
|
||||
a = 'https://news.google.com/rss/search?q=when:27h+allinurl:thewire.in{}&hl=en-IN&gl=IN&ceid=IN:en'
|
||||
feeds.append((sec.capitalize(), a.format('%2F' + sec + '%2F')))
|
||||
feeds.append(('Others', a.format('')))
|
Loading…
x
Reference in New Issue
Block a user