Register Guidelines E-Books Search Today's Posts Mark Forums Read

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

Notices

Reply
 
Thread Tools Search this Thread
Old 07-13-2011, 02:38 PM   #1
Gnome Eater
Junior Member
Gnome Eater began at the beginning.
 
Posts: 8
Karma: 10
Join Date: May 2011
Device: K3
Would it be possible to get a recipe for National Geographic Mag?

I know there are already recipes, but those are for the Daily News feed. I was curious if one could be made for the print edition only: http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine
Gnome Eater is offline   Reply With Quote
Old 07-14-2011, 12:50 AM   #2
Bortolotto
Member
Bortolotto began at the beginning.
 
Bortolotto's Avatar
 
Posts: 15
Karma: 14
Join Date: Jun 2011
Location: Brazil
Device: Kindle
Lightbulb NatGeoMag recipe

Hi Gnome!

Here is it! I hope you like it!

By the way: I like KDE!

Spoiler:
Code:
class NatGeoMag(BasicNewsRecipe):
    title                  = 'National Geographic Magazine'
    __author__             = 'Diniz Bortolotto'
    description            = 'The National Geographic Magazine'
    publisher              = 'National Geographic'
    oldest_article         = 1
    max_articles_per_feed  = 30
    category               = 'geography, magazine'
    language               = 'en_US'
    publication_type       = 'magazine'
    use_embedded_content   = False
    no_stylesheets         = True
    remove_javascript      = True

    feeds                  = [('National Geographic Magazine', 'http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine')]

    def print_version(self,url):
        segments = url.split('/')
        printURL = '/'.join(segments[0:3]) + '/print/' + '/'.join(segments[3:])
        return printURL

    remove_tags            = [dict(id='global_footer')]
Attached Files
File Type: txt NatGeoMag.txt (904 Bytes, 76 views)
File Type: epub NatGeoMag.epub (162.4 KB, 73 views)
Bortolotto is offline   Reply With Quote
Old 07-14-2011, 01:48 PM   #3
Gnome Eater
Junior Member
Gnome Eater began at the beginning.
 
Posts: 8
Karma: 10
Join Date: May 2011
Device: K3
Thanks!
Gnome Eater is offline   Reply With Quote
Old 07-14-2011, 10:00 PM   #4
oneillpt
Connoisseur
oneillpt began at the beginning.
 
Posts: 51
Karma: 46
Join Date: Feb 2011
Device: Kindle 3 (cracked screen!); PW1
Alternative recipe version with photos, but ...

Quote:
Originally Posted by Gnome Eater View Post
I know there are already recipes, but those are for the Daily News feed. I was curious if one could be made for the print edition only: http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine
Here is a quick version which does not use the "print version", and so retains the photos, but loses the continuation text which is only in the "print version". Another side effect is that the table of contents shows some items, such as "Presented by:", "Game: Animal Z's", "Now: Real Angry Birds", "Next: Elevator to Space", "Desktop Wallpaper", "Visions of Earth", "Flashback", "Your Shot" and "MyShot" (contents shown today) although these items are not extracted. The "Photo Journal" is included, but has no heading before the first photo. remove "dict(attrs={'class':'slide'})" to drop this item. If you do not want the "Editor's Note", remove "dict(attrs={'class':'main_2wide'})"

Code:
class AdvancedUserRecipe1310601553(BasicNewsRecipe):
    title          = u'NationalGeographicPrintEdition'
    oldest_article = 7
    max_articles_per_feed = 100
    use_embedded_content = False
    keep_only_tags    = [dict(attrs={'class':'main_3narrow'}),
      dict(attrs={'class':'main_2wide'}),
      dict(attrs={'class':'slide'})
      ]

    feeds          = [(u'National Geographic Print Edition', u'http://feeds.nationalgeographic.com/ng/NGM/NGM_Magazine')]
oneillpt is offline   Reply With Quote
Old 07-14-2011, 10:28 PM   #5
Bortolotto
Member
Bortolotto began at the beginning.
 
Bortolotto's Avatar
 
Posts: 15
Karma: 14
Join Date: Jun 2011
Location: Brazil
Device: Kindle
Quote:
Originally Posted by oneillpt View Post
Here is a quick version which does not use the "print version", and so retains the photos, but loses the continuation text which is only in the "print version". Another side effect is that the table of contents shows some items, such as "Presented by:", "Game: Animal Z's", "Now: Real Angry Birds", "Next: Elevator to Space", "Desktop Wallpaper", "Visions of Earth", "Flashback", "Your Shot" and "MyShot" (contents shown today) although these items are not extracted. The "Photo Journal" is included, but has no heading before the first photo. remove "dict(attrs={'class':'slide'})" to drop this item. If you do not want the "Editor's Note", remove "dict(attrs={'class':'main_2wide'})"
Yes! That is correct. I made the recipe very quickly and with readable content in mind. I don't know (yet ) how we can go to the next page and merge the content. So, I prefer the printable version. Maybe someone could help this matter.
Bortolotto is offline   Reply With Quote
Old 07-15-2011, 09:09 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 Bortolotto View Post
I don't know (yet ) how we can go to the next page and merge the content. So, I prefer the printable version. Maybe someone could help this matter.
There are lots of posts in this forum about multipage handling. Search for that term and you will find useful information.

Basically, a multipage does this:
1) it finds the link to the "next page"
2) it goes to that page and gets everything on it that the recipe author wants.
3) it pastes that stuff into the first page.
4) it repeats 1-3 until there is no "next page" link.

The recursion is tricky to understand, but it's easy to copy the multipage code, which is already set up. Almost every multipage recipe is the same and copies the same bit of multipage code, except for the part about what tag is used to find the "next page" and the part about what part of the next page to keep.

Start with the Adventure Gamer recipe, then ask questions about what you don't understand.
Starson17 is offline   Reply With Quote
Old 11-19-2011, 04:23 PM   #7
iostream
Junior Member
iostream began at the beginning.
 
Posts: 3
Karma: 10
Join Date: May 2009
Device: none
Has anyone consolidated this into some working code yet? Though my username is Iostream, I'm not that handy with code myself.

I just need everything that is in the printed edition, including the pictures.

Thanks,

Iostream
iostream is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
National Geographic promised, where is it? jeannieju Calibre 6 06-25-2011 01:17 AM
National Geographic (DE) xXxXxXxXxXx Recipes 0 05-21-2011 08:56 AM
Recipe for National Geographic *Updated* gagsays Recipes 3 05-19-2011 12:30 PM
National Geographic Recipe (need some improvement) gagsays Recipes 6 05-19-2011 12:21 PM
National Geographic Request Oilfieldtrash Recipes 5 11-29-2010 08:35 AM


All times are GMT -4. The time now is 07:16 PM.


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