mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Update Frontline
Fixes #1647313 [Replace Frontline recipe](https://bugs.launchpad.net/calibre/+bug/1647313)
This commit is contained in:
parent
6f99bc3cea
commit
9a60dd0da1
@ -1,79 +1,74 @@
|
|||||||
|
# -*- mode: python -*-
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2011 - 2016, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
frontlineonnet.com
|
www.frontline.in
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import re
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
class Frontlineonnet(BasicNewsRecipe):
|
class Frontlineonnet(BasicNewsRecipe):
|
||||||
title = 'Frontline'
|
title = 'Frontline'
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = "India's national magazine"
|
description = """
|
||||||
publisher = 'Frontline'
|
India's National Magazine
|
||||||
category = 'news, politics, India'
|
Frontline, the fortnightly English magazine from the stable of The Hindu, has been a distinguished presence in the media world for the past 27 years.
|
||||||
no_stylesheets = True
|
As per the Indian Readership Survey (IRS) Q4, its average issue readership is 152,000.
|
||||||
delay = 1
|
|
||||||
INDEX = 'http://frontlineonnet.com/'
|
Frontline's journalism is characterised by in-depth, insightful reporting and analysis of issues and events at the regional, national and international levels.
|
||||||
|
It excels in long-form journalism.
|
||||||
|
|
||||||
|
The topics Frontline covers range from politics, economics and social issues to the environment, nature, culture and cinema.
|
||||||
|
Its cover stories are comprehensive.
|
||||||
|
"""
|
||||||
|
publisher = 'Frontline'
|
||||||
|
category = 'news, politics, India'
|
||||||
|
no_stylesheets = True
|
||||||
|
oldest_article = 15
|
||||||
|
INDEX = 'http://www.frontline.in/'
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
language = 'en_IN'
|
language = 'en_IN'
|
||||||
publication_type = 'magazine'
|
publication_type = 'magazine'
|
||||||
masthead_url = 'http://frontlineonnet.com/images/newfline.jpg'
|
auto_cleanup = True
|
||||||
|
masthead_url = 'http://www.frontline.in/template/1-0-1/gfx/fl_logo.jpg'
|
||||||
extra_css = """
|
extra_css = """
|
||||||
body{font-family: Verdana,Arial,Helvetica,sans-serif}
|
body{font-family: Georgia,"Times New Roman",serif}
|
||||||
img{margin-top:0.5em; margin-bottom: 0.7em; display: block}
|
img{margin-top:0.5em; margin-bottom: 0.7em; display: block}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comment': description, 'tags': category, 'publisher': publisher, 'language': language, 'linearize_tables': True
|
'comment' : description,
|
||||||
|
'tags' : category ,
|
||||||
|
'publisher': publisher ,
|
||||||
|
'language' : language
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocess_regexps = [
|
feeds = [
|
||||||
(re.compile(r'.*?<base', re.DOTALL | re.IGNORECASE), lambda match: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html dir="ltr" xml:lang="en-IN"><head><title>title</title><base') # noqa
|
(u'Cover story' , u'http://www.frontline.in/cover-story/?service=rss'),
|
||||||
, (re.compile(r'<base .*?>', re.DOTALL | re.IGNORECASE), lambda match: '</head><body>'), (re.compile(r'<byline>', re.DOTALL | re.IGNORECASE), lambda match: '<div class="byline">'), (re.compile(r'</byline>', re.DOTALL | re.IGNORECASE), lambda match: '</div>'), (re.compile(r'<center>', re.DOTALL | re.IGNORECASE), lambda match: '<div class="ctr">'), (re.compile(r'</center>', re.DOTALL | re.IGNORECASE), lambda match: '</div>') # noqa
|
(u'The Nation' , u'http://www.frontline.in/the-nation/?service=rss'),
|
||||||
]
|
(u'Politics' , u'http://www.frontline.in/politics/?service=rss'),
|
||||||
|
(u'Columns' , u'http://www.frontline.in/columns/?service=rss'),
|
||||||
keep_only_tags = [
|
(u'Social Issues' , u'http://www.frontline.in/social-issues/?service=rss'),
|
||||||
dict(name='div', attrs={'id': 'content'})
|
(u'General issues' , u'http://www.frontline.in/social-issues/general-issues/?service=rss'),
|
||||||
|
(u'Social justice' , u'http://www.frontline.in/social-issues/social-justice/?service=rss'),
|
||||||
|
(u'Arts&Culture' , u'http://www.frontline.in/arts-and-culture/?service=rss'),
|
||||||
|
(u'Economy' , u'http://www.frontline.in/economy/?service=rss'),
|
||||||
|
(u'World Affairs' , u'http://www.frontline.in/world-affairs/?service=rss'),
|
||||||
|
(u'Science&Technology', u'http://www.frontline.in/science-and-technology/?service=rss'),
|
||||||
|
(u'Books' , u'http://www.frontline.in/books/?service=rss'),
|
||||||
|
(u'Sport' , u'http://www.frontline.in/other/sport/?service=rss')
|
||||||
]
|
]
|
||||||
remove_attributes = ['size', 'noshade', 'border']
|
|
||||||
|
|
||||||
use_javascript_to_login = True
|
def get_cover_url(self):
|
||||||
needs_subscription = True
|
|
||||||
|
|
||||||
def javascript_login(self, browser, username, password):
|
|
||||||
browser.visit('http://www.frontline.in/profile/login.do')
|
|
||||||
browser.wait_for_element('form#loginForm', timeout=180)
|
|
||||||
# Select the first form on the page
|
|
||||||
form = browser.select_form('#loginForm')
|
|
||||||
form['userName'] = username
|
|
||||||
form['password'] = password
|
|
||||||
browser.submit(timeout=120)
|
|
||||||
|
|
||||||
def parse_index(self):
|
|
||||||
articles = []
|
|
||||||
current_section = None
|
|
||||||
feeds = []
|
|
||||||
soup = self.index_to_soup(self.INDEX)
|
soup = self.index_to_soup(self.INDEX)
|
||||||
for h3 in soup.findAll('h3'):
|
divtag = soup.find('div', 'smallMagCont')
|
||||||
if h3.get('class', None) == 'artListSec':
|
if divtag:
|
||||||
if articles:
|
return divtag.img['src']
|
||||||
feeds.append((current_section, articles))
|
return None
|
||||||
articles = []
|
|
||||||
current_section = self.tag_to_string(h3).strip()
|
def print_version(self, url):
|
||||||
self.log(current_section)
|
return url.replace('?','?css=print&')
|
||||||
elif h3.get('id', None) in {'headseccol', 'headsec'}:
|
|
||||||
a = h3.find('a', href=True)
|
|
||||||
if a is not None:
|
|
||||||
title = self.tag_to_string(a)
|
|
||||||
url = a['href']
|
|
||||||
articles.append({
|
|
||||||
'title': title, 'date': '', 'url': url, 'description': ''
|
|
||||||
})
|
|
||||||
self.log('\t', title, url)
|
|
||||||
if articles:
|
|
||||||
feeds.append((current_section, articles))
|
|
||||||
return feeds
|
|
||||||
|
BIN
recipes/icons/frontlineonnet.png
Normal file
BIN
recipes/icons/frontlineonnet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 527 B |
Loading…
x
Reference in New Issue
Block a user