Skip to content

Commit 05777f5

Browse files
committed
🍞 Allow specifying playlist items
1 parent 5b61374 commit 05777f5

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

YoutubeDl.Wpf/Models/BackendInstance.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ private void ParseLine(ReadOnlySpan<char> line)
153153
}
154154
}
155155

156-
public void GenerateDownloadArguments()
156+
public void GenerateDownloadArguments(string playlistItems)
157157
{
158158
GeneratedDownloadArguments.Clear();
159159

@@ -236,6 +236,12 @@ public void GenerateDownloadArguments()
236236
if (_settings.DownloadPlaylist)
237237
{
238238
GeneratedDownloadArguments.Add("--yes-playlist");
239+
240+
if (!string.IsNullOrEmpty(playlistItems))
241+
{
242+
GeneratedDownloadArguments.Add("--playlist-items");
243+
GeneratedDownloadArguments.Add(playlistItems);
244+
}
239245
}
240246
else
241247
{

YoutubeDl.Wpf/ViewModels/HomeViewModel.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public class HomeViewModel : ReactiveValidationObject
6060
[Reactive]
6161
public string Link { get; set; } = "";
6262

63+
[Reactive]
64+
public string PlaylistItems { get; set; } = "";
65+
6366
public ReactiveCommand<Unit, Unit> ResetCustomFilenameTemplateCommand { get; }
6467
public ReactiveCommand<Unit, Unit> BrowseDownloadFolderCommand { get; }
6568
public ReactiveCommand<Unit, Unit> OpenDownloadFolderCommand { get; }
@@ -142,7 +145,8 @@ public HomeViewModel(ObservableSettings settings, BackendService backendService,
142145
x => x.SharedSettings.DownloadAutoGeneratedSubtitles,
143146
x => x.SharedSettings.AddMetadata,
144147
x => x.SharedSettings.DownloadThumbnail,
145-
x => x.SharedSettings.DownloadPlaylist)
148+
x => x.SharedSettings.DownloadPlaylist,
149+
x => x.PlaylistItems)
146150
.Select(_ => Unit.Default);
147151

148152
var gdaC = this.WhenAnyValue(
@@ -361,7 +365,7 @@ private void GenerateDownloadArguments()
361365
DownloadArguments.RemoveAt(_globalArgCount);
362366
}
363367

364-
BackendInstance.GenerateDownloadArguments();
368+
BackendInstance.GenerateDownloadArguments(PlaylistItems);
365369

366370
var pos = _globalArgCount;
367371

YoutubeDl.Wpf/Views/HomeView.xaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@
150150
<ToggleButton x:Name="playlistToggle"
151151
Margin="8 4 4 4"/>
152152
<TextBlock VerticalAlignment="Center" Margin="4">Download playlist</TextBlock>
153+
<TextBox x:Name="playlistItemsTextBox"
154+
Margin="4"
155+
Width="96"
156+
VerticalAlignment="Center"
157+
materialDesign:HintAssist.Hint="Items (optional)"/>
153158
</StackPanel>
154159
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="1">
155160
<ToggleButton x:Name="filenameTemplateToggle"

YoutubeDl.Wpf/Views/HomeView.xaml.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,16 @@ public HomeView()
115115
view => view.playlistToggle.IsChecked)
116116
.DisposeWith(disposables);
117117

118+
this.OneWayBind(ViewModel,
119+
viewModel => viewModel.SharedSettings.DownloadPlaylist,
120+
view => view.playlistItemsTextBox.IsEnabled)
121+
.DisposeWith(disposables);
122+
123+
this.Bind(ViewModel,
124+
viewModel => viewModel.PlaylistItems,
125+
view => view.playlistItemsTextBox.Text)
126+
.DisposeWith(disposables);
127+
118128
// Options row 2
119129
this.Bind(ViewModel,
120130
viewModel => viewModel.SharedSettings.UseCustomOutputTemplate,

0 commit comments

Comments
 (0)