question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing trackers in announce-list corrupts save

See original GitHub issue

Hi,

First thanks for taking the time to write this.

#

I’m trying to strip out existing (dead) trackers from torrent files and replace them with known good ones. But, changing trackers in the announce-list results in a corrupted (non-working) announce-list. [You can change the “announce” tracker successfully.]

For testing I’ve been using the MX-19.2_x64.iso torrent file. It seems to be no longer available, but similar files are at https://mxlinux.org/torrent-files/ .

Output testing is by loading into qBittorrent v4.2.3 and checking the “Trackers” tab. All tests fail by not loading the changed “announce-list” tracker to the Tracker List in qBittorrent.

See toradd.py code at bottom. I’ve used “pytp” to visualize the outputed torrent files.

Request:

Have the code,

tracker_03a        = 'http://tracker.opentrackr.org:1337/announce'
data['announce-list'][0] = tracker_03a

correctly replace the tracker so that it loads successfully into qBittorrent.

Control pass:

Changes: Straight read, no changes, and a write to separate file.

Results: All trackers show up in qBittorrent

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/data/Downloads/isos/torrentfiles/MX-19.2_x64.iso.torrent' -d -i 2 > /home/michael/trash/torout.txt
michael@local [~/trash]# head torout.txt
{
  "announce": "http://l2.mxrepo.com:6969/announce",
  "announce-list": [
    [
      "http://l2.mxrepo.com:6969/announce"
    ],
    [
      "http://it.mxrepo.com:6969/announce"
    ]
  ],

Test 01-a:

Changes:

data['announce-list'][0] = tracker_03a
#data['announce-list'][1] = tracker_01

Results: Loads only tracker http://it.mxrepo.com:6969/announce

Output

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/trash/test.torrent' -d -i 2 > /home/michael/trash/torout2.txt
michael@local [~/trash]# head torout2.txt
{
  "announce": "http://tracker.opentrackr.org:1337/announce",
  "announce-list": [
    "http://tracker.opentrackr.org:1337/announce",
    [
      "http://it.mxrepo.com:6969/announce"
    ]
  ],
  "created by": "mktorrent 1.0",
  "creation date": 1591050075,

Test 01-b:

Changes:

data['announce-list'][0] = tracker_03a
data['announce-list'][1] = tracker_01

Results: Loads only tracker http://tracker.opentrackr.org:1337/announce

Output

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/trash/test.torrent' -d -i 2 > /home/michael/trash/torout2.txt
michael@local [~/trash]# head torout2.txt
{
  "announce": "http://tracker.opentrackr.org:1337/announce",
  "announce-list": [
    "http://tracker.opentrackr.org:1337/announce",
    "http://tracker.dler.org:6969/announce"
  ],
  "created by": "mktorrent 1.0",
  "creation date": 1591050075,
  "info": {
    "length": 1609564160,

Test 02:

Changes:

data['announce-list'][0] = tracker_03b
data['announce-list'][1] = tracker_01

Results: Loads only tracker http://tracker.opentrackr.org:1337/announce

Output

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/trash/test.torrent' -d -i 2 > /home/michael/trash/torout2.txt
michael@local [~/trash]# head torout2.txt
{
  "announce": "http://tracker.opentrackr.org:1337/announce",
  "announce-list": [
    "[\"http://tracker.opentrackr.org:1337/announce\"]",
    "http://tracker.dler.org:6969/announce"
  ],
  "created by": "mktorrent 1.0",
  "creation date": 1591050075,
  "info": {
    "length": 1609564160,

Test 03:

Changes:

data['announce-list'][0] = tracker_03c
data['announce-list'][1] = tracker_01

Results: Loads only tracker http://tracker.opentrackr.org:1337/announce

Output

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/trash/test.torrent' -d -i 2 > /home/michael/trash/torout2.txt
michael@local [~/trash]# head torout2.txt
{
  "announce": "http://tracker.opentrackr.org:1337/announce",
  "announce-list": [
    "[http://tracker.opentrackr.org:1337/announce]",
    "http://tracker.dler.org:6969/announce"
  ],
  "created by": "mktorrent 1.0",
  "creation date": 1591050075,
  "info": {
    "length": 1609564160,

Test 04:

Changes:

data['announce-list'][0] = tracker_03d
data['announce-list'][1] = tracker_01

Results: Loads only tracker http://tracker.opentrackr.org:1337/announce

Output

michael@local [~/trash]# toradd.py arg1 arg2
michael@local [~/trash]# ./pytp '/home/michael/trash/test.torrent' -d -i 2 > /home/michael/trash/torout2.txt
michael@local [~/trash]# head torout2.txt
{
  "announce": "http://tracker.opentrackr.org:1337/announce",
  "announce-list": [
    "['http://tracker.opentrackr.org:1337/announce']",
    "http://tracker.dler.org:6969/announce"
  ],
  "created by": "mktorrent 1.0",
  "creation date": 1591050075,
  "info": {
    "length": 1609564160,

Program used

I was in the middle of passing trackers into the program, so ignore the other testing junk…

michael@local [~/common/bin]# cat toradd.py
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
import torrent_parser as tp

if  len(sys.argv) > 2:  # Need 2 arguments
  print(True)
else:
  print(False)
  sys.exit(43)

print ('Number of arguments:', len(sys.argv), 'arguments.')
print ('Argument List:', str(sys.argv))

tor_file_in       = '/home/michael/data/Downloads/isos/torrentfiles/MX-19.2_x64.iso.torrent'
tor_file_out      = '/home/michael/trash/test.torrent'
tracker_00        = "http://tracker.opentrackr.org:1337/announce"
tracker_01        = "http://tracker.dler.org:6969/announce"
tracker_02        = ''
tracker_03a        = 'http://tracker.opentrackr.org:1337/announce'
tracker_03b        = '["http://tracker.opentrackr.org:1337/announce"]'
tracker_03c        = '[http://tracker.opentrackr.org:1337/announce]'
tracker_03d        = "['http://tracker.opentrackr.org:1337/announce']"

data = tp.parse_torrent_file(tor_file_in)
print(data['announce'])
print(data['info']['name'])
print(data['announce-list'][0])
print(data['announce-list'][1])

data['announce'] = tracker_00
data['announce-list'][0] = tracker_03c
data['announce-list'][1] = tracker_01

print(data['announce'])
tp.create_torrent_file(tor_file_out, data)

sys.exit(0)

General output of toradd.py

It’s repetitive so I stripped it out of the above to reduce clutter…

michael@local [~/trash]# toradd.py arg1 arg2
True
Number of arguments: 3 arguments.
Argument List: ['/home/michael/common/bin/toradd.py', 'arg1', 'arg2']
http://l2.mxrepo.com:6969/announce
MX-19.2_x64.iso
['http://l2.mxrepo.com:6969/announce']
['http://it.mxrepo.com:6969/announce']
http://tracker.opentrackr.org:1337/announce

Edit: Header bits for the input and output .torrent files

MX-19.2_x64.iso.torrent

d8:announce34:http://l2.mxrepo.com:6969/announce13:announce-listll34:http://l2.mxrepo.com:6969/announceel34:http://it.mxrepo.com:6969/announceee10:created by13:mktorrent 1.013:creation

test.torrent

d8:announce43:http://tracker.opentrackr.org:1337/announce13:announce-listl47:['http://tracker.opentrackr.org:1337/announce']37:http://tracker.dler.org:6969/announcee10:created by13:mktorrent 1.013:creation 

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Michael-IDAcommented, Feb 15, 2022

Due to Torrent file spec, type of announce-list field should be List<List<Tracker>>.

So, please try

tracker_00 = 'http://tracker.opentrackr.org:1337/announce'
tracker_01 = ['http://tracker.dler.org:6969/announce']
tracker_03 = ['http://tracker.opentrackr.org:1337/announce']

with your logic and see if it works.

7sDream,

You obviously never bothered to test your own code, since instead of replying with the proper syntax, you said, “try this.”

As a suggestion, never, ever list this github account on any resume you submit to a potential employer.

You can close this for all I care, I’ll use something else.

0reactions
7sDreamcommented, Feb 15, 2022
image

I’m pretty sure the announce-list can be modified(increased) normally using the code I’ve given.

This is not the “syntax problem” you mentioned, but you have absolutely no understanding of the format of the torrent file, nor a basic understanding of the Python language.

I have no responsibility or obligation to guide you on how to use my project, and I don’t care what project you end up using to accomplish your goals. Because of your arrogant attitude, I have no interest in continuing to communicate with you. Good lucks, and please do not use any of my code anymore.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Corrupted Word File containing many tracked changes
Hi HiggledyHen,. We suggest you try opening in Word for Windows then save as a new file then send back to you to...
Read more >
03 Coordination tools: bug trackers and mailing lists | LinuxChix ...
describes two ways of collaborating on Free Software work: bug tracking software and mailing lists, ... action, a corrupted saved file and so...
Read more >
Bug #262411 “transmission doesn't load torrent, ktorrent does”
Downloading in Ktorrent began. Is that torrent file seriously corrupted, or is there some mistake while checking torrent file for corruption?
Read more >
gnome-games 2.19.1 [LWN.net]
To: games-list-AT-gnome.org, gnome-announce-list-AT-gnome.org ... Handle empty filename in save dialog (Bug #419486) - Change python OpenGL import to make ...
Read more >
BEncode Editor - Page 13 - General - Forums - uTorrent
I want a "Simple mode" button for switching to uTorrent torrent property-liked dialog for editing announce-list easily.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found