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

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

Notices

Closed Thread
 
Thread Tools Search this Thread
Old 05-25-2010, 01:19 AM   #1981
TouchToneTommy
Junior Member
TouchToneTommy began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2010
Device: none
Thanks for your input and insights, dwanthny and Starson17.

So far, I have not been able to make either to work. Spent the evening googling Python, and not really grasping it yet.

One thing I tried, was " insert(url[:40] + 'v-print/' + url[40:]) ", to break the url at the 40th character, insert the "v-print", and then continue (since the date is always the same number of characters, using 2 digits for even a single digit month or day), but I don't have the form or syntax right yet.

I also tried looking for a newspaper from the same publisher (McClatchy) in the included recipes, hoping that their web templates might be the same. So far, haven't found anything.
TouchToneTommy is offline  
Old 05-25-2010, 01:22 AM   #1982
mik991
Junior Member
mik991 began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2010
Device: Nook
Hi,

Is there anyway to customize the filename using the recipe?
Currently a news file will be named something like "Newsweek_2010-5-24.epub" I would like it to read "Newsweek.epub".

This way when calibre moves over files to my nook it should just overwrite the old effectively deleting obsolete news.

Thanks


Quote:
No you can't adjust the filenames for news files. Eventually calibre will be able to delete news files from the device automatically when you connect it, but not at the moment.

Last edited by mik991; 05-25-2010 at 11:57 AM.
mik991 is offline  
Old 05-25-2010, 07:50 AM   #1983
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 TouchToneTommy View Post
Thanks for your input and insights, dwanthny and Starson17.

So far, I have not been able to make either to work. Spent the evening googling Python, and not really grasping it yet.

One thing I tried, was " insert(url[:40] + 'v-print/' + url[40:]) ", to break the url at the 40th character, insert the "v-print", and then continue (since the date is always the same number of characters, using 2 digits for even a single digit month or day), but I don't have the form or syntax right yet.

I also tried looking for a newspaper from the same publisher (McClatchy) in the included recipes, hoping that their web templates might be the same. So far, haven't found anything.
Run your recipe from the command line, use the -vv option and print the "url" variable to see why it isn't working. Read this
Starson17 is offline  
Old 05-25-2010, 12:13 PM   #1984
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 dwanthny View Post
Thanks for the pointer.
I am curious though, do wildcards work?
If they do what I wrote should return the print edition.
I am not a Python expert, so I'm not the one to ask. I've never tried to use wildcards outside of the regular expression context. All I can say is that I've seen the insert-something-into-url problem solved several times in recipes, and it's always been just a split-at-slash and reassemble or a regex solution.
Starson17 is offline  
Old 05-25-2010, 12:19 PM   #1985
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: 26,125
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
wildcards do not work, you have to use a regular expression or the fnmatch module if you want to use wildcards.
kovidgoyal is offline  
Old 05-25-2010, 12:26 PM   #1986
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 TouchToneTommy View Post
One thing I tried, was " insert(url[:40] + 'v-print/' + url[40:]) "
I really should never give advice on Python, without testing, but I can't resist. The code above doesn't look right to me. "insert" will put something into a list, but you've got two problems. First is your form - you'd need to specify the list you're inserting into like: list.insert(i, x). The first argument is the index of the element before which to insert.

Second, I don't think you can insert into a string in Python - instead, you create a new string.

You might try this:

Code:
url2 = url[:40] + 'v-print/' + url[40:]
return url2
Starson17 is offline  
Old 05-25-2010, 12:31 PM   #1987
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 kovidgoyal View Post
wildcards do not work, you have to use a regular expression or the fnmatch module if you want to use wildcards.
When first trying to understand regular expressions, I asked a friend for help. IIRC, his answer was something like .. "If you have a problem that needs to be solved with a regular expression ... now you have two problems."
Starson17 is offline  
Old 05-25-2010, 02:28 PM   #1988
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: 26,125
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Quote:
Originally Posted by Starson17 View Post
When first trying to understand regular expressions, I asked a friend for help. IIRC, his answer was something like .. "If you have a problem that needs to be solved with a regular expression ... now you have two problems."
But I must say that having learning regular expressions has boosted my productivity by an order of magnitude.
kovidgoyal is offline  
Old 05-25-2010, 05:24 PM   #1989
chaley
"chaley", not "charley"
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 5,636
Karma: 1137414
Join Date: Jan 2010
Location: France
Device: Many android devices
I have been a user of regular expressions since my early ed/ex/vi days in the early '70s. I can't imagine working on text without them. I remember 'grokking' (shows my age) that a regexp is just a description/template/pattern, and the lights turned on.

If you enjoy constructing regexps, play a bit with (f)lex, a program that generates lexical analyzers that can read files with known structure and split them into usable 'words' (technically, tokens). I am often surprised by how many problems are amenable to solution by a combination of lexical processing and subsequent parsing.

Yes, I know I am weird. Can't help it, and really don't want to change.
chaley is offline  
Old 05-25-2010, 08:12 PM   #1990
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: 26,125
Karma: 5381911
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Yeah calibre uses pyparsing to build the parser that tokenizes the search strings. While I haven't used lex/yacc at all, I do enjoying working with pyparsing.

http://onlamp.com/pub/a/python/2006/...pyparsing.html
kovidgoyal is offline  
Old 05-25-2010, 08:13 PM   #1991
TouchToneTommy
Junior Member
TouchToneTommy began at the beginning.
 
Posts: 4
Karma: 10
Join Date: May 2010
Device: none
Thanks for everyone's help!! Especially the link to recipe guide, that I did not find by Googling.

Here's what I came up with, a little tweaking of Starson17's original suggestion

Code:
    def print_version(self, url):
        segments = url.split('/')
        print_url = 'http://' + segments[2] + '/' + segments[3] + '/' + segments[4] + '/' + segments[5] + '/'  \
                + 'v-print/' + segments[6] + '/' + segments[7]
        return print_url
It was a matter of the segment numbers and an extra slash before 'v-print'

This is really exciting! And now I need to spend some time learning about Python, is there a "Python for Dummies"?

Thanks again!!!
TouchToneTommy is offline  
Old 05-25-2010, 08:51 PM   #1992
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 TouchToneTommy View Post
This is really exciting! And now I need to spend some time learning about Python, is there a "Python for Dummies"?
Try here.
Starson17 is offline  
Old 05-26-2010, 10:53 PM   #1993
bhandarisaurabh
Enthusiast
bhandarisaurabh began at the beginning.
 
Posts: 49
Karma: 10
Join Date: Aug 2009
Device: none
REQUEST FOR RECIPE

I WOULD LIKE TO REQUEST A RECIPE FOR
http://knowledge.wharton.upenn.edu/india/rss/
AND
http://knowledge.wharton.upenn.edu/rss/
bhandarisaurabh is offline  
Old 05-27-2010, 05:26 PM   #1994
notyou
Connoisseur
notyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheesenotyou can extract oil from cheese
 
Posts: 52
Karma: 1140
Join Date: Apr 2010
Device: Kindle / Palm Pre / iPhone
Hoping someone can help me with the Wired Magazine recipe, which the latest June 2010 issue seems to have broken.

Calibre is giving me the dreaded "AttributeError: 'NoneType' object has no attribute 'a'" error:

It's happening here:

File "c:\docume~1\darryl~1\locals~1\temp\calibre_0.6.54 _jujqqs_recipes\recipe0.py", line 79, in parse_index
url = 'http://www.wired.com' + divurl.a['href']

Looking at the source at http://www.wired.com/magazine I think the problem may be that Wired has added a new "Bonus Video" section which does not have a feature-header div, and so the URL cannot be parsed from there. Is there anyways to have Calibre skip feature sections that don't have headers?

Thanks!
notyou is offline  
Old 05-27-2010, 08:59 PM   #1995
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: 780
Karma: 194642
Join Date: Dec 2007
Location: Argentina
Device: Kindle PaperWhite, Motorola Xoom
I'll look into that this weekend if time permits
kiklop74 is offline  
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:19 PM.


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