add `encode` function to convert an object into a magnet uri