Page 1 of 1
Invalid json returned for mode=history
Posted: December 29th, 2012, 3:27 pm
by cltdba
Example api call for history json:
Code: Select all
http://localhost:8080/api?output=json&apikey=myApiKey&limit=15&mode=history
Excerpt of returned json where error lies:
Code: Select all
"show_details": "True",
"script_log": "| + Codec ID: A_DTS\nVariable values: \n -> (dl_path) [arg1] = /media/sabnzbd/post_process
When output is parsed through JSONLint it gives the following error. Other applications are reporting similar invalid character and/or parse errors.
Code: Select all
Parse error on line 9:
... "script_log": "| + Codec ID: A_DT
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
Example log from couchpotatoserver:
Code: Select all
12-29 15:12:51 INFO [0m[hpotato.core.plugins.base] Opening url: http://localhost:8080/api?output=json&apikey=xxx&limit=15&mode=history, params: [][0m
12-29 15:12:51 ERROR [31m[.core.downloaders.sabnzbd] Failed getting history json: Traceback (most recent call last):
File "/Applications/CouchPotatoServer/couchpotato/core/downloaders/sabnzbd/main.py", line 86, in getAllDownloadStatus
'limit': 15,
ValueError: Invalid control character at: line 1 column 116343 (char 116343)
Re: Invalid json returned for mode=history
Posted: December 30th, 2012, 7:22 am
by shypike
When you cut short all logging, it's a bit hard to tell what's going on.
Code: Select all
"show_details": "True",
"script_log": "| + Codec ID: A_DTS\nVariable values: \n -> (dl_path) [arg1] = /media/sabnzbd/post_process
Do you mean to tell that the end quote is missing?
Does the string continue on the next line, but is SABnzbd splitting lines incorrectly?
What is the real output?
Re: Invalid json returned for mode=history
Posted: December 30th, 2012, 11:09 am
by cltdba
Where can I send you the full json output? It appears it is complaining about the colon just after show details.
Re: Invalid json returned for mode=history
Posted: December 30th, 2012, 2:57 pm
by shypike
[email protected]
(Please add the URL of this post.)
Re: Invalid json returned for mode=history
Posted: January 20th, 2013, 5:43 pm
by GijsW
Seems I have a simlar issue:
Code: Select all
01-20 23:54:47 INFO [hpotato.core.plugins.base] Opening url: http://localhost:8080/api?output=json&apikey=xxx&limit=15&mode=history, params: []01-20 23:54:48 ERROR [tato.core.plugins.renamer] Failed checking for release in downloader: Traceback (most recent call last):
File "/volume1/@appstore/couchpotatoserver/share/CouchPotatoServer/couchpotato/core/plugins/renamer/main.py", line 563, in checkSnatched
nzbname = self.createNzbName(rel_dict['info'], movie_dict)
File "/volume1/@appstore/couchpotatoserver/share/CouchPotatoServer/couchpotato/core/plugins/base.py", line 260, in createNzbName
return '%s%s' % (toSafeString(data.get('name')[:127 - len(tag)]), tag)
TypeError: 'int' object has no attribute '__getitem__'
Re: Invalid json returned for mode=history
Posted: January 20th, 2013, 7:03 pm
by cltdba
Finally remembered to send you the json.
Re: Invalid json returned for mode=history
Posted: January 21st, 2013, 4:22 am
by shypike
cltdba and GijsW.
Both your examples validate fine in
http://jsonlint.com/
I also tried
http://json.parser.online.fr but I don't see any error messages there either.
Maybe they're there, but I don't see them.
Re: Invalid json returned for mode=history
Posted: January 21st, 2013, 12:51 pm
by cltdba
I'm not sure what you're doing differently than me? I paste the entire contents into jsonlint and upload the file to json parser. I know little to nothing about json so I could be doing this all wrong.
Code: Select all
Parse error on line 71:
... "script_log": "Loading config from
-----------------------^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '['
Json Parser Online complains of a missing comma in the string below. It also gives an eval error of: SyntaxError: JSON Parse error: Expected ']'
Code: Select all
./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"
All 15 reported parse errors are variations of the below block.
Code: Select all
{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href="./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"
]
}
It looks like the issues is because of the double quote starting at href=. If you remove them, it no longers lends a parse error. If you escape them with "\" it also parses. This particular example is output from the sabToSickBeard.py post processing script. Perhaps the fix is to replace all occurrences of double quotes with a backslash followed by double quote.
This parses:
Code: Select all
{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href=./scriptlog?name=SABnzbd_nzo_GSGha4>(More)</a>"
]
}
So does this:
Code: Select all
{
"name":"Script",
"actions":[
"Processing succeeded for /media/sabnzbd/post_process/American.Horror.Story.S02E09.720p.WEB-DL.DD5.1.H.264-ECI/American.Horror.Story.S02E09.The.Coat... <a href=\"./scriptlog?name=SABnzbd_nzo_GSGha4\">(More)</a>"
]
}
Re: Invalid json returned for mode=history
Posted: January 21st, 2013, 1:17 pm
by cltdba
This "error" is annoying.. When I copy and paste into
http://json.parser.online.fr, it parses just fine........ back to the proverbial drawing board..
Re: Invalid json returned for mode=history
Posted: January 21st, 2013, 3:05 pm
by shypike
This fragment is handled correctly:
Code: Select all
./scriptlog?name=SABnzbd_nzo_GSGha4">(More)</a>"
In the JSON file that you sent me, the actual data is:
Code: Select all
./scriptlog?name=SABnzbd_nzo_GSGha4\">(More)</a>"
Notice the backslash before the embedded quote?
Isn't what you show in your post just the rendering of the pretty-printer you are using?
Re: Invalid json returned for mode=history
Posted: January 21st, 2013, 10:54 pm
by cltdba
Yep, you're correct. I noticed the same after I pasted the log contents into the json parser instead of uploading it. None of the current CP logs are producing the error. If it pops up again I'll grab fresh logs and json.