Register Guidelines E-Books Today's Posts Search

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

Notices

Closed Thread
 
Thread Tools Search this Thread
Old 07-30-2010, 06:59 PM   #2371
sark666
Connoisseur
sark666 began at the beginning.
 
Posts: 51
Karma: 10
Join Date: Jul 2010
Device: colognesbook
I tried importing the string module using import string but it still didn't work.

I don't know what you mean by did it give an error. I haven't seen any errors throughout any of this. Do you mean launching calibre from the cmd line with a verbose setting? Or is there a built in error messaging that I'm not seeing? Same with the printing, you say you like to " print the results when the recipe runs, then I can see if it's doing what I expect." So you simply insert print statements on the variables? I'll try that.

But it runs further without the string there and using as you suggested. However, now I have just the table of contents of rss feed but each link simply leads to:

"This article was downloaded by calibre from http://www.metronews.ca/toronto/local/article/589013--caribana-brings-the-summer-spirit-to-toronto"

Well that's one specific example, but you see what I mean. I tried inserting a print statement. I simply added print s prior to the return, but I don't see where I'm supposed to see the output.
sark666 is offline  
Old 07-31-2010, 08:00 AM   #2372
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by sark666 View Post
I don't know what you mean by did it give an error. I haven't seen any errors throughout any of this. Do you mean launching calibre from the cmd line with a verbose setting?
Yes. It's very hard to construct recipes inside of Calibre's GUI.
Read This.



Quote:
is there a built in error messaging that I'm not seeing? Same with the printing, you say you like to " print the results when the recipe runs, then I can see if it's doing what I expect." So you simply insert print statements on the variables? I'll try that.
I do it this way:
Code:
ebook-convert myrecipe.recipe output_dir --test -vv>myrecipe.txt
Quote:
using as you suggested. However, now I have just the table of contents of rss feed but each link simply leads to:

"This article was downloaded by calibre from http://www.metronews.ca/toronto/local/article/589013--caribana-brings-the-summer-spirit-to-toronto"
It looks like that worked. That shows your recipe created the correct link and Calibre went there. However, when I went there, with scripts blocked in FireFox, I got nothing but photos. Allowing scripts produced the article text. You may need to deal with this issue to get anything.

Try posting your recipe (Inside code and spoiler tags) - I'll look at it.
Starson17 is offline  
Advert
Old 08-01-2010, 02:23 PM   #2373
Flexicat
Junior Member
Flexicat began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2010
Device: Kobo
Assistance requested, please.

Hello all,

I am certainly enjoying the control that calibre gives me with sorting my books with my new Kobo and have decided to try the customization for newsites and the like. As you might guess, I do not understand Python.

I have started a recipe and so far have gotten:


class AdvancedUserRecipe1280684448(BasicNewsRecipe):
title = u'Twisting the Hellmouth'
oldest_article = 7
max_articles_per_feed = 100

feeds = [(u'Latest', u'http://www.tthfanfic.org/rss.php')]


by following the instructions. This is the RSS feed for the latest stories.

Here I have hit a snag, however. I get the first page of all the articles, but nothing beyond that. The suggestion is to use the print url command, which makes sense.

The articles do have a print address but it is quite different from the original story address.

Story address: http://www.tthfanfic.org/Story-22821...ly+Literal.htm

Print address: http://www.tthfanfic.org/wholestory....1&format=print

I can see that each article has a special ID identifyer, but I cannot figure out how to extract it and put it into the print url command. I can put the bit after the ID number, but don't know how to fix the front text or even get the ID number.

I have tried

def print_version(self, url):
return url + '&format=print'

without success. I have also tried

def print_version(self, url):
return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'

also with out success.

I must be missing some vital step. Can someone here assist me?

Thank you.
Flexicat is offline  
Old 08-01-2010, 02:51 PM   #2374
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Flexicat View Post
I have started a recipe and so far have gotten:
Spoiler:
Code:
class AdvancedUserRecipe1280684448(BasicNewsRecipe):
    title          = u'Twisting the Hellmouth'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'Latest', u'http://www.tthfanfic.org/rss.php')]
Notice Code tags and Spoiler tags.

Quote:
I have also tried
def print_version(self, url):
return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'
also with out success.
This should work if you put the code needed to extract artid from the url.

Try this:
Code:
    def print_version(self, url):
        split1 = url.split("/")
        xxx = split1[3]
        split2 = xxx.split("-")
        artid =  split2[1]
        print "artid is: ', artid
        return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'
This isn't tested. Please don't some back with a simple "this doesn't work" - you'll need to set the numbers/subscripts if I've miscounted. I'll happily help, but make sure you post the complete recipe in code and spoiler tags.

Last edited by Starson17; 08-01-2010 at 02:55 PM.
Starson17 is offline  
Old 08-01-2010, 04:08 PM   #2375
Flexicat
Junior Member
Flexicat began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2010
Device: Kobo
Thank you!

