feat(models): add Source.prefer_audio_track
A per-Source CharField choice (original / default) with a data migration. Defaults to 'original', which keeps the current combined-format matching behaviour (added in PR #1452) unchanged. format_summary gains a ' DEFAULT-AUDIO' marker so the source list shows which sources deviate. Refs #1468
This commit is contained in:
35
tubesync/sync/migrations/0038_source_prefer_audio_track.py
Normal file
35
tubesync/sync/migrations/0038_source_prefer_audio_track.py
Normal file
@@ -0,0 +1,35 @@
|
||||
# Generated by Django 5.2.11 on 2026-09-07 00:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('sync', '0037_alter_source_fallback'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='source',
|
||||
name='prefer_audio_track',
|
||||
field=models.CharField(
|
||||
choices=[
|
||||
('original', 'Original audio (recorded language)'),
|
||||
('default', "Publisher's default audio (often an auto-dub)"),
|
||||
],
|
||||
db_index=True,
|
||||
default='original',
|
||||
help_text=(
|
||||
'Which audio track to download when the source publishes more than one. '
|
||||
'"Original audio" is the track in the language the video was actually '
|
||||
'recorded in. "Publisher\'s default audio" is whichever track the uploader '
|
||||
'set as the default for viewers, which for many channels is an automatic '
|
||||
'dubbed translation. This setting has no effect when a video only offers a '
|
||||
'single audio track.'
|
||||
),
|
||||
max_length=8,
|
||||
verbose_name='prefer audio track',
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -12,7 +12,7 @@ from django.utils.text import slugify
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from yt_dlp import DownloadError
|
||||
from ..choices import (Val,
|
||||
SponsorBlock_Category, YouTube_SourceType, IndexSchedule,
|
||||
AudioTrack, SponsorBlock_Category, YouTube_SourceType, IndexSchedule,
|
||||
CapChoices, Fallback, FileExtension, FilterSeconds,
|
||||
SourceResolution, SourceResolutionInteger,
|
||||
YouTube_VideoCodec, YouTube_AudioCodec,
|
||||
@@ -252,6 +252,21 @@ class Source(db.models.Model):
|
||||
default=False,
|
||||
help_text=_('Where possible, prefer HDR media for this source'),
|
||||
)
|
||||
prefer_audio_track = db.models.CharField(
|
||||
_('prefer audio track'),
|
||||
max_length=8,
|
||||
db_index=True,
|
||||
choices=AudioTrack.choices,
|
||||
default=AudioTrack.ORIGINAL,
|
||||
help_text=_(
|
||||
'Which audio track to download when the source publishes more than one. '
|
||||
'"Original audio" is the track in the language the video was actually '
|
||||
'recorded in. "Publisher\'s default audio" is whichever track the uploader '
|
||||
'set as the default for viewers, which for many channels is an automatic '
|
||||
'dubbed translation. This setting has no effect when a video only offers a '
|
||||
'single audio track.'
|
||||
),
|
||||
)
|
||||
fallback = db.models.CharField(
|
||||
_('fallback'),
|
||||
max_length=1,
|
||||
@@ -468,7 +483,8 @@ class Source(db.models.Model):
|
||||
ac = self.source_acodec
|
||||
f = ' 60FPS' if self.is_video and self.prefer_60fps else ''
|
||||
h = ' HDR' if self.is_video and self.prefer_hdr else ''
|
||||
return f'{self.source_resolution} (video:{vc}, audio:{ac}){f}{h}'.strip()
|
||||
a = '' if self.prefer_audio_track == Val(AudioTrack.ORIGINAL) else ' DEFAULT-AUDIO'
|
||||
return f'{self.source_resolution} (video:{vc}, audio:{ac}){f}{h}{a}'.strip()
|
||||
|
||||
@property
|
||||
def directory_path(self):
|
||||
|
||||
Reference in New Issue
Block a user