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 11-25-2012, 05:43 PM   #1
anthonyliu
Junior Member
anthonyliu began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Oct 2012
Device: Kindle
Error when adding date to titles in recipes

Hi! I am a complete newbie, so please bear with me if I am making any silly mistakes.

I am trying to customize the built-in recipes by adding the date to the title. By following the instructions in the Calibre manual, I added "import time" and put " + time.strftime('%d %b %Y')" in the title line (these are the only changes I made to the recipe).

So the recipe looks something like this:
Code:
#!/usr/bin/env  python

__license__   = 'GPL v3'
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
'''
economist.com
'''
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ebooks.BeautifulSoup import Tag, NavigableString
from collections import OrderedDict

import time, re

class Economist(BasicNewsRecipe):

    title = 'The Economist' + time.strftime('%d %b %Y')
But when I hit the Add/Update Recipe botton, I got the following error message:
Quote:
calibre, version 0.9.7
ERROR: Unhandled exception: <b>UnicodeDecodeError</b>:'utf8' codec can't decode byte 0xd4 in position 20: invalid continuation byte

Traceback (most recent call last):
File "site-packages\calibre\gui2\dialogs\user_profiles.py", line 268, in add_profile
File "site-packages\calibre\gui2\dialogs\user_profiles.py", line 64, in add
File "site-packages\calibre\web\feeds\recipes\model.py", line 175, in add_custom_recipe
File "site-packages\calibre\web\feeds\recipes\collection.py", line 155, in add_custom_recipe
File "site-packages\calibre\utils\config.py", line 388, in __setitem__
File "site-packages\calibre\utils\config.py", line 333, in commit
File "site-packages\calibre\utils\config.py", line 372, in to_raw
File "json\__init__.py", line 238, in dumps
File "json\encoder.py", line 203, in encode
File "json\encoder.py", line 428, in _iterencode
File "json\encoder.py", line 402, in _iterencode_dict
File "json\encoder.py", line 307, in _iterencode_list
UnicodeDecodeError: 'utf8' codec can't decode byte 0xd4 in position 20: invalid continuation byte
I've been having this problem for months, and all your input and assistance will be very appreciated! Thank you!
anthonyliu is offline   Reply With Quote
Old 11-25-2012, 10:11 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: 26,437
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Use

from calibre import strftime

rather than time.strftime
kovidgoyal is offline   Reply With Quote
 
Advertisement
Old 11-25-2012, 11:07 PM   #3
anthonyliu
Junior Member
anthonyliu began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Oct 2012
Device: Kindle
It is working now. Thank you!

Quote:
Originally Posted by kovidgoyal View Post
Use

from calibre import strftime

rather than time.strftime
anthonyliu is offline   Reply With Quote
Old 01-01-2013, 10:09 AM   #4
jeromedevine
Zealot
jeromedevine doesn't litterjeromedevine doesn't litterjeromedevine doesn't litter
 
Posts: 108
Karma: 240
Join Date: Sep 2009
Device: Kindle 3 3G Graphite, Sony PRS-505
Hi, can you tell me what I am doing wrong in the below script? I believe I followed the explanations above. I am trying to make the title show as follows: The Economist - 2012 Dec 22. In the recipe I changed only the below line:


title = 'The Economist - ' + from calibre import strftime('%Y %b %d')
jeromedevine is offline   Reply With Quote
Old 01-01-2013, 10:16 AM   #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: 26,437
Karma: 5383257
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You need

title = 'The Economist' + time.strftime('%d %b %Y')
kovidgoyal is offline   Reply With Quote
Old 01-01-2013, 01:54 PM   #6
jeromedevine
Zealot
jeromedevine doesn't litterjeromedevine doesn't litterjeromedevine doesn't litter
 
Posts: 108
Karma: 240
Join Date: Sep 2009
Device: Kindle 3 3G Graphite, Sony PRS-505
Kovid, you are the BOSS!!! Great work, and now this is awesome!

Thanks a lot and Happy New Year!!!
jeromedevine 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
Adding Apostrophes in Recipes Steven630 Recipes 2 07-30-2012 06:53 AM
Import OS modify date while Adding books? unboggling Calibre 4 12-07-2011 01:09 PM
Changing article titles in recipes tbaac Recipes 8 12-22-2010 01:03 PM
Date in Calibre? Adding books in the future? wygit Calibre 2 11-04-2009 12:12 PM
Bug with the date in subscription titles copernicc Calibre 4 03-05-2009 02:22 PM


All times are GMT -4. The time now is 10:57 AM.


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