.addMagnet torrent and then get its hash
blackwater17 opened this issue · 6 comments
Is it possible to getting the hash of a magnet torrent after its just added?
normalizedAddTorrent will do it, addMagnet only returns what qbittorrent api gives back, a mostly useless boolean.
You might also get the hash yourself, see how its done here
qbittorrent/src/qbittorrent.ts
Line 599 in 10e9a79
Thanks. Does normalizedAddTorrent work with magnet urls too? If so, I couldn't get it to work. It throws an error and says "Error: not a number: buffer['0'] = 104"
Could it be because my input is actually not a magnet file? Because what I'm using as parameter is actually just a "download URL" for the torrent file. Does this count as magnet? When I use addMagnet function with this url it works btw.
And for the second method does it work with this url? Once again I tried it but it throw an error.
You're probably adding by url then. I'm not sure how you would get the hash except by comparing the current set of torrents with the new set of torrents after adding the torrent. Another solution might be to download the torrent file in your code and pass that to add normalized torrent.
Comparing the torrents and getting the hash is what I currently do. But sometimes it just doesn't work
and loads the wrong torrent for some reason. And its not best the best solution either. I could also download the torrent file and add it by file, but this would also make things more complicated. So are you confirming that this method is not supposed to work anyway?
I call it like this:
const result = await client.normalizedAddTorrent("https://....blablabla.torrent", { savepath: savepath, sequentialDownload:"True", paused:"False" }) // throws the error I shared above.
But the below code just works, and returns true.
const result = await client.addMagnet("https://....blablabla.torrent", { savepath: savepath, sequentialDownload:"True", paused:"False" })
yeah add magnet is using the same api as add by url. normalizedAddTorrent can't support urls since there isn't a way to return the hash. maybe it should throw an error.