Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Recipes

Notices

Reply
 
Thread Tools Search this Thread
Old 03-27-2024, 06:46 AM   #1
413Michele
Enthusiast
413Michele began at the beginning.
 
Posts: 44
Karma: 10
Join Date: Jan 2021
Location: Italy
Device: Kobo Libra 2, Kindle Paperwhite (1st gen)
Question Help with image processing

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
Attached Files
File Type: recipe myrecipe.recipe (4.6 KB, 28 views)
413Michele is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Comic Processing Lowers Image Resolution Limeonade Calibre 1 04-17-2022 04:59 PM
Heuristic processing saxondawg Conversion 6 01-21-2018 07:43 PM
Bug in Kobo processing of epub files causing hang in "Processing content" BensonBear Kobo Reader 21 12-21-2012 05:47 AM
Trying to use Textile processing getajob Conversion 18 03-09-2011 07:34 AM
Image processing using html2epub? Portnull Calibre 2 06-03-2009 12:31 PM


All times are GMT -4. The time now is 12:01 PM.


MobileRead.com is a privately owned, operated and funded community.