Fix adding duplicate torrent in Deluge

This fixes https://github.com/RuudBurger/CouchPotatoServer/issues/2440.

Hash generation from magnet and file was taken from utorrent downloader, in the event this is not the way it should be done.