Add batch size option for bruteforce operation

This commit is contained in:
√(noham)²
2025-12-21 18:56:53 +01:00
parent e14fa2f99e
commit 7dc70dc3bb
5 changed files with 17 additions and 5 deletions

1
.gitignore vendored
View File

@@ -222,3 +222,4 @@ dev_test/
widevine/ widevine/
info.md info.md
/downloads /downloads
.env.bak

View File

@@ -90,6 +90,8 @@ options:
Répertoire de sortie pour les fichiers téléchargés (par défaut: ./downloads) Répertoire de sortie pour les fichiers téléchargés (par défaut: ./downloads)
--widevine-device WIDEVINE_DEVICE --widevine-device WIDEVINE_DEVICE
Chemin vers le CDM Widevine (par défaut: ./widevine/device.wvd) Chemin vers le CDM Widevine (par défaut: ./widevine/device.wvd)
--batch-size BATCH_SIZE
Nombre de requêtes pour le bruteforce (par défaut: 20000)
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL} --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Définir le niveau de logging (par défaut: INFO) Définir le niveau de logging (par défaut: INFO)
``` ```
@@ -100,7 +102,7 @@ https://github.com/user-attachments/assets/cc76990a-3d13-4be1-bb3c-ba8d87e6eaba
**Télécharger un programme spécifique avec une durée :** **Télécharger un programme spécifique avec une durée :**
```bash ```bash
uv run main.py --channel-id 536 --start-date "2025-12-19 12:00:00" --duration "01:30:00" --video "1080p+best" --audio "best" --title "MonFilm" uv run main.py --channel-id 536 --start-date "2025-12-19 12:00:00" --duration "01:30:00" --video "1080p+best" --audio "best" --title "Enregistrement"
``` ```
**Télécharger avec des clés DRM manuelles :** **Télécharger avec des clés DRM manuelles :**

View File

@@ -90,6 +90,8 @@ options:
Output directory for downloaded files (default: ./downloads) Output directory for downloaded files (default: ./downloads)
--widevine-device WIDEVINE_DEVICE --widevine-device WIDEVINE_DEVICE
Path to Widevine device file (default: ./widevine/device.wvd) Path to Widevine device file (default: ./widevine/device.wvd)
--batch-size BATCH_SIZE
Batch size for bruteforce (default: 20000)
--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL} --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
Set the logging level (default: INFO) Set the logging level (default: INFO)
``` ```
@@ -100,7 +102,7 @@ https://github.com/user-attachments/assets/cc76990a-3d13-4be1-bb3c-ba8d87e6eaba
**Download a specific program with duration:** **Download a specific program with duration:**
```bash ```bash
uv run main.py --channel-id 536 --start-date "2025-12-19 12:00:00" --duration "01:30:00" --video "1080p+best" --audio "best" --title "MyMovie" uv run main.py --channel-id 536 --start-date "2025-12-19 12:00:00" --duration "01:30:00" --video "1080p+best" --audio "best" --title "Record"
``` ```
**Download with manual DRM keys:** **Download with manual DRM keys:**

10
main.py
View File

@@ -85,6 +85,12 @@ def parse_arguments():
default="./widevine/device.wvd", default="./widevine/device.wvd",
help="Path to Widevine device file (default: ./widevine/device.wvd)", help="Path to Widevine device file (default: ./widevine/device.wvd)",
) )
parser.add_argument(
"--batch-size",
type=int,
default=20000,
help="Batch size for bruteforce (default: 20000)",
)
parser.add_argument( parser.add_argument(
"--log-level", "--log-level",
type=str, type=str,
@@ -182,6 +188,7 @@ if __name__ == "__main__":
logger.debug("DRM keys: %s", keys) logger.debug("DRM keys: %s", keys)
logger.debug("Output dir: %s", args.output_dir) logger.debug("Output dir: %s", args.output_dir)
logger.debug("Widevine device: %s", args.widevine_device) logger.debug("Widevine device: %s", args.widevine_device)
logger.debug("Batch size: %d", args.batch_size)
else: else:
# Interactive mode # Interactive mode
@@ -206,6 +213,7 @@ if __name__ == "__main__":
title = title or f"{freebox_id}_{start_date.strftime('%Y%m%d_%H%M%S')}" title = title or f"{freebox_id}_{start_date.strftime('%Y%m%d_%H%M%S')}"
keys = [] keys = []
batch_size = args.batch_size if cli_mode else 20000
output_dir = os.getenv("OUTPUT_DIR") or ( output_dir = os.getenv("OUTPUT_DIR") or (
args.output_dir if cli_mode else "./downloads" args.output_dir if cli_mode else "./downloads"
) )
@@ -244,7 +252,7 @@ if __name__ == "__main__":
"Date mismatch between requested start date and manifest data, bruteforce method is needed." "Date mismatch between requested start date and manifest data, bruteforce method is needed."
) )
valid_ticks = asyncio.run(bruteforce(track_id, start_tick_user)) valid_ticks = asyncio.run(bruteforce(track_id, start_tick_user, batch_size))
valid_tick = valid_ticks[0] valid_tick = valid_ticks[0]
start_tick, start_rep = find_nearest_tick_by_hour( start_tick, start_rep = find_nearest_tick_by_hour(

View File

@@ -51,11 +51,10 @@ def future(rep, base, duration):
return base + rep * duration return base + rep * duration
async def bruteforce(track_id, date): async def bruteforce(track_id, date, batch_size=20000):
"""Bruteforce segments to find valid ticks.""" """Bruteforce segments to find valid ticks."""
valid_ticks = [] valid_ticks = []
total_requests = 288000 total_requests = 288000
batch_size = 20000
logger.debug("Starting bruteforce for %s near %s", track_id, date) logger.debug("Starting bruteforce for %s near %s", track_id, date)