ITADN

Support reading bytes in `Torrent.read_stream`

#48ClosedRavencentric 创建于 2024-10-10
R
Ravencentriccommented
Currently `Torrent.read_stream` only accepts a file-like object but there are cases when you have the bytes from an external source and this currently requires wrapping said bytes in BytesIO. My use case is something along the lines of: ```py import requests from torf import Torrent resp = requests.get("https://example.org/example.torrent") torrent = Torrent.read_stream(resp.content) print(torrent.name) ``` This is currently not possible. The current work around for this is: ```py import io import requests from torf import Torrent resp = requests.get("https://example.org/example.torrent") torrent = Torrent.read_stream(io.BytesIO(resp.content)) print(torrent.name) ```
关闭于 2024-10-18 0 条评论