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 06-23-2012, 08:56 PM   #16
NotTaken
Connoisseur
NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.NotTaken is fluent in JavaScript as well as Klingon.
 
Posts: 65
Karma: 4640
Join Date: Aug 2011
Device: kindle
Quote:
Originally Posted by faber1971 View Post
Thanks to you and God Kovid.
It's incredible how, even if we try to empower our skills, there is always someone who flies in an upper sky. Thank you, guys.
Anyhow, let's try to sum up the output of this interesting thread:
1) what can we do for the recipe of Marketing Sensoriale? Will it be automatically updated in next Calibre update?
2) will the new browser feature automatically be annexed into next Calibre release or should we download it separately, as a plugin?
Re 2:

The latest recipe won't work until next release but if you want to can use the recipe before with the fork_helper plugin.
NotTaken is offline   Reply With Quote
Old 06-23-2012, 10:48 PM   #17
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yes, it will be included in the next calibre relase. And just for completeness, here is a version that avoids double fetching the article html.

Code:
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.utils.ipc.simple_worker import fork_job
from calibre.ptempfile import PersistentTemporaryFile

js_fetcher = '''

import calibre.web.jsbrowser.browser as jsbrowser

def grab(url):
    browser = jsbrowser.Browser()
    #10 second timeout
    browser.visit(url, 10)
    browser.run_for_a_time(10)
    html = browser.html
    browser.close()
    return html

    '''
class MarketingSensoriale(BasicNewsRecipe):

    title                 = u'Marketing sensoriale'
    description           = 'Marketing Sensoriale, il Blog'
    category              = 'Blog'
    oldest_article        = 7
    max_articles_per_feed = 200
    no_stylesheets        = True
    encoding              = 'utf8'
    use_embedded_content  = False
    language              = 'it'
    remove_empty_feeds    = True
    recursions = 0
    requires_version = (0, 8, 58)
    auto_cleanup = False
    simultaneous_downloads = 1
    articles_are_obfuscated = True

    remove_tags_after    = [dict(name='div', attrs={'class':['article-footer']})]


    def get_article_url(self, article):
        return article.get('feedburner_origlink',  None)

    def get_obfuscated_article(self, url):
        result = fork_job(js_fetcher, 'grab', (url,), module_is_source_code=True)

        html = result['result']
        if isinstance(html, type(u'')):
            html = html.encode('utf-8')
        pt = PersistentTemporaryFile('.html')
        pt.write(html)
        pt.close()
        return pt.name

    feeds          = [(u'Marketing sensoriale', u'http://feeds.feedburner.com/MarketingSensoriale?format=xml')]
kovidgoyal is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
360 DRM protected prc msca PocketBook 2 01-25-2012 06:16 AM
Are iBook pubs protected? mjhudston Apple Devices 14 01-01-2011 10:13 AM
This book is protected by DRM racsw Calibre 2 12-19-2010 12:16 AM
Protected page trout Sony Reader 6 07-08-2010 08:24 AM
PDF protected by DRM, only... it's not? pooks Calibre 17 01-30-2010 11:44 PM


All times are GMT -4. The time now is 02:51 AM.


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