tflink / python-yourls

Simple Python client for the YOURLS URL shortener
http://tflink.github.com/python-yourls
GNU General Public License v2.0
13 stars 12 forks source link

Apostrophe in page title causes error #4

Closed RazerM closed 1 year ago

RazerM commented 10 years ago

I tried to shorten a URL with an apostrophe in the page's default title (i.e. the title parameter was not manually set, although this also causes the below error)

For example, shortening this URL causes the error because of the apostrophe in the title: http://www.bbc.co.uk/news/uk-25482736

{ "url": { "keyword": "0qn-7", "url": "http://www.bbc.co.uk/news/uk-25482736", "title": "BBC News - Abbas Khan death: British doctor\'s body to be flown to UK", "date": "2013-12-22 02:37:49", "ip": "REDACTED" }, "status": "success", "message": "http://www.bbc.co.uk/news/uk-25482736 added to database", "title": "BBC News - Abbas Khan death: British doctor\'s body to be flown to UK", "shorturl": "REDACTED/0qn-7", "statusCode": 200 }
Traceback (most recent call last):
  File "URLShortener.py", line 22, in <module>
    shorturl = client.shorten(longurl, keyword=keyw, title=title)
  File "build/bdist.macosx-10.8-x86_64/egg/yourls/client.py", line 136, in shorturl
  File "build/bdist.macosx-10.8-x86_64/egg/yourls/client.py", line 104, in _base_request
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/decoder.py", line 382, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Invalid \escape: line 1 column 133 (char 132)
tflink commented 1 year ago

I'm archiving the project, closing the issue.

Also, thank you for picking up the client where I dropped it. I've linked to your newer, working fork in the README before I archive the project