Archived

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

dabear

add tags?

Recommended Posts

Hi, I'm currently adding torrents by requesting the following url:

"http://host:port/gui/?action=add-url&s=url"

But I cannot seem to find out how I can add a tag to the torrent file? The docs I found on this site doesn't mention it, either.

Ideas? :)

Share this post


Link to post
Share on other sites

thanks, so there isn't a way to set the label initially when adding the torrent?

I only know the name of the torrent file, but not the TORRENT HASH, so it seems kinda difficult to add that label.

I noticed that /gui/?list=1 lists all the torrent names though. Those names doesn't necessarily match the torrent names, so I'm back to start.

Share this post


Link to post
Share on other sites

idd, adding a torrent and changing the label cannot be combined in a single command.

Sadly you have to get the hash either through ?list=1 or by downloading and inspecting the .torrent with a bencode editor/viewer.

Share this post


Link to post
Share on other sites

The .torrent file doesn't actually contain the infohash -- it's calculated by taking the SHA1 hash of the info dictionary in the .torrent file.

I'm not really sure what you mean by "Those names doesn't necessarily match the torrent names."

Share this post


Link to post
Share on other sites

If the filename and the name in the .torrent info differs then you won't be able to match directly with ?list=1 no.

What should work then is inspecting the .torrent file and look for the name field. That should match the name in ?list=1. (If you can't find that name in ?list=1 then the adding of the torrent failed or you added a torrent that already exists.)

But if you are inspecting the .torrent I'm sure you can also create a hash over the info dictionary in it.

afaik there is no javascript beencode parser atm. You could try writing one using others as an example.

In any case whatever you are trying to do this is gonna take you time and effort :P

Share this post


Link to post
Share on other sites

If he's doing everything from browser Javascript, no BEncode parser is going to help, as plain ol' browser Javascript can't read local files anyway. What would probably be more helpful is if µTorrent returned some basic info regarding the torrent (infohash, name, size, etc.) as a response to it being sent to the backend (either via add-url, or add-file). The only problem is that random delays (latency, .torrent file download time, parsing time, etc.) may cause problems with this idea.

Share this post


Link to post
Share on other sites

Doesn't add-file already wait for a response? I remember that it returns a error JSON object if adding the torrent didn't work (although only if the torrent already exists I think).

Anyways I agree with expanding the use of the JSON error object by the webui core and maybe implement showing those errors in the logger tab of the webui.zip.

Share this post


Link to post
Share on other sites

Nope, it doesn't wait. I get {"build":12639} immediately after sending a URL, even though the torrent hasn't yet appeared in the list (sometimes taking something like 5-10 seconds before it appears in the list because the server is slow).

Share this post


Link to post
Share on other sites
If he's doing everything from browser Javascript, no BEncode parser is going to help, as plain ol' browser Javascript can't read local files anyway.

I thought about comparing the .torrent-file directly from the tracker and finding the hash that way. As I said previously - that would require a bencode parser and also a sha1sum implementation in js :/

This particular functionality isn't essential, but it would be nice to be able to add a default label to the torrents downloaded.

Nope, it doesn't wait. I get {"build":12639} immediately after sending a URL, even though the torrent hasn't yet appeared in the list (sometimes taking something like 5-10 seconds before it appears in the list because the server is slow).

I noticed that too, is there any way to find out if the torrent was successfully added?

edit: this is for a greasemonkey user script, btw, so I have full access to the contents of the .torrent file located on the tracker :)

Share this post


Link to post
Share on other sites