Skip to content
This repository was archived by the owner on Sep 14, 2022. It is now read-only.

Commit 69f9a6d

Browse files
committed
Add interface for VM
1 parent dc875fa commit 69f9a6d

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Prism.Commands;
2+
using System;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using YoutubeExplode.Models;
8+
using YoutubeExplode.Models.MediaStreams;
9+
10+
namespace YouTubeTool.ViewModels
11+
{
12+
internal class IMainViewModel
13+
{
14+
bool IsBusy { get; }
15+
string Query { get; set; }
16+
17+
Playlist Playlist { get; }
18+
bool IsDataAvailable { get; }
19+
20+
double Progress { get; }
21+
bool IsProgressIndeterminate { get; }
22+
23+
DelegateCommand GetDataCommand { get; }
24+
DelegateCommand<string> DownloadSongCommand { get; }
25+
DelegateCommand<string> DownloadVideoCommand { get; }
26+
}
27+
}

YouTubeTool/ViewModels/MainViewModel.cs

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ internal class MainViewModel : BindableBase
2222

2323
private readonly Cli FfmpegCli = new Cli("ffmpeg.exe");
2424

25+
private static readonly string TempDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Temp");
26+
private static readonly string OutputDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Output");
27+
2528
#region Fields
2629
private string myTitle;
2730
private string status;
@@ -31,8 +34,6 @@ internal class MainViewModel : BindableBase
3134
private Playlist _playlist;
3235
private Video _video;
3336
private Channel _channel;
34-
//private MediaStreamInfoSet _mediaStreamInfos;
35-
//private IReadOnlyList<ClosedCaptionTrackInfo> _closedCaptionTrackInfos;
3637
private double _progress;
3738
private bool _isProgressIndeterminate;
3839
#endregion
@@ -115,13 +116,11 @@ public bool IsProgressIndeterminate
115116
}
116117
#endregion
117118

118-
// Commands
119+
#region Commands
119120
public DelegateCommand GetDataCommand { get; }
120121
public DelegateCommand<string> DownloadSongCommand { get; }
121122
public DelegateCommand<string> DownloadVideoCommand { get; }
122-
123-
private static readonly string TempDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Temp");
124-
private static readonly string OutputDirectoryPath = Path.Combine(Directory.GetCurrentDirectory(), "Output");
123+
#endregion
125124
#endregion
126125

127126
public MainViewModel()
@@ -178,7 +177,7 @@ private async void GetData()
178177
IsProgressIndeterminate = false;
179178
}
180179

181-
#region YouTube Dling
180+
#region YouTube Song DL
182181
private async Task DownloadSongPlaylistAsync(string id)
183182
{
184183
// Get playlist info
@@ -245,6 +244,17 @@ private async Task DownloadSongAsync(Video video)
245244
Status = $"Downloaded and converted video [{video.Id}] to [{outputFilePath}]";
246245
}
247246

247+
private static MediaStreamInfo GetBestAudioStreamInfo(MediaStreamInfoSet set)
248+
{
249+
if (set.Audio.Any())
250+
return set.Audio.WithHighestBitrate();
251+
if (set.Muxed.Any())
252+
return set.Muxed.WithHighestVideoQuality();
253+
throw new Exception("No applicable media streams found for this video");
254+
}
255+
#endregion
256+
257+
#region YouTube Video DL
248258
private async Task DownloadVideoAsync(string id)
249259
{
250260
Status = $"Working on video [{id}]...";
@@ -288,15 +298,6 @@ private async Task DownloadVideoAsync(Video video)
288298

289299
Status = $"Downloaded video [{video.Id}] to [{outputFilePath}]";
290300
}
291-
292-
private static MediaStreamInfo GetBestAudioStreamInfo(MediaStreamInfoSet set)
293-
{
294-
if (set.Audio.Any())
295-
return set.Audio.WithHighestBitrate();
296-
if (set.Muxed.Any())
297-
return set.Muxed.WithHighestVideoQuality();
298-
throw new Exception("No applicable media streams found for this video");
299-
}
300301
#endregion
301302

302303
#region Commands

0 commit comments

Comments
 (0)