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 12-01-2010, 02:57 PM   #1
weebl
Junior Member
weebl began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Dec 2010
Device: none
How do I replace a common graphic in every story?

Every story I download from the website has a .gif file as a banner, I would like to replace it with another. I have the complete url for both.

Here is my recipe that does not work manner but it didn't work.

Code:
class AdvancedUserRecipe1291143841(BasicNewsRecipe):
    title          = u'Poughkeepsipe Journal'
    oldest_article = 7
    max_articles_per_feed = 100
    no_stylesheets = True
    timefmt = ' [%a, %d %b, %Y]'
    feeds          = [(u'Local News', u'http://poughkeepsiejournal.com/apps/pbcs.dll/oversikt?Category=RSS01&mime=xml'), (u'Local Business', u'http://poughkeepsiejournal.com/apps/pbcs.dll/oversikt?Category=RSS02&mime=xml'), (u'Local Sports', u'http://poughkeepsiejournal.com/apps/pbcs.dll/oversikt?Category=RSS03&mime=xml'), (u'Life', u'http://poughkeepsiejournal.com/apps/pbcs.dll/oversikt?Category=RSS04&mime=xml')]
    masthead_url          = 'http://www.poughkeepsiejournal.com/graphics/branding.gif'
  
    def print_version(self, url):
          return url.replace('http://www.poughkeepsiejournal.com', 'http://www.poughkeepsiejournal.com/print')
          return url.replace('http://www.poughkeepsiejournal.com/graphics/mastlogo.gif','http://www.poughkeepsiejournal.com/graphics/branding.gif')
weebl is offline   Reply With Quote
Old 12-01-2010, 03:04 PM   #2
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 weebl View Post
Every story I download from the website has a .gif file as a banner, I would like to replace it with another. I have the complete url for both.
Use preprocess_html.
Starson17 is offline   Reply With Quote
Old 12-01-2010, 03:54 PM   #3
weebl
Junior Member
weebl began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Dec 2010
Device: none
Quote:
Originally Posted by Starson17 View Post
Use preprocess_html.
I've tried the method you suggested for removing it, and I've also tried replacing it. But I think I am getting something wrong with the syntax. The whole story gets deleted.

Here is specifically what I need to have removed, or replaced from the story.
Code:
<div style="background-image:url(/gci/gc/p15/background_sprite.gif);background-color:transparent;background-position:-3000px 0;">

				<img src="/graphics/mastlogo.gif" alt=www.poughkeepsiejournal.com border="0" >

			</div>
weebl is offline   Reply With Quote
Old 12-01-2010, 04:50 PM   #4
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 weebl View Post
I've tried the method you suggested for removing it, and I've also tried replacing it. But I think I am getting something wrong with the syntax. The whole story gets deleted.

Here is specifically what I need to have removed, or replaced from the story.
Code:
<div style="background-image:url(/gci/gc/p15/background_sprite.gif);background-color:transparent;background-position:-3000px 0;">

				<img src="/graphics/mastlogo.gif" alt=www.poughkeepsiejournal.com border="0" >

			</div>
If you just want to remove the img tag, then try this:
remove_tags = [dict(name='img', attrs={'src':'/graphics/mastlogo.gif'})]
Starson17 is offline   Reply With Quote
Old 12-02-2010, 08:21 AM   #5
weebl
Junior Member
weebl began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Dec 2010
Device: none
Thanks - another question

Starson - thanks, that worked great. I will post the recipe and I would like to learn more. I've looked over the tutorial and command reference, but I still cannot figure out how to put together the syntax to swap one graphic for another. Could you help with that?
weebl is offline   Reply With Quote
Old 12-02-2010, 08:53 AM   #6
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 weebl View Post
Starson - thanks, that worked great. I will post the recipe and I would like to learn more. I've looked over the tutorial and command reference, but I still cannot figure out how to put together the syntax to swap one graphic for another. Could you help with that?
I'd use preprocess_html, as originally suggested. You were using the replace function, and that should work, or use ReplaceWith on the tag. Preprocess_html is called before the soup is parsed for links and images.
Starson17 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems Common to All Kobos Nicktheviking Kobo Reader 15 10-25-2010 10:35 PM
Common Problems Edd Sony Reader 0 05-26-2009 01:36 AM
Common Problems Edd Sony Reader 0 05-26-2009 01:34 AM
eBook piracy, how common is it? Stringer News 920 05-01-2009 10:33 AM


All times are GMT -4. The time now is 04:21 PM.


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