mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-28 12:36:42 +00:00
support channel number for bulk from streams
This commit is contained in:
parent
7a24511f51
commit
7eae1e4ca5
1 changed files with 15 additions and 5 deletions
|
|
@ -191,6 +191,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
channel_group = stream.channel_group
|
||||
|
||||
# Check if client provided a channel_number; if not, auto-assign one.
|
||||
channel_number = None
|
||||
provided_number = request.data.get('channel_number')
|
||||
if provided_number is None:
|
||||
channel_number = self.get_next_available_channel_number()
|
||||
|
|
@ -211,6 +212,12 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
name = stream.name
|
||||
|
||||
stream_custom_props = json.loads(stream.custom_properties) if stream.custom_properties else {}
|
||||
if channel_number is None:
|
||||
if 'tv-chno' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['tv-chno'])
|
||||
elif 'channel-number' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['channel-number'])
|
||||
|
||||
channel_data = {
|
||||
'channel_number': channel_number,
|
||||
'name': name,
|
||||
|
|
@ -219,11 +226,6 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
'streams': [stream_id],
|
||||
}
|
||||
|
||||
if 'tv-chno' in stream_custom_props:
|
||||
channel_data['channel_number'] = int(stream_custom_props['tv-chno'])
|
||||
elif 'channel-number' in stream_custom_props:
|
||||
channel_data['channel_number'] = int(stream_custom_props['channel-number'])
|
||||
|
||||
if stream.logo_url:
|
||||
logo, _ = Logo.objects.get_or_create(url=stream.logo_url, defaults={
|
||||
"name": stream.name or stream.tvg_id
|
||||
|
|
@ -304,6 +306,7 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
channel_group = stream.channel_group
|
||||
|
||||
# Determine channel number: if provided, use it (if free); else auto assign.
|
||||
channel_number = None
|
||||
provided_number = item.get('channel_number')
|
||||
if provided_number is None:
|
||||
channel_number = get_auto_number()
|
||||
|
|
@ -322,6 +325,13 @@ class ChannelViewSet(viewsets.ModelViewSet):
|
|||
if name is None:
|
||||
name = stream.name
|
||||
|
||||
stream_custom_props = json.loads(stream.custom_properties) if stream.custom_properties else {}
|
||||
if channel_number is None:
|
||||
if 'tv-chno' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['tv-chno'])
|
||||
elif 'channel-number' in stream_custom_props:
|
||||
channel_number = int(stream_custom_props['channel-number'])
|
||||
|
||||
channel_data = {
|
||||
"channel_number": channel_number,
|
||||
"name": name,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue