|
|
#1 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 2354
Join Date: Nov 2010
Device: none
|
Problem with Article Date in parse_index
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
})
|
|
|
|
|
|
#2 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,489
Karma: 2944574
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.
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
Enthusiast
|
|
|
|
#3 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 2354
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. |
|
|
|
|
|
#4 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 2354
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... |
|
|
|
|
|
#5 |
|
Creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 22,489
Karma: 2944574
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.
__________________
Get calibre Notice to all: I can not provide assistance with DRM removal, for legal reasons, so please do not contact me about it. |
|
|
|
|
|
#6 |
|
Connoisseur
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 82
Karma: 2354
Join Date: Nov 2010
Device: none
|
Awesome - thanks for the heads-up on that. That'll help keep it clean...
|
|
|
|
![]() |
| Thread Tools | Search this Thread |
|
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 |