Skip to content

Commit

Permalink
Allow piece sizes up to 256 MiB
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Oct 25, 2024
1 parent 6c0dd51 commit 086e340
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def parse(self, args, meta):
parser.add_argument('-debug', '--debug', action='store_true', required=False, help="Debug Mode, will run through all the motions providing extra info, but will not upload to trackers.")
parser.add_argument('-ffdebug', '--ffdebug', action='store_true', required=False, help="Will show info from ffmpeg while taking screenshots.")
parser.add_argument('-m', '--manual', action='store_true', required=False, help="Manual Mode. Returns link to ddl screens/base.torrent")
parser.add_argument('-mps', '--max-piece-size', nargs='*', required=False, help="Set max piece size allowed in MiB for default torrent creation (default 64 MiB)", choices=['2', '4', '8', '16', '32', '64'])
parser.add_argument('-mps', '--max-piece-size', nargs='*', required=False, help="Set max piece size allowed in MiB for default torrent creation (default 256 MiB)", choices=['2', '4', '8', '16', '32', '64', '128', '256'])
parser.add_argument('-nh', '--nohash', action='store_true', required=False, help="Don't hash .torrent")
parser.add_argument('-rh', '--rehash', action='store_true', required=False, help="DO hash .torrent")
parser.add_argument('-dr', '--draft', action='store_true', required=False, help="Send to drafts (BHD, LST)")
Expand Down
6 changes: 3 additions & 3 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -2466,7 +2466,7 @@ def get_edition(self, video, bdinfo, filelist, manual_edition):
class CustomTorrent(torf.Torrent):
# Default piece size limits
torf.Torrent.piece_size_min = 16384 # 16 KiB
torf.Torrent.piece_size_max = 67108864 # 64 MiB
torf.Torrent.piece_size_max = 268435456 # 256 MiB

def __init__(self, meta, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -2501,8 +2501,8 @@ def piece_size(self, value):
@classmethod
def calculate_piece_size(cls, total_size, min_size, max_size, files):
our_min_size = 16384
our_max_size = max_size if max_size else 67108864 # Default to 64 MiB if max_size is None
piece_size = 67108864 # Start with 64 MiB
our_max_size = max_size if max_size else 268435456 # Default to 256 MiB if max_size is None
piece_size = 268435456 # Start with 256 MiB
num_pieces = math.ceil(total_size / piece_size)
torrent_file_size = 20 + (num_pieces * 20) + cls._calculate_pathname_bytes(files) # Approximate .torrent size

Expand Down

0 comments on commit 086e340

Please sign in to comment.