diff --git a/apps/channels/models.py b/apps/channels/models.py index af66178d..20c9ac42 100644 --- a/apps/channels/models.py +++ b/apps/channels/models.py @@ -119,11 +119,11 @@ class Stream(models.Model): return self.name or self.url or f"Stream ID {self.id}" @classmethod - def generate_hash_key(cls, name, url, tvg_id, keys=None): + def generate_hash_key(cls, name, url, tvg_id, keys=None, m3u_id=None): if keys is None: keys = CoreSettings.get_m3u_hash_key().split(",") - stream_parts = {"name": name, "url": url, "tvg_id": tvg_id} + stream_parts = {"name": name, "url": url, "tvg_id": tvg_id, "m3u_id": m3u_id} hash_parts = {key: stream_parts[key] for key in keys if key in stream_parts} diff --git a/apps/m3u/tasks.py b/apps/m3u/tasks.py index e9d290af..ba2edaef 100644 --- a/apps/m3u/tasks.py +++ b/apps/m3u/tasks.py @@ -774,7 +774,7 @@ def process_xc_category_direct(account_id, batch, groups, hash_keys): group_title = group_name stream_hash = Stream.generate_hash_key( - name, url, tvg_id, hash_keys + name, url, tvg_id, hash_keys, m3u_id=str(account_id) ) stream_props = { "name": name, @@ -942,7 +942,7 @@ def process_m3u_batch_direct(account_id, batch, groups, hash_keys): ) continue - stream_hash = Stream.generate_hash_key(name, url, tvg_id, hash_keys) + stream_hash = Stream.generate_hash_key(name, url, tvg_id, hash_keys, m3u_id=str(account_id)) stream_props = { "name": name, "url": url, diff --git a/core/tasks.py b/core/tasks.py index 7bd3975b..f757613b 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -513,7 +513,7 @@ def rehash_streams(keys): for obj in batch: # Generate new hash - new_hash = Stream.generate_hash_key(obj.name, obj.url, obj.tvg_id, keys) + new_hash = Stream.generate_hash_key(obj.name, obj.url, obj.tvg_id, keys, m3u_id=obj.m3u_account_id) # Check if this hash already exists in our tracking dict or in database if new_hash in hash_keys: diff --git a/frontend/src/pages/Settings.jsx b/frontend/src/pages/Settings.jsx index df7a755a..ff39adb9 100644 --- a/frontend/src/pages/Settings.jsx +++ b/frontend/src/pages/Settings.jsx @@ -651,6 +651,10 @@ const SettingsPage = () => { value: 'tvg_id', label: 'TVG-ID', }, + { + value: 'm3u_id', + label: 'M3U ID', + }, ]} {...form.getInputProps('m3u-hash-key')} key={form.key('m3u-hash-key')}