Quote:
Notice Code tags and Spoiler tags
I shall try to be tidier.

Here is my adjusted code:
Spoiler:

Code:
class AdvancedUserRecipe1280684448(BasicNewsRecipe):
    title          = u'Twisting the Hellmouth'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'Latest', u'http://www.tthfanfic.org/rss.php')]

 def print_version(self, url):
        split1 = url.split("/")
        xxx = split1[3]
        split2 = xxx.split("-")
        artid =  split2[1]
        print "artid is: ', artid
        return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'


I get the error message

"ERROR: Invalid input: Could not create recipe. Error: unindent does not match any outer indentation level (recipe8.py, line 11)" when trying to update it.

Am I missing some sort of closing tag?

Also, what are the "numbers/subscripts" you mention? Are they the "/" marks in the URL?

Thank you
Flexicat is offline  
Advert
Old 08-01-2010, 07:44 PM   #2376
capidamonte
Not who you think I am...
capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
capidamonte's Avatar
 
Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
Has anyone else noticed that the Honolulu Star Advertiser recipe produces double articles -- ie: articles are headed properly but contain the same text repeated twice?
capidamonte is offline  
Old 08-01-2010, 08:31 PM   #2377
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Flexicat View Post
Thank you!
You're welcome.
Quote:
I shall try to be tidier.
I hope I didn't sound too grumpy
Quote:
Here is my adjusted code:
Spoiler:

Code:
class AdvancedUserRecipe1280684448(BasicNewsRecipe):
    title          = u'Twisting the Hellmouth'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'Latest', u'http://www.tthfanfic.org/rss.php')]

 def print_version(self, url):
        split1 = url.split("/")
        xxx = split1[3]
        split2 = xxx.split("-")
        artid =  split2[1]
        print "artid is: ', artid
        return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'
It's almost perfect
Quote:
I get the error message

"ERROR: Invalid input: Could not create recipe. Error: unindent does not match any outer indentation level (recipe8.py, line 11)" when trying to update it.
You had a space in front of the def print_version. Python is picky about indents. I made a typo that you copied when I pasted in the quotes. Because you pasted in the code tags, (which preserves indents) I was able to easily spot it.

Try this:
Spoiler:
Code:
class AdvancedUserRecipe1280684448(BasicNewsRecipe):
    title          = u'Twisting the Hellmouth'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'Latest', u'http://www.tthfanfic.org/rss.php')]

def print_version(self, url):
    split1 = url.split("/")
    xxx = split1[3]
    split2 = xxx.split("-")
    artid =  split2[1]
    print 'artid is: ', artid
    return 'http://www.tthfanfic.org/wholestory.php?no=' + artid + '&format=print'


Quote:
Also, what are the "numbers/subscripts" you mention? Are they the "/" marks in the URL?
I wasn't sure xxx = split1[3] was right, it might have been xxx = split1[4], but I've now checked them - the recipe ran OK.
Starson17 is offline  
Old 08-01-2010, 08:44 PM   #2378
Flexicat
Junior Member
Flexicat began at the beginning.
 
Posts: 8
Karma: 10
Join Date: Aug 2010
Device: Kobo
Thank you!
Quote:
I hope I didn't sound too grumpy
No you didn't. I appreciated the information. And, obviously, the code tags help fix problems too. Who knew a space could be such a tricky thing?
Flexicat is offline  
Old 08-02-2010, 07:46 AM   #2379
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Flexicat View Post
Thank you!

No you didn't. I appreciated the information. And, obviously, the code tags help fix problems too. Who knew a space could be such a tricky thing?
If you're happy with the results, you're done. If not, the next step is to remove junk that you don't want. The easiest way to do that is by identifying the junk using FireFox and FireBug, then putting a
remove_tags = [dict(name='div', attrs={'class':['classname']}),] or whatever into your recipe.
Starson17 is offline  
Old 08-03-2010, 02:42 PM   #2380
fuquaforlife
Junior Member
fuquaforlife began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Jul 2010
Device: sony
Quote:
Originally Posted by Starson17 View Post
These are good questions. I've never looked closely enough to answer it. Why don't you test it and tell us all? I'd have to look at the code or test it to answer. I suspect it just compares the date, not the time, but that's just a guess. Personally, I never read every single recipe every day, so I like lots of overlap. I just read articles until I get to the ones I've already read.
Just did a test -- looks like if you put in one day, the recipe picks up the last 24hours worth of articles!
fuquaforlife is offline  
Old 08-04-2010, 09:14 PM   #2381
sark666
Connoisseur
sark666 began at the beginning.
 
Posts: 51
Karma: 10
Join Date: Jul 2010
Device: colognesbook
@Starson17

Thanks, if you can look at it, it would be appreciated.

But the strange thing is I just re-ran it since Friday, and now on some I get the article with no image (haven't verified on the site if those actually have an image), some with just an image, and some with just the header alone.

Code:
class AdvancedUserRecipe1280289069(BasicNewsRecipe):
    title          = u'Metro Daily'
    oldest_article = 7
    max_articles_per_feed = 100

    feeds          = [(u'metro local', u'http://www.metronews.ca/Toronto/local/rss')]


    def print_version(self, url):
        baseurl='http://www.metronews.ca/ArticlePrint/' 
        split1 = url.split("/")
        xxx=split1 [6]
        split2= xxx[0:5]
        s =  baseurl + split2
        print s
        return s

Here are more feeds if it helps in having more examples when generated:

Code:
    feeds          = [
    (u'Local', u'http://www.metronews.ca/Toronto/local/rss'),
    (u'Entertainment', u'http://www.metronews.ca/Toronto/entertainment/rss'),
    (u'World', u'http://www.metronews.ca/Toronto/world/rss'),
    (u'Canada',u'http://www.metronews.ca/Toronto/canada/rss'),
    (u'Business',u'http://www.metronews.ca/Toronto/business/rss')
    ]
I'm going to read the article you linked but anything you can suggest to get consistent results would be appreciated. I'm a little confused by your mention of firefox. I"m not sure if calibre somehow uses the gecko engine in downloading the articles.
sark666 is offline  
Old 08-04-2010, 11:23 PM   #2382
saverio.palmieri
Junior Member
saverio.palmieri began at the beginning.
 
saverio.palmieri's Avatar
 
Posts: 2
Karma: 22
Join Date: Aug 2010
Location: Brazil
Device: Sony PRS-300, Mobipocket Reader (BB edition)
Lightbulb New Recipe - Brazilian Newspaper Folha de São Paulo.

Hi everyone,

Here goes my first try to write a recipe for Calibre. If anyone wanna give it a try and send me some feedback I will appreciate it very much.

Regards,

Saverio.
Attached Files
File Type: zip recipe_folhadesaopaulo.zip (1.2 KB, 241 views)
saverio.palmieri is offline  
Old 08-05-2010, 12:28 AM   #2383
saverio.palmieri
Junior Member
saverio.palmieri began at the beginning.
 
saverio.palmieri's Avatar
 
Posts: 2
Karma: 22
Join Date: Aug 2010
Location: Brazil
Device: Sony PRS-300, Mobipocket Reader (BB edition)
Thumbs up Fixed: Honolulu Star Advertiser recipe

Quote:
Originally Posted by capidamonte View Post
Has anyone else noticed that the Honolulu Star Advertiser recipe produces double articles -- ie: articles are headed properly but contain the same text repeated twice?
Fixed recipe attached.

Regards,

Saverio.
Attached Files
File Type: zip recipe_honolulu_star_advertiser.zip (1,017 Bytes, 255 views)
saverio.palmieri is offline  
Old 08-05-2010, 07:32 AM   #2384
capidamonte
Not who you think I am...
capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.capidamonte can even cheer up an android equipped with a defective Genuine Personality Prototype.
 
capidamonte's Avatar
 
Posts: 374
Karma: 30283
Join Date: Jan 2010
Location: Honolulu
Device: PocketBook 360 -- Ivory
Thanks Saverio!
capidamonte is offline  
Old 08-05-2010, 08:49 AM   #2385
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by sark666 View Post
I just re-ran it since Friday, and now on some I get the article with no image (haven't verified on the site if those actually have an image), some with just an image, and some with just the header alone.
I have no idea about the images, you'll have to check the source. As to those with just the header, this likely indicates that you aren't correctly calculating the article URL.

Quote:
I'm a little confused by your mention of firefox. I"m not sure if calibre somehow uses the gecko engine in downloading the articles.
No, FireFox is not used by Calibre's recipes. There are two basic steps in building a good recipe. First, you have to get or calculate the article URLs. From the above, it sounds like you don't have that step done yet. Then you usually want to clean up the results, removing advertising and navigation buttons, while keeping articles and photos. The easiest way to do that is to open the article in FireFox, point to something you want to keep or remove and ask FireBug how to refer to it. Once you know how it's identified, you can tell your recipe to keep it or remove it.
Starson17 is offline  
Closed Thread


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom column read ? pchrist7 Calibre 2 10-04-2010 02:52 AM
Archive for custom screensavers sleeplessdave Amazon Kindle 1 07-07-2010 12:33 PM
How to back up preferences and custom recipes? greenapple Calibre 3 03-29-2010 05:08 AM
Donations for Custom Recipes ddavtian Calibre 5 01-23-2010 04:54 PM
Help understanding custom recipes andersent Calibre 0 12-17-2009 02:37 PM


All times are GMT -4. The time now is 09:39 AM.


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