Giter Site home page Giter Site logo

v2 Torrent supported? about torrent_parser HOT 8 CLOSED

7sdream avatar 7sdream commented on July 2, 2024
v2 Torrent supported?

from torrent_parser.

Comments (8)

7sDream avatar 7sDream commented on July 2, 2024

Could you try way 2 in this comment and check if it works?

with argument: hash_fields={"pieces root": (32, False)}

from torrent_parser.

daomengRen avatar daomengRen commented on July 2, 2024

I try data = tp.parse_torrent_file(str, hash_fields={"pieces root": (32, False)}), Getting “torrent_parser.InvalidTorrentDataException: Fail to decode string at pos 1359 using encoding utf-8”

from torrent_parser.

7sDream avatar 7sDream commented on July 2, 2024

It seems this v2 file has a piece layers dict whose key and value are all hash bytes.

Current hash_fields argument can't specify entrie dict.

For now, if you don't care about piece layers values, you can add errors="replace" to make parse success:

data = tp.parse_torrent_file(
    "bittorrent-v2-test.torrent",
    hash_fields={
        "pieces root": (32, False),
    },
    errors="replace",
)

But if you edit data and write back to file, the content of piece layers will be incorrect.

I will publish a new version to solve this issue.

from torrent_parser.

daomengRen avatar daomengRen commented on July 2, 2024

Looking forward to new version,If I only edit the content except the piece layers, will I get an error when writing to the file?

from torrent_parser.

7sDream avatar 7sDream commented on July 2, 2024

No error will be raise if you write back to file, it is the file content is incorrect.

Because error="replace" argument of parse step replaced invalid utf8 bytes in piece layers with Unicode Replacement Character. In encode/write step, we can't restore origin bytes.

from torrent_parser.

7sDream avatar 7sDream commented on July 2, 2024

v0.4.0 just published.

Please try it with tp.parse_torrent_file("bittorrent-v2-test.torrent") without any other argument. In theory you should be able to successfully parse the file.

Feel free to continue this thread if you meet any issue when using the new version.

from torrent_parser.

daomengRen avatar daomengRen commented on July 2, 2024

It's working fine, thank you

from torrent_parser.

7sDream avatar 7sDream commented on July 2, 2024

That's fine, then I'll close the issue.

If there are any subsequent issue, you can open a new one.

from torrent_parser.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.