Debian Codegraph @

recipes/lex_fridman_podcast.recipe

raw
1 #!/usr/bin/env python
2 # vim:fileencoding=utf-8
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class lexfridman(BasicNewsRecipe):
7 title = 'Lex Fridman Podcast'
8 description = (
9 'Transcripts from Lex Fridman Podcast. Conversations about science, technology, history, '
10 'philosophy and the nature of intelligence, consciousness, love, and power. Lex is an AI '
11 'researcher at MIT and beyond. Download monthly.'
12 )
13 oldest_article = 30 # days
14 __author__ = 'unkn0wn'
15 language = 'en'
16 encoding = 'utf-8'
17 remove_attributes = ['style', 'height', 'width']
18 no_stylesheets = True
19 ignore_duplicate_articles = {'url'}
20 use_embedded_content = False
21 timefmt = ' [%b, %Y]'
22 cover_url = 'https://i.scdn.co/image/ab6765630000ba8a563ebb538d297875b10114b7'
23
24 recipe_specific_options = {
25 'days': {
26 'short': 'Oldest article to download from this news source. In days ',
27 'long': 'For example, 0.5, gives you articles from the past 12 hours',
28 'default': str(oldest_article),
29 }
30 }
31
32 def __init__(self, *args, **kwargs):
33 BasicNewsRecipe.__init__(self, *args, **kwargs)
34 d = self.recipe_specific_options.get('days')
35 if d and isinstance(d, str):
36 self.oldest_article = float(d)
37
38 extra_css = '''
39 .ts-name { font-weight:bold; }
40 .ts-timestamp { font-size:small; }
41 '''
42
43 keep_only_tags = [dict(name='article')]
44 remove_tags = [dict(name=['svg']), dict(name='div', attrs={'class': 'episode-player'})]
45
46 feeds = [('Transcripts', 'https://lexfridman.com/feed/podcast/')]
47
48 def print_version(self, url):
49 return url.split('?')[0][:-1] + '-transcript/'
50
51 def preprocess_html(self, soup):
52 for div in soup.findAll('div', attrs={'class': 'ts-segment'}):
53 div.name = 'p'
54 for name in soup.findAll('span', attrs={'class': 'ts-name'}):
55 name.name = 'div'
56 return soup