Debian Codegraph @

recipes/film_web.recipe

raw
1 import re
2
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class FilmWebPl(BasicNewsRecipe):
7 title = 'FilmWeb'
8 __author__ = 'fenuks'
9 description = 'Filmweb.pl - Filmy takie jak Ty Filmweb to największy i najczęściej odwiedzany polski serwis filmowy.'
10 cover_url = 'https://1.fwcdn.pl/an/np/49468/2018/15037.2.jpg'
11 category = 'movies'
12 language = 'pl'
13 index = 'https://www.filmweb.pl'
14 oldest_article = 8
15 max_articles_per_feed = 100
16 no_stylesheets = True
17 remove_empty_feeds = True
18 ignore_duplicate_articles = {'title', 'url'}
19 remove_javascript = True
20 use_embedded_content = False
21 extra_css = (
22 '.hdrBig {font-size:22px;} ul {list-style-type:none;} '
23 'ul.inline > li {display: inline;} '
24 'ul.sep-line > li + li::before {content: " | "} '
25 'ul.inline {padding:0px;} .vertical-align {display: inline-block;}'
26 )
27 preprocess_regexps = [
28 (re.compile(r'<body.+?</head>', re.DOTALL), lambda match: ''), # fix malformed HTML with 2 body tags...
29 (re.compile('(?:<sup>)?\\(kliknij\\,\\ aby powiększyć\\)(?:</sup>)?', re.IGNORECASE), lambda m: ''), # noqa: RUF039
30 (re.compile(type('')(r'(<br ?/?>\s*?<br ?/?>\s*?)+'), re.IGNORECASE), lambda m: '<br />'),
31 ]
32 remove_tags = [
33 dict(attrs={'class': ['infoParent', 'likeBar', 'droptions-box pull-right', 'photoDesc', 'imageLicense', 'play big', 'shadow embed__icon--svg']})
34 ]
35 remove_attributes = [
36 'style',
37 ]
38 keep_only_tags = [dict(attrs={'class': ['newsHdr hdrWithAuthor ', 'reviewHdr', 'newsContent newsPage', 'newsContent', 'hdr hdr-mega']})]
39 feeds = [
40 ('Filmy', 'https://www.filmweb.pl/feed/news/category/film'),
41 ('Seriale', 'https://www.filmweb.pl/feed/news/category/serial'),
42 ('Box office', 'https://www.filmweb.pl/feed/news/category/boxoffice'),
43 ('Telewizja', 'https://www.filmweb.pl/feed/news/category/tv'),
44 ('Festiwale, nagrody i przeglądy', 'https://www.filmweb.pl/feed/news/category/festival'),
45 ('Multimedia', 'https://www.filmweb.pl/feed/news/category/multimedia'),
46 ('Dystrybucja dvd/blu-ray', 'https://www.filmweb.pl/feed/news/category/dvd'),
47 ('Gry wideo', 'https://www.filmweb.pl/feed/news/category/game'),
48 ('Różne', 'https://www.filmweb.pl/feed/news/category/other'),
49 ('Recenzje redakcji', 'https://www.filmweb.pl/feed/reviews/latest'),
50 ('Recenzje użytkowników', 'https://www.filmweb.pl/feed/user-reviews/latest'),
51 ]
52
53 def preprocess_html(self, soup):
54 for a in soup('a', href=True):
55 if 'https://' not in a['href']:
56 a['href'] = self.index + a['href']
57
58 return soup