Jump to content

Could we have a version of multiple-hash getfiles that is legal json


jobermark

Recommended Posts

I just started using this interface. My husband tends to start downloads of large multi-file torrents of video clips and then pick out files as the complete. I was automating this, and used getfiles with multiple hash keys (the keys for all of these half-completed leviathan torrents).

It is cool that you accept multiple values of the hash function, for folks that want all of that info, but don't want to spend the time on round trips.

But many json parsing tools misinterpret the result, because there are multiple copies of the same key in the dictionary. Obviously, for my little experiment, I can write crap code. What is there is easy to fix, I just find the key "files": in the string before parsing, and wedge in just enough packing to make the result legal.

But on general principals, if you claim to return JSON, the result should be valid, and a straight eval in JavaScript or Python should net the intended result. So, on whatever wish list you keep, can we have a copy that is a list, instead of a dictionary with multiple copies of the same key? Maybe only populated when there are multiple hash values?

This seems like the kind of thing that is there almost by accident, and that may not warrant full support. But then other folks should note the bug before they get confused by it.

Link to comment
Share on other sites

Thanks for the report/request. You're correct, the current behavior is a bit crazy. It would make more sense to return a JSON response containing dict of infohash => [dict of file metadata] keys, with the number of entries corresponding to the number of passed-in infohashes. That's a consistent response format no matter how many infohashes are supplied, and it solves the keys-overwriting-each-other issue.

We have a long list of improvements we'd like to make to the WebAPI, and are working on making improvements and releasing them back to the community without breaking compatibility.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...