7sDream / torrent_parser

A .torrent file parser and creator for both Python 2 and 3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

torrent_parser does not return "Info Hash v1" value

kkuriyama opened this issue · comments

Is this a oversight? I need to get the hash of the torrent so that I can detect duplicate torrents. 'transmission-show' displays the hash value of a torrent but not torrent_parser. Thanks.

Please provide a torrent file that make you have this issue, for testing purposes.

And the mean of "info Hash v1" is not clear, some screenshot or log of transmission-show maybe helpful.

This is the output of transmission-show, The "Hash" value is also referred to as "Info Hash v1" on qbittorrent. It is the "Hash" value that I am trying to get from pytp.

Name: xubuntu-22.04-desktop-amd64.iso
File: xubuntu-22.04-desktop-amd64.iso.torrent

GENERAL

  Name: xubuntu-22.04-desktop-amd64.iso
  Hash: f435d2324f313bad7ff941633320fe4d1c9c3079
  Created by: mktorrent 1.1
  Created on: Thu Apr 21 04:02:51 2022
  Comment: Xubuntu CD cdimage.ubuntu.com
  Piece Count: 10306
  Piece Size: 256.0 KiB
  Total Size: 2.70 GB
  Privacy: Public torrent

TRACKERS

  Tier #1
  https://torrent.ubuntu.com/announce

FILES

  xubuntu-22.04-desktop-amd64.iso (2.70 GB)

This is a snippet of the pytp output as the original is ~400KB.

{"announce": "https://torrent.ubuntu.com/announce", "comment": "Xubuntu CD cdima
ge.ubuntu.com", "created by": "mktorrent 1.1", "creation date": 1650549771, "inf
o": {"length": 2701512704, "name": "xubuntu-22.04-desktop-amd64.iso", "piece len
gth": 262144, "pieces": ["8cadae7758f70a8ea1436eeb0f5652a98490b403", "0b303e6617
e84c37edbe52d7a82e5a7533bfcdce", "6b239e36ba8a4301f36383613ecb064e489b9990", "36
bf90f9dce84508628fb4aab9dd5ca7abe950d8", "24a44ee3ea3ca316ef5e9323e3fce4045e7d1f
84", "5e621209bef519529508d24ad5fddf549a32422c", "d641c2d4e07713490747f22fb76aea
206e319c03", "42101ebbb4feaa44b6ff24c63942f770d0510136", "49e648f3bf657adb65c6fd
38ecf870f5118af104", "6077160ac9752477d702c38a125b2d1684da85da", "2002f583676a15
dfd2232dd1fc48c6013a26f080", "286ce9b025c646badf3d8264617d1b5343702458", "772268
df32e9078d1ba9fe38ebb2823ec1b64b49", "74a91f948242eafa56380ec85b6ab5b66ed44d21"

The link to the torrent file is: https://torrent.ubuntu.com/xubuntu/releases/jammy/release/desktop/xubuntu-22.04-desktop-amd64.iso.torrent

Thank you for your assistance.

I did some digging in tramsmission source code, and found info hash is actually a SHA1 checksum of torrent file's info object binary bytes.

This value is not stored in files itself, but be caluclated during parse process, so current this project do not show it.

The only way I can see is after parse the file, we encode the info object into binary bytes again and calulate the hash, It (in theory) will be the same value as transmission-show shows.

图片

Just write a test using the file you provide, it's the same in this case.

PS: hash_raw=True must be provided to (try my best to) ensure result of encoding is as same as origin data.

Thank you. I'll use transmission-show for now.

That's OK, this project is basicly a torrent format encoder/decoder, use transmission-show is more reasonable if you want features more than that.

But I think we can build our own transmission-show like tools above this project, the only obstacle is that I don't have enough time. 😭