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 03-23-2011, 05:15 AM   #1
Hurda
Junior Member
Hurda began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
Adding image from RSS

I'm trying to create recipe for video games news server http://games.tiscali.cz/
fro the feed http://games.tiscali.cz/rss2.xml

There each article has an image:

<item>
<title>a</title>
<guid isPermaLink="true">http://games.tiscali.cz/b</guid>
<link>http://games.tiscali.cz/obrazky/b</link>
<description><![CDATA[D]]></description>
<category><![CDATA[Obrázky]]></category>
<author><![CDATA[games@tiscalimedia.cz (levis)]]></author>
<pubDate>Tue, 22 Mar 2011 19:53:08 +0000</pubDate>
<enclosure url="http://games.cz.imag3box.com/uploads/1-1-game14059-img198044_670x377.jpg" type="image/jpeg"></enclosure>

I woudl like to add the image in the enclosure after the first <p> element in the body of an article - what do i need to do.

I'm Java programmer, si I'm not skilled with beatiful soap and I can't event find method to override (where I have acces both to current article body and to this rss definition).

Thanks in davance
Hurda is offline   Reply With Quote
Old 03-23-2011, 09:40 AM   #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 Hurda View Post
I'm trying to create recipe for video games news server http://games.tiscali.cz/
fro the feed http://games.tiscali.cz/rss2.xml

There each article has an image:
It sounds like you are saying that you want an image from the feed page. Where do you want to put that image? On the article page or the page that lists the articles?

A standard Calibre recipe-created ebook puts the images on the article page. Usually all the images you want are already on that page (on the site) and you just need to make sure you don't remove them with the recipe. If you need to grab them from the RSS feed page, or some other page, that can be done, too.

Last edited by Starson17; 03-23-2011 at 09:44 AM.
Starson17 is offline   Reply With Quote
Advert
Old 03-23-2011, 11:50 AM   #3
Hurda
Junior Member
Hurda began at the beginning.
 
Posts: 6
Karma: 10
Join Date: Feb 2011
Device: Kindle 3
Quote:
Originally Posted by Starson17 View Post
It sounds like you are saying that you want an image from the feed page. Where do you want to put that image? On the article page or the page that lists the articles?

A standard Calibre recipe-created ebook puts the images on the article page.
I'm trying to do exactly that, I don't think I'm removing them, yet they are not there (on the article page) - where shoudl tehy be? after first h1,h2 or at the end?

This si my code

Code:
import re
from calibre.web.feeds.recipes import BasicNewsRecipe

class GamesTiscali(BasicNewsRecipe):
    __author__ = 'hurda@keyelements.org'
    
    title = u'Games.tiscali.cz'
    oldest_article = 7
    max_articles_per_feed = 2
    remove_empty_feeds = True

    timefmt = ' [%a - %d.%m.%Y]'  
    
    description = 'Games.tiscali.cz - The Video Game portal eBook edition'
    no_stylesheets = True
    #delay                  = 1
    use_embedded_content = False
    encoding = 'utf8'
    publisher = 'Games.tiscali.cz'
    category = 'Video games'
    language = 'cs_CZ'
    publication_type = 'magazine'
    
    masthead_url = 'http://games.tiscali.cz/design/logo.gif'
    cover_url = 'http://games.tiscali.cz/design/logo.gif' 
    
    extra_css = """
    body{ color: black } 
    .introduction{font-weight: bold}
    .story-feature{display: block; padding: 0; border: 1px solid; width: 40%; font-size: small}
    .story-feature h2 {text-align: center; text-transform: uppercase} 
    """

    feeds = [
            (u'Vše', u'http://games.tiscali.cz/rss2.xml'),
            (u'Recenze', u'http://games.tiscali.cz/recenze/rss2.xml'),
            (u'Preview', u'http://games.tiscali.cz/preview/rss2.xml'),
            (u'Dojmy z hraní', u'http://games.tiscali.cz/prvni-dojmy/rss2.xml'),
            (u'Téma', u'http://games.tiscali.cz/tema/rss2.xml'),
            (u'Hardware', u'http://games.tiscali.cz/hardware/rss2.xml'),
            (u'Návod', u'http://games.tiscali.cz/navod/rss2.xml'),
            (u'Rozhovor', u'http://games.tiscali.cz/rozhovor/rss2.xml'),
            (u'Oznámení', u'http://games.tiscali.cz/oznameni/rss2.xml'),
            (u'Retro', u'http://games.tiscali.cz/retro/rss2.xml')
    ]
    
    keep_only_tags = [
                       dict(name='div', attrs={'class':['content box']})
                       ]

    remove_tags = [
                     dict(name='span', attrs={'class':['article-platform']}), 
                     #dict(name='div', attrs={'id':['perex']}),
                     dict(name='object', attrs={'id':['player']}),
                     dict(name='link'),
                     dict(name='meta'),
                     dict(name='div', attrs={'id':['addsense']}),
                     dict(name='ul', attrs={'class':['articles-thumbs box']}),
                     dict(name='ul', attrs={'class':['tabs box']}),
                     dict(name='div', attrs={'class':['box-02 box']}),
                     dict(name='p', attrs={'class':['articles-bottom']})                    
                     ]
    
    remove_attributes = ['style']
Hurda is offline   Reply With Quote
Old 03-23-2011, 02:01 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 Hurda View Post
I'm trying to do exactly that, I don't think I'm removing them, yet they are not there (on the article page) - where shoudl tehy be? after first h1,h2 or at the end?
Test your code without the keep_only or remove_tags and see if the images appear.
Starson17 is offline   Reply With Quote
Reply

Tags
recipe images


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding date (and maybe other info) to custom cover image chewi Recipes 7 03-16-2011 04:21 AM
Adding cover image miwie Library Management 9 03-04-2011 10:39 AM
Adding cover image to PDF? silvijakk Bookeen 2 04-02-2009 03:33 PM
Adding a cover image to mobipocket files rheostaticsfan Kindle Formats 4 05-25-2008 03:40 PM
Adding My Own RSS Feeds Safely JeffASonyReader Sony Reader Dev Corner 9 01-16-2008 07:05 PM


All times are GMT -4. The time now is 05:32 AM.


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