Hi all,
some time ago I wrote a recipe for the
Plane Crash Series on Medium. I recently picked it up again and improved it after gaining some knowledge of Python, and I believe I obtained a good result of extracting the main text and minimising Medium's clutter.
The only thing missing that I'd like to add is a custom cover. I implemented the get_cover_url method as shown here:
Code:
def get_cover_url(self):
soup = self.index_to_soup('https://admiralcloudberg.medium.com/about')
cover_url_list = []
for style in soup.find_all('style'):
for element in style:
match = re.search('https://.+?\.jpeg', element)
cover_url_list.append(match)
i = 0
while i < len(cover_url_list):
if cover_url_list[i] is not None:
cover_url = cover_url_list[i].group()
i = i+1
return cover_url
to retrieve the image I want to use. The image however has a landscape aspect ratio: I'd like to crop it to obtain a portrait-style cover.
After looking at calibre's code, it seems
this function does what I need, but I have no idea how to deal with files in a news recipe, particularly retrieving them and passing them along between methods. Could somebody help me with this?
The full recipe is attached for reference