Comment.body_html is incomplete
from hn import Story
story = Story.fromid(7324236)
comments = story.get_comments()
print comments[0].body
print comments[0].body_html
Seems like .body_html only returns a portion of the comment body's HTML.
I can see why this is happening....each sub-comment is treated as a separate comment. so if u print comments[1].body_html u will get the first reply to comments[0].body_html. i will try to fix it unless Karan can fix it before me :)
You for it @ueg1990!
hey karan, i thin i fixed the problem. what i did was for each comment that had nested comments, i aded it to the current comment but still treated each comment as separate comments too. that is if comments[0] has comments[1] and comments[2] as nested comments, i concatenate the body and body_html of both comments[1] and comments[2] to comments[0], but comments[1] and comments[2] are still in the comments array. I know the explanation is confusing but i will add a pull request and u can have a look and let me know what you think. :)
The code makes sense and tests are passing. Good job! :)
just to confirm, do u want this functionality to only be for comments at level 0?? as in retrieve all the comments only for at level 0?
@ueg1990 I think it's better to have it for all to keep the API consistent.
as in u want all comments under level 1 to be concatenated to its body and so on for comments at other levels??
I'm not sure what you mean, but comments should be in JSON format, with a list of individual comments.
The next level of this, is to make nested dicts. So comments[0] means the first comment, comments[0][0] means the first reply of first comment etc. This is where the level field will be useful.
Also, make sure to update the README as the code evolves to keep it in sync with the features.
Ok, looks a bit tricky. will let you know if i need some help.
On Wed, Mar 19, 2014 at 4:00 PM, Karan Goel [email protected]:
I'm not sure what you mean, but comments should be in JSON format, with a list of individual comments.
The next level of this, is to make nested dicts. So comments[0] means the first comment, comments[0][0] means the first reply of first comment etc. This is where the level field will be useful.
Also, make sure to update the README as the code evolves to keep it in sync with the features.
Reply to this email directly or view it on GitHubhttps://github.com/karan/HackerNewsAPI/issues/30#issuecomment-38099632 .
USman