08-27-2012, 08:42 AM | #1 |
Enthusiast
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'] Code:
from urlib import quote self.cover_url = quote(cover['src'], safe="%/:=&?~#+!$,;'@()*[]") |
08-27-2012, 11:33 AM | #2 |
creator of calibre
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.
|
Advert | |
|
08-27-2012, 03:44 PM | #3 |
Member
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 |
08-27-2012, 03:49 PM | #4 |
creator of calibre
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. |
08-27-2012, 04:32 PM | #5 |
Member
Posts: 10
Karma: 10
Join Date: Aug 2012
Device: android
|
Yes, you are right I expected a simple string as the input
|
Advert | |
|
Thread Tools | Search this Thread |
|
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 |