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 01-23-2011, 09:42 AM   #1
spedinfargo
Groupie
spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.
 
Posts: 155
Karma: 106422
Join Date: Nov 2010
Device: none
Problem with Article Date in parse_index

I'm having an issue trying to override the default date/time that gets put in the article. The strange thing is that it seems to work fine in one of my recipes but can't get it to "take" in the other recipe.

When I do a self.log on the result of my regular expression, everything looks fine. But when the EPUB file gets created, it defaults to the date that would get generated if I had passed in a blank string to the article dictionary: [Sun, 23 Jan 08:36]

I should be able to use any string that I want for the date, correct? Or is there something in the EPUB generation that tries to detect a valid date or something?

Any help appreciated...

Here is my code:

Code:
                    pattern2 = r'AID=\/(.*?)\/'
                    reg2 = re.compile(pattern2, re.IGNORECASE|re.DOTALL)
                    match2 = reg2.search(thisurl)
                    if match2:
                        c = time.strptime(match2.group(1),"%Y%m%d")
                        mydate=time.strftime("%a, %b %d, %Y", c)
                    else:
                        mydate = time.strftime("%a, %b %d, %Y")
                    self.log(mydate)
                    
                    articles.append({
                                      'title'      :thistitle
                                     ,'date'       :' {' + mydate + '}'
                                     ,'url'        :thisurl
                                     ,'description':description
                                    })
spedinfargo is offline   Reply With Quote
Old 01-23-2011, 12:05 PM   #2
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,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
That date is used only in the section index of links pointing to articles, not in the article itself.
kovidgoyal is offline   Reply With Quote
Advert
Old 01-23-2011, 08:17 PM   #3
spedinfargo
Groupie
spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.
 
Posts: 155
Karma: 106422
Join Date: Nov 2010
Device: none
Thanks for the quick response (as always, of course).

I should have been more clear in my question - it is the TOC that I'm talking about where the date doesn't seem to be working. No matter what I end up passing in, all the links in the TOC have the current datetime instead of what I send in.

I'll keep playing around with it - it's not a big deal... the rest of the recipe seems to be working fine.
spedinfargo is offline   Reply With Quote
Old 02-19-2011, 07:01 PM   #4
spedinfargo
Groupie
spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.
 
Posts: 155
Karma: 106422
Join Date: Nov 2010
Device: none
Yay! I finally found what was going on here.

After getting the string formatted just like I wanted:

mydate=time.strftime("%a, %b %d, %Y", c)

I had to somehow convert it to a unicode string before adding it as an article. So instead of this:

'date' :' {' + mydate + '}'

I needed this:

'date' :u' {' + mydate + '}'

All good now...
spedinfargo is offline   Reply With Quote
Old 02-19-2011, 07:09 PM   #5
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,850
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Rather than using time.strftime, instead use

from calibre import strftime

strftime(...)

this will always return unicode strings.
kovidgoyal is offline   Reply With Quote
Advert
Old 02-19-2011, 07:12 PM   #6
spedinfargo
Groupie
spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.spedinfargo is the king of the Divan.
 
Posts: 155
Karma: 106422
Join Date: Nov 2010
Device: none
Awesome - thanks for the heads-up on that. That'll help keep it clean...
spedinfargo is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Problem deppeler Calibre 3 01-11-2011 11:44 PM
Bulk Changing Published Date To Date hmf Calibre 4 10-19-2010 10:19 PM
Article Dates with parse_index EnergyLens Calibre 6 04-21-2010 10:13 PM
Omitting description an author in parse_index nickredding Calibre 0 12-31-2009 04:19 PM
Problem with date resetting nathantw Sony Reader 5 02-01-2008 02:57 PM


All times are GMT -4. The time now is 01:54 PM.


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