pobrn / mktorrent

A simple command line utility to create BitTorrent metainfo files
Other
472 stars 73 forks source link

Request: Automatic Piece Length #30

Closed microraptor closed 3 years ago

microraptor commented 5 years ago

Could we have a -l auto option please, which calculates using the torrent size a piece length between 15 and 24, so that there are usually maybe between 1000 and 2000 pieces.

Perhaps with this formula: max( 15, min( 24, floor( log( torrent_size / 1000 ) / log( 2 ))))

Slider-Whistle commented 4 years ago

https://github.com/cmclark65/mktorrent/blob/master/init.c Sections mentioning "piece_length" (lines 872 on, in particular) from @cmclark65 's fork seem to be his only relevant changes. Someone who's not an idiot like myself could probably ask for permission to port it over without worrying about something breaking.

https://github.com/Rudde/mktorrent/issues/22#issuecomment-384086551 He talks a little bit about his fork here. You could just use his, but then you miss out on other updates like the source option.

cmclark65 commented 4 years ago

I don't know what the source option does exactly, but if I understand it right and if you know the details of what it is doing you could do the same thing with the --extra option that is in my fork; it lets you add arbitrary extra fields to the dictionary. I did this specifically so I could make torrents that would already have the various incompatible extra fields added by various private trackers I was using. I would just make a wrapper script, "siteNamemake" and it would call mktorrent with "--extra=source:siteName" as one of its arguments.

I don't use mktorrent now and don't have the resources to work on the code now, but I doubt it is insanely hard to port the piece size changes, especially since most or all of my compiler warning fixes have already been ported I think. Anyone certainly has my permission to do it.

You could also keep using the currently maintained mktorrent and use a wrapper script to calculate piece sizes. I'll try to paste a link to the one I was using prior to forking (the then unmaintained) mktorrent.

https://pastebin.com/2RSVXj0z

Slider-Whistle commented 4 years ago

@cmclark65 Thanks for sharing, both of those things are really useful. I was going to make a script that seds the source field in or something.