Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression as piece length? #187

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion torrentfile/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import ctypes
import shutil
import platform
import re
from pathlib import Path

if platform.system() == "Windows": # pragma: nocover
Expand Down Expand Up @@ -175,7 +176,12 @@ def normalize_piece_length(piece_length: int) -> int:
if piece_length.isnumeric():
piece_length = int(piece_length)
else:
raise PieceLengthValueError(piece_length)
try:
if re.search('[0-9*<]*(.*)',piece_length).group(1):
raise PieceLengthValueError(piece_length)
piece_length = int(eval(piece_length))
except:
raise PieceLengthValueError(piece_length)

if piece_length > (1 << 14):
if 2**math.log2(piece_length) == piece_length:
Expand Down
Loading