From 5c27bd2c10fa9e344ba96739bd7a31703351900d Mon Sep 17 00:00:00 2001 From: SergeantPanda Date: Tue, 28 Oct 2025 15:02:36 -0500 Subject: [PATCH] Enhancement: Increase maximum URL length for Stream model to 4096 characters (from 2000) and add validation for URL length in processing tasks. Fixes #585 --- .../migrations/0030_alter_stream_url.py | 18 ++++++++++++++++++ apps/channels/models.py | 2 +- apps/m3u/tasks.py | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 apps/channels/migrations/0030_alter_stream_url.py diff --git a/apps/channels/migrations/0030_alter_stream_url.py b/apps/channels/migrations/0030_alter_stream_url.py new file mode 100644 index 00000000..203e411a --- /dev/null +++ b/apps/channels/migrations/0030_alter_stream_url.py @@ -0,0 +1,18 @@ +# Generated by Django 5.2.4 on 2025-10-28 20:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('dispatcharr_channels', '0029_backfill_custom_stream_hashes'), + ] + + operations = [ + migrations.AlterField( + model_name='stream', + name='url', + field=models.URLField(blank=True, max_length=4096, null=True), + ), + ] diff --git a/apps/channels/models.py b/apps/channels/models.py index 3b7ed6e3..3dfb392b 100644 --- a/apps/channels/models.py +++ b/apps/channels/models.py @@ -55,7 +55,7 @@ class Stream(models.Model): """ name = models.CharField(max_length=255, default="Default Stream") - url = models.URLField(max_length=2000, blank=True, null=True) + url = models.URLField(max_length=4096, blank=True, null=True) m3u_account = models.ForeignKey( M3UAccount, on_delete=models.CASCADE, diff --git a/apps/m3u/tasks.py b/apps/m3u/tasks.py index d29c294b..6e05c4c0 100644 --- a/apps/m3u/tasks.py +++ b/apps/m3u/tasks.py @@ -894,6 +894,12 @@ def process_m3u_batch_direct(account_id, batch, groups, hash_keys): for stream_info in batch: try: name, url = stream_info["name"], stream_info["url"] + + # Validate URL length - maximum of 4096 characters + if url and len(url) > 4096: + logger.warning(f"Skipping stream '{name}': URL too long ({len(url)} characters, max 4096)") + continue + tvg_id, tvg_logo = get_case_insensitive_attr( stream_info["attributes"], "tvg-id", "" ), get_case_insensitive_attr(stream_info["attributes"], "tvg-logo", "")