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 12-22-2008, 02:28 PM   #76
kiklop74
Guru
kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.kiklop74 can program the VCR without an owner's manual.
 
kiklop74's Avatar
 
Posts: 800
Karma: 194644
Join Date: Dec 2007
Location: Argentina
Device: Kindle Voyage
Judging you? Why would we do such thing?
kiklop74 is offline  
Old 12-23-2008, 03:42 AM   #77
moggie
Enthusiast
moggie is on a distinguished road
 
moggie's Avatar
 
Posts: 34
Karma: 74
Join Date: Nov 2008
Location: Cambridge,UK
Device: sony 505
Images

I am trying to work on a recipe, is there a documented way of getting at the resizing functionality of comic2* from a feeds2* recipe ?
moggie is offline  
Advert
Old 12-23-2008, 08:11 AM   #78
moggie
Enthusiast
moggie is on a distinguished road
 
moggie's Avatar
 
Posts: 34
Karma: 74
Join Date: Nov 2008
Location: Cambridge,UK
Device: sony 505
The sugarquill

This recipe can be used to make lrf from pages at the sugarquill. The sugarquill is a website dedicated to relatively high quality Harry Potter fan fiction ( http://www.sugarquill.net/index.php?action=faq ).

This recipe takes an author id as the username. And searches for all stories by that author and makes a book up with each story appearing in the index. If a story has multiple chapters it pulls down each chapter.
Code:
feeds2lrf TheSugarQuill.py --username 310
..
Output written to /Users/jb23/tmp/quill/code/The Stories of Arabella and Zsenya at The sugar quill [Tue, 23 Dec 2008].lrf
It does it's best with the fan art section but I think that still needs some work, I would be interested in trying to reuse some comic2lrf code here.

This is my first bit of python programming but it seems to work quiet well.
Code:
mpb19815i:code jb23$ cat !$
#!/usr/bin/env  python

__license__   = 'GPL v3'
__copyright__ = '2008, James Beal <james_@catbus.co.uk>'
'''
www.sugarquill.net
'''
import re
from calibre.web.feeds.news import BasicNewsRecipe
from BeautifulSoup import BeautifulSoup 

class TheSugarQuill(BasicNewsRecipe):
    
    description = 'Harry Potter Stories'
    match_regexps = [r'read.php']
    no_stylesheets     = True


    def parse_index(self):
	list = []
	articles = []
       
        url = "http://www.sugarquill.net/index.php?action=profile&id=%s" % (self.username) 
        soup = self.index_to_soup(url)
	for table in soup.findAll('table', attrs={'width':'80%'}):
		td=table.find('td',attrs={'class':'highlightcolor2'})
		td1=td.findNext('td',attrs={'class':'highlightcolor2'})
                self.__author__ = td1.next
		self.title = "The Stories of %s at The sugar quill" % (self.__author__)
		self.html2lrf_options = [ 
                         '--author', td1.next,
                         '--publisher', 'The Sugar Quill'
                       ]
        
	for table in soup.findAll('table', attrs={'width':'90%'}):
            a = table.find('a')
            if a and a.has_key('href'):
		url = "http://www.sugarquill.net/%s" % (a['href'])
                title = self.tag_to_string(a)
		td=table.find('td',attrs={'class':'highlightcolor2'})
                description = td.next
		td1=table.find('td',attrs={'class':'highlightcolor1'})
		date=''
		list.append((title,[{
                                 'title':title, 'date':date,
                                 'url':url,
                                 'description':description
                                }]))
	return list


    def process_chapter(self,  page):
        head = page.head
	if head != None:
        	head.extract()
	td=page.find('td',attrs={'class':'top_pane'})
	if td != None:
		if td.parent != None: 
        		if td.parent.parent != None:
            	            td.parent.parent.extract()
        td=page.find('td',attrs={'class':'bottom_pane'})
        if td != None:
                if td.parent != None:
                        if td.parent.parent != None:
                            td.parent.parent.extract()
        td=page.find('td',attrs={'class':'info_pane'})
        if td != None:
                if td.parent != None:
                     td.parent.extract()
        td=page.find('td',attrs={'class':'info2_pane'})
        if td != None:
                if td.parent != None:
                     td.parent.extract()
	td=page.find("form", attrs={'name':'SQ3'})
        if td != None:
                if td.parent != None:
                        if td.parent.parent != None:
                            td.parent.parent.extract()
        td=page.find('td',attrs={'class':'highlightcolor1'})
        if td != None:
                if td.parent != None:
                     td.parent.extract()
        form=page.find("form", attrs={'action':'read.php'})
	if form != None:
           table = form.parent
           if table != None:
               table.extract()
        sugar_signoff = page.find("div" , { "style" : "font-family: Verdana; font-size: 10px;"} )
        if sugar_signoff != None:
            sugar_signoff.extract()
        return page

    def preprocess_html(self, soup):
	from urllib2 import urlopen 
	try:
		form = soup.find("form", attrs={'action':'read.php'})
	except:
		return self.process_chapter(soup)
	if form == None:
		return self.process_chapter(soup)
	process =  ''
	storyid= form.input['value']
	story_url= "http://www.sugarquill.net/read.php?storyid=%s" % ( storyid ) 
	num_chapters = int(len(form('option')))
	current_chapter = 1
	while current_chapter <= num_chapters :
		url = "%s&chapno=%d" % (story_url,current_chapter )
		process += '<span style="page-break-after: always"></span>' 
		process += str (self.process_chapter(BeautifulSoup(urlopen(url).read())))
		current_chapter += 1
	process += '<span style="page-break-after: always"></span>'
        return BeautifulSoup(process)
Attached Files
File Type: zip TheSugarQuill.zip (1.4 KB, 435 views)
moggie is offline  
Old 12-23-2008, 12:33 PM   #79
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
An interesting use of the recipe system One suggestion. Expand your description system to include instructions about the use of the username as an id, so that people who encounter the recipe in the GUI will know how to use it.

Using the image transformations of comic2lrf is overkill in IMO. The SONY Reader does an adequate job for pictures that don't contain much text.
kovidgoyal is offline  
Old 12-23-2008, 01:59 PM   #80
Amalthia
Wizard
Amalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beauty
 
Amalthia's Avatar
 
Posts: 1,159
Karma: 32196
Join Date: Jan 2007
Location: Anchorage, AK
Device: Sony Reader PRS-505, PRS-650, PRS-T3, Pocketbook HD2
dont' want to sound greedy or anything...

But would this receipe work with other Harry Potter archives that use the same archiving software?
Amalthia is offline  
Advert
Old 12-23-2008, 02:05 PM   #81
moggie
Enthusiast
moggie is on a distinguished road
 
moggie's Avatar
 
Posts: 34
Karma: 74
Join Date: Nov 2008
Location: Cambridge,UK
Device: sony 505
Quote:
Originally Posted by Amalthia View Post
But would this receipe work with other Harry Potter archives that use the same archiving software?
There are other Harry Potter sites ?, That use the same software.

If you or email/PM me some urls If it doesn't work I will do my best to make it work.

Although the website may end up having to go into the password field......
moggie is offline  
Old 12-23-2008, 02:42 PM   #82
moggie
Enthusiast
moggie is on a distinguished road
 
moggie's Avatar
 
Posts: 34
Karma: 74
Join Date: Nov 2008
Location: Cambridge,UK
Device: sony 505
Quote:
Originally Posted by kovidgoyal View Post
An interesting use of the recipe system One suggestion. Expand your description system to include instructions about the use of the username as an id, so that people who encounter the recipe in the GUI will know how to use it.
Ok I will do that, is appropriate to bundle it in with the other recipes ? If so if I want to make changes in the future should I send in the same kind of patch as any other developer would eg use bzr ?

Quote:
Originally Posted by kovidgoyal View Post
Using the image transformations of comic2lrf is overkill in IMO. The SONY Reader does an adequate job for pictures that don't contain much text.
Remember I don't get a real reader until christmas day so I have only tested it with calibre's viewer. I would like to know as I could then start automating creating books from webcomics.
moggie is offline  
Old 12-23-2008, 02:50 PM   #83
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by moggie View Post
Ok I will do that, is appropriate to bundle it in with the other recipes ? If so if I want to make changes in the future should I send in the same kind of patch as any other developer would eg use bzr ?



Remember I don't get a real reader until christmas day so I have only tested it with calibre's viewer. I would like to know as I could then start automating creating books from webcomics.
Bundling it would make it accessible to a lot of people with very little effort on your part. Sure you can just mail me patches. (or just a new version of the recipe file).

At some point I will have to create a framework in calibre for fetching more general online content (like books form feedboks/mobileread, content from fanfic sites, etc), but that's a big job, so for the time being, just add it as a recipe
kovidgoyal is offline  
Old 12-23-2008, 02:55 PM   #84
moggie
Enthusiast
moggie is on a distinguished road
 
moggie's Avatar
 
Posts: 34
Karma: 74
Join Date: Nov 2008
Location: Cambridge,UK
Device: sony 505
Quote:
Originally Posted by kovidgoyal View Post
Bundling it would make it accessible to a lot of people with very little effort on your part. Sure you can just mail me patches. (or just a new version of the recipe file).
I would love you to bundle it It's already got the GPL V3 in there in the same way you have for your recipes. And if you are happy to take new versions from me or others I would be pleased.

Quote:
Originally Posted by kovidgoyal View Post
At some point I will have to create a framework in calibre for fetching more general online content (like books form feedboks/mobileread, content from fanfic sites, etc), but that's a big job, so for the time being, just add it as a recipe
I will happily add recipes as I can. Would it be possible to have a more flexible way of passing arguments over as username and password are a bit restricting. And remember that its my first bit of real python code.
moggie is offline  
Old 12-23-2008, 03:02 PM   #85
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Sure, just test the recipe with both epub and LRF output and when you're satisfied, either attach it here or open a ticket and attach it to that.

I have a very liberal policy when it comes to accepting patches
kovidgoyal is offline  
Old 12-23-2008, 05:53 PM   #86
Amalthia
Wizard
Amalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beautyAmalthia does all things with Zen-like beauty
 
Amalthia's Avatar
 
Posts: 1,159
Karma: 32196
Join Date: Jan 2007
Location: Anchorage, AK
Device: Sony Reader PRS-505, PRS-650, PRS-T3, Pocketbook HD2
Quote:
Originally Posted by moggie View Post
There are other Harry Potter sites ?, That use the same software.

If you or email/PM me some urls If it doesn't work I will do my best to make it work.

Although the website may end up having to go into the password field......
I'm rather sure there are other archives that run off similar archiving software but I'll have to double check. I have most of my bookmarks on my home computer so it may take a few hours or a day before I can get back to you with links. (which I'll private message you with)

Amalthia
Amalthia is offline  
Old 12-23-2008, 06:32 PM   #87
orkan39
Junior Member
orkan39 began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2008
Device: PRS-700
Hi guys. Thanks for all the awesome recipes. Would it be possible for you to create feeds for:
Engadget - http://www.engadget.com/
Fudzilla - http://www.fudzilla.com/
Tom's Hardware - http://www.tomshardware.com/us/ (Articles and News are separate)
Sarcastic Gamer - http://sarcasticgamer.com/wp/

I realise that this is asking a lot but I would really appreciate it and it would make my PRS-700 so much more useful and valuable.
Thanks in advance
orkan39 is offline  
Old 12-24-2008, 12:38 AM   #88
macthekitten
Enthusiast
macthekitten has a complete set of Star Wars action figures.macthekitten has a complete set of Star Wars action figures.macthekitten has a complete set of Star Wars action figures.
 
Posts: 31
Karma: 289
Join Date: Dec 2008
Location: Ontario Canada
Device: PRS700
recipe huh...i make a mean potato & leek soup...

sorry I couldn't reist

I know I know, don't interrupt when grown ups are talking LOL
macthekitten is offline  
Old 12-24-2008, 01:23 AM   #89
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,860
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Feel free to create a custom potato and leek recipe for calibre
kovidgoyal is offline  
Old 12-24-2008, 11:21 AM   #90
macthekitten
Enthusiast
macthekitten has a complete set of Star Wars action figures.macthekitten has a complete set of Star Wars action figures.macthekitten has a complete set of Star Wars action figures.
 
Posts: 31
Karma: 289
Join Date: Dec 2008
Location: Ontario Canada
Device: PRS700
I'm on it!!!
macthekitten 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 03:39 AM.


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