View Single Post
Old 01-08-2012, 02:53 AM   #8
kiavash
Old Linux User
kiavash began at the beginning.
 
Posts: 36
Karma: 12
Join Date: Jan 2012
Device: NST
There it is. It fetches the latest cover and add it to the ebook.

PHP Code:
    #  No magazine is complete without cover. Let's get it then!
    # The function is adapted from the Economist recipe
    
def get_cover_url(self):
        
cover_url None
        cover_page_location 
'http://www.mwjournal.com/Journal/'    # Cover image is located on this page
        
soup self.index_to_soup(cover_page_location)    
        
cover_item soup.find('img',attrs={'src':lambda xand '/IssueImg/3_MWJ_CurrIss_CoverImg' in x})    # There are three files named cover, we want the highest resolution which is the 3rd image. So we look for the pattern. Remember that the name of the cover image changes every month so we cannot search for the complete name. Instead we are searching for the pattern
        
if cover_item:
            
cover_url 'http://www.mwjournal.com' cover_item['src'].strip()    # yeah! we found it. Let's fetch the image file and pass it as cover to calibre
        
return cover_url 
kiavash is offline   Reply With Quote