mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update der Standard
Merge branch 'update_der_standard_and_fix_cover' of https://github.com/andy-5/calibre
This commit is contained in:
commit
fc687e9b14
@ -6,6 +6,7 @@ __copyright__ = '2009, Gerhard Aigner <gerhard.aigner at gmail.com>'
|
|||||||
|
|
||||||
''' http://www.derstandard.at - Austrian Newspaper '''
|
''' http://www.derstandard.at - Austrian Newspaper '''
|
||||||
import re
|
import re
|
||||||
|
import random
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from time import strftime
|
from time import strftime
|
||||||
|
|
||||||
@ -47,8 +48,11 @@ class DerStandardRecipe(BasicNewsRecipe):
|
|||||||
(u'Meinung', u'http://derStandard.at/?page=rss&ressort=Meinung'),
|
(u'Meinung', u'http://derStandard.at/?page=rss&ressort=Meinung'),
|
||||||
(u'Lifestyle', u'http://derStandard.at/?page=rss&ressort=Lifestyle'),
|
(u'Lifestyle', u'http://derStandard.at/?page=rss&ressort=Lifestyle'),
|
||||||
(u'Reisen', u'http://derStandard.at/?page=rss&ressort=Reisen'),
|
(u'Reisen', u'http://derStandard.at/?page=rss&ressort=Reisen'),
|
||||||
|
(u'Familie', u'http://derstandard.at/?page=rss&ressort=Familie'),
|
||||||
|
(u'Greenlife', u'http://derStandard.at/?page=rss&ressort=Greenlife'),
|
||||||
(u'Karriere', u'http://derStandard.at/?page=rss&ressort=Karriere'),
|
(u'Karriere', u'http://derStandard.at/?page=rss&ressort=Karriere'),
|
||||||
(u'Immobilien', u'http://derstandard.at/?page=rss&ressort=Immobilien'),
|
(u'Immobilien', u'http://derstandard.at/?page=rss&ressort=Immobilien'),
|
||||||
|
(u'Automobil', u'http://derstandard.at/?page=rss&ressort=Automobil'),
|
||||||
(u'dieStandard', u'http://dieStandard.at/?page=rss&ressort=diestandard'),
|
(u'dieStandard', u'http://dieStandard.at/?page=rss&ressort=diestandard'),
|
||||||
(u'daStandard', u'http://daStandard.at/?page=rss&ressort=dastandard')
|
(u'daStandard', u'http://daStandard.at/?page=rss&ressort=dastandard')
|
||||||
]
|
]
|
||||||
@ -90,40 +94,14 @@ class DerStandardRecipe(BasicNewsRecipe):
|
|||||||
t.name = 'div'
|
t.name = 'div'
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
cover_re = re.compile('<img.*class="thumbnailBig.*src="(.*)" alt="issue"')
|
||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
highResolution = True
|
base_url = 'https://epaper.derstandard.at/'
|
||||||
|
url = base_url + 'shelf.act?s=' + str(random.random() * 10000)
|
||||||
date = strftime("%Y/%Y%m%d")
|
|
||||||
# it is also possible for the past
|
|
||||||
#date = '2012/20120503'
|
|
||||||
|
|
||||||
urlP1 = 'http://epaper.derstandarddigital.at/'
|
|
||||||
urlP2 = 'data_ep/STAN/' + date
|
|
||||||
urlP3 = '/V.B1/'
|
|
||||||
urlP4 = 'paper.htm'
|
|
||||||
urlHTML = urlP1 + urlP2 + urlP3 + urlP4
|
|
||||||
|
|
||||||
br = self.clone_browser(self.browser)
|
br = self.clone_browser(self.browser)
|
||||||
htmlF = br.open_novisit(urlHTML)
|
html = br.open(url).read()
|
||||||
htmlC = htmlF.read()
|
cover_match = self.cover_re.search(html)
|
||||||
|
if cover_match is not None:
|
||||||
|
cover_url = base_url + cover_match.group(1)
|
||||||
# URL EXAMPLE: data_ep/STAN/2012/20120504/V.B1/pages/A3B6798F-2751-4D8D-A103-C5EF22F7ACBE.htm
|
return cover_url
|
||||||
# consists of part2 + part3 + 'pages/' + code
|
|
||||||
# 'pages/' has length 6, code has lenght 36
|
|
||||||
|
|
||||||
index = htmlC.find(urlP2) + len(urlP2 + urlP3) + 6
|
|
||||||
code = htmlC[index:index + 36]
|
|
||||||
|
|
||||||
|
|
||||||
# URL EXAMPLE HIGH RESOLUTION: http://epaper.derstandarddigital.at/data_ep/STAN/2012/20120504/pagejpg/A3B6798F-2751-4D8D-A103-C5EF22F7ACBE_b.png
|
|
||||||
# URL EXAMPLE LOW RESOLUTION: http://epaper.derstandarddigital.at/data_ep/STAN/2012/20120504/pagejpg/2AB52F71-11C1-4859-9114-CDCD79BEFDCB.png
|
|
||||||
|
|
||||||
urlPic = urlP1 + urlP2 + '/pagejpg/' + code
|
|
||||||
|
|
||||||
if highResolution:
|
|
||||||
urlPic = urlPic + '_b'
|
|
||||||
|
|
||||||
urlPic = urlPic + '.png'
|
|
||||||
|
|
||||||
return urlPic
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user