![]() |
#1 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Can't get print_version to do anything
I'm brand new to Calibre and haven't used Python for years. I am following the tutorial for custom news feeds. I notice that BBC printable pages are now of the form ...something?print=true, so I have added to the basic recipe
Code:
def print_version(self, url): return url.append(u'?print=true') Full recipe: Code:
class AdvancedUserRecipe1321386207(BasicNewsRecipe): title = u'BBC' oldest_article = 3 max_articles_per_feed = 2 auto_cleanup = True no_stylesheets = True feeds = [(u'BBC Front Page', u'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml')] def print_version(self, url): return url.append(u'?print=true') |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,331
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
When you call ebook-convert, call it with the full path to the edited recipe file.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Yes, I'm using
ebook-convert c:\temp\test.recipe .epub --test -vv --debug-pipeline debug |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,331
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You need a indent before def it has to be in line with the rest of the contents of the class
|
![]() |
![]() |
![]() |
#5 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Aha, so that's what the tutorial meant about indentation ... I missed that--have been using Ruby too long. Thanks for the quick answer!
|
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Although the print_version method works fine now, the result is still not the print version of the BBC story. Perhaps it's something funny about BBC. Using the command line
wget http://www.bbc.co.uk/news/world-midd...260?print=true gives the right page, printable form. However, if I modify print_version to Code:
def print_version(self, url): return 'http://www.bbc.co.uk/news/world-middle-east-15762260?print=true' |
![]() |
![]() |
![]() |
#7 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
|
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Here is the recipe:
Code:
class AdvancedUserRecipe1321386207(BasicNewsRecipe): title = u'BBC' oldest_article = 3 max_articles_per_feed = 2 auto_cleanup = True no_stylesheets = True feeds = [(u'BBC Front Page', u'http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml')] def print_version(self, url): return url + u'?print=true' |
![]() |
![]() |
![]() |
#9 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,331
Karma: 27182818
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
The problem is probably that the RSS feed provides links to an intermediate page which is automatically redirected (this is done by websites for tracking purposes). So your print=true is being discarded during the redirect. To get around it you would need to implement the get_article_url method in your recipe to resolve the correct article url.
|
![]() |
![]() |
![]() |
#10 |
Junior Member
![]() Posts: 7
Karma: 10
Join Date: Nov 2011
Location: Jos, Nigeria
Device: Kindle
|
Thanks.
|
![]() |
![]() |
![]() |
#11 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Code:
def get_article_url(self, article): print article return None |
|
![]() |
![]() |
![]() |
#12 |
Old Linux User
![]() Posts: 36
Karma: 12
Join Date: Jan 2012
Device: NST
|
Did you find out why? I am having the same issue.
Edit: Mine got solved this way: PHP Code:
Last edited by kiavash; 01-10-2012 at 12:16 PM. Reason: Solved mine and posted the solution |
![]() |
![]() |
![]() |
#13 |
Junior Member
![]() Posts: 9
Karma: 10
Join Date: Jan 2012
Device: SONY PRS-T1
|
I had the exact same problem the last days, the solution was very simple after all
![]() I just entered the feed I provided to the script into the browser, in you case: http://newsrss.bbc.co.uk/rss/newsonl...t_page/rss.xml It will then redirect you to: http://feeds.bbci.co.uk/news/rss.xml?edition=int Put this link into you script instead of the first xml-link. Now use the Code:
def print_version(self, url): return url + '?print=true') Last edited by roedi06; 01-17-2012 at 05:50 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to use print_version to get the print page of | Starson17 | Recipes | 0 | 06-15-2011 12:05 PM |
Using print_version for custom news source | sexymax15 | Recipes | 0 | 06-15-2011 10:53 AM |
SacBee print_version syntax | thczv | Recipes | 6 | 04-12-2011 09:38 AM |
Using PubDate in print_version of custom news source | mobilereader72 | Calibre | 4 | 05-30-2009 05:52 PM |