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

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

Notices

Reply
 
Thread Tools Search this Thread
Old 08-27-2012, 08:42 AM   #1
forceps
Enthusiast
forceps doesn't litterforceps doesn't litter
 
Posts: 26
Karma: 168
Join Date: May 2005
Location: Wuhan, China
Device: Kindle DXG
recipe problem with space in cover url

the ebook-convert fail to retrive a cover image because there is a space in the url:
"http://cdn.theatlantic.com/static/newsroom/img/2012/08/20/0912 Cover_210x280/mag-issue-large.jpg?m92if7"
so far this problem can be bypassed by modify the cover url in recipe, for example,
change
Code:
self.cover_url = cover['src']
to
Code:
from urlib import quote
self.cover_url = quote(cover['src'], safe="%/:=&?~#+!$,;'@()*[]")
would it be better to fix this in ebook-convert itself?
forceps is offline   Reply With Quote
Old 08-27-2012, 11:33 AM   #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,835
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
It cannot be "fixed" because there is no way to know what the set of safe characters are for any given URL/server combination.
kovidgoyal is offline   Reply With Quote
Advert
Old 08-27-2012, 03:44 PM   #3
renszarv
Member
renszarv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2012
Device: android
no, the URL/percent encoding pretty universal: http://en.wikipedia.org/wiki/Percent-encoding
I think if you do this :
urllib.encode(strObj.encode("utf-8"))
you will get URL part
renszarv is offline   Reply With Quote
Old 08-27-2012, 03:49 PM   #4
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,835
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
That assumes that strobj is not already encoded and that all characters in the string are encode safe. For example, if you did what you suggest on the the OPs URL you will get an invalid result because the ? will be quoted.

URL quoting is well defined, the status of the string that you are trying to quote and the level of quoting that the server that you are trying to connect to requires are not.

Last edited by kovidgoyal; 08-27-2012 at 03:56 PM.
kovidgoyal is offline   Reply With Quote
Old 08-27-2012, 04:32 PM   #5
renszarv
Member
renszarv began at the beginning.
 
Posts: 10
Karma: 10
Join Date: Aug 2012
Device: android
Yes, you are right I expected a simple string as the input
renszarv is offline   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Lost trying to get url for time.com cover Olger Recipes 3 02-14-2012 09:04 AM
HTML Meta tag for cover image URL? MrPLD Conversion 5 01-29-2012 12:15 AM
Los Tiempos, Bolivia cover URL pietvo Recipes 1 10-18-2011 02:20 PM
Simple download from rss url recipe BloodOmen Recipes 0 02-16-2011 09:21 PM
Space.com recipe - text is invisible! Tridens92 Recipes 2 01-31-2011 10:55 AM


All times are GMT -4. The time now is 12:26 AM.


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