fixed tvg_id logic

This commit is contained in:
kappa118 2025-02-26 10:23:06 -05:00
parent 6a2e6963c4
commit 849bf2f73b
3 changed files with 18 additions and 3 deletions

View file

@ -12,6 +12,7 @@ class StreamSerializer(serializers.ModelSerializer):
allow_null=True,
required=False
)
class Meta:
model = Stream
fields = [
@ -29,6 +30,19 @@ class StreamSerializer(serializers.ModelSerializer):
'stream_profile_id',
]
def get_fields(self):
fields = super().get_fields()
# Unable to edit specific properties if this stream was created from an M3U account
if self.instance and getattr(self.instance, 'm3u_account', None):
fields['id'].read_only = True
fields['name'].read_only = True
fields['url'].read_only = True
fields['m3u_account'].read_only = True
fields['tvg_id'].read_only = True
fields['group_name'].read_only = True
return fields
#
# Channel Group

View file

@ -35,7 +35,7 @@ class ProgramData(models.Model):
title = models.CharField(max_length=255)
sub_title = models.CharField(max_length=255, blank=True, null=True)
description = models.TextField(blank=True, null=True)
tvg_id = models.TextField(max_length=255)
tvg_id = models.TextField(max_length=255, null=True)
def __str__(self):
return f"{self.title} ({self.start_time} - {self.end_time})"

View file

@ -47,6 +47,7 @@ def fetch_xmltv(source):
'end_time': stop_time,
'title': title,
'description': desc,
'tvg_id': channel_tvg_id,
})
# Process each channel group
@ -75,11 +76,11 @@ def fetch_xmltv(source):
epg=epg_data,
start_time=prog['start_time'],
title=prog['title'],
tvg_id=tvg_id,
defaults={
'end_time': prog['end_time'],
'description': prog['description'],
'sub_title': ''
'sub_title': '',
'tvg_id': tvg_id,
}
)
if created: