other filters added
This commit is contained in:
@@ -81,6 +81,91 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
}
|
}
|
||||||
protected string _authorFilter;
|
protected string _authorFilter;
|
||||||
|
|
||||||
|
public long MinViewsFilter
|
||||||
|
{
|
||||||
|
get => _minViewsFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _minViewsFilter, value, nameof(MinViewsFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected long _minViewsFilter;
|
||||||
|
|
||||||
|
public long MaxViewsFilter
|
||||||
|
{
|
||||||
|
get => _maxViewsFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _maxViewsFilter, value, nameof(MaxViewsFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected long _maxViewsFilter;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected long _minViews;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected long _maxViews;
|
||||||
|
|
||||||
|
public DateTimeOffset MinDateFilter
|
||||||
|
{
|
||||||
|
get => _minDateFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _minDateFilter, value, nameof(MinDateFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected DateTimeOffset _minDateFilter;
|
||||||
|
|
||||||
|
public DateTimeOffset MaxDateFilter
|
||||||
|
{
|
||||||
|
get => _maxDateFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _maxDateFilter, value, nameof(MaxDateFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected DateTimeOffset _maxDateFilter;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected DateTimeOffset _minDate;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected DateTimeOffset _maxDate;
|
||||||
|
|
||||||
|
|
||||||
|
public TimeSpan MinDurationFilter
|
||||||
|
{
|
||||||
|
get => _minDurationFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _minDurationFilter, value, nameof(MinDurationFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected TimeSpan _minDurationFilter;
|
||||||
|
|
||||||
|
public TimeSpan MaxDurationFilter
|
||||||
|
{
|
||||||
|
get => _maxDurationFilter;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
SetProperty(ref _maxDurationFilter, value, nameof(MaxDurationFilter));
|
||||||
|
UpdateFilter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected TimeSpan _maxDurationFilter;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected TimeSpan _minDuration;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
protected TimeSpan _maxDuration;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
@@ -107,11 +192,31 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
public void LoadPlaylist(Playlist playlist)
|
public void LoadPlaylist(Playlist playlist)
|
||||||
{
|
{
|
||||||
_playlist = playlist;
|
_playlist = playlist;
|
||||||
|
ParallelQuery<Video> playlistQuery = playlist.AsParallel();
|
||||||
|
|
||||||
_removedVideos.Clear();
|
_removedVideos.Clear();
|
||||||
|
|
||||||
_titleFilter = string.Empty;
|
_titleFilter = string.Empty;
|
||||||
_authorFilter = string.Empty;
|
_authorFilter = string.Empty;
|
||||||
|
|
||||||
|
IEnumerable<long> views = playlistQuery.Select(x => x.Views);
|
||||||
|
MinViews = views.Min();
|
||||||
|
MaxViews = views.Max();
|
||||||
|
_minViewsFilter = MinViews;
|
||||||
|
_maxViewsFilter = MaxViews;
|
||||||
|
|
||||||
|
IEnumerable<DateTimeOffset> date = playlist.Select(x => new DateTimeOffset(x.PublishDate));
|
||||||
|
MinDate = date.Min();
|
||||||
|
MaxDate = date.Max();
|
||||||
|
_minDateFilter = MinDate;
|
||||||
|
_maxDateFilter = MaxDate;
|
||||||
|
|
||||||
|
IEnumerable<TimeSpan> duration = playlistQuery.Select(x => x.Duration);
|
||||||
|
MinDuration = duration.Min();
|
||||||
|
MaxDuration = duration.Max();
|
||||||
|
_minDurationFilter = MinDuration;
|
||||||
|
_maxDurationFilter = MaxDuration;
|
||||||
|
|
||||||
Name = _playlist.Name;
|
Name = _playlist.Name;
|
||||||
Videos.Clear();
|
Videos.Clear();
|
||||||
foreach (Video video in playlist)
|
foreach (Video video in playlist)
|
||||||
@@ -176,7 +281,11 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
protected void CreateTasks(bool download)
|
protected void CreateTasks(bool download)
|
||||||
{
|
{
|
||||||
foreach (VideoViewModel video in Videos.Keys)
|
IEnumerable<VideoViewModel> videos = Videos.Cast<ObservableKeyValuePair<VideoViewModel, bool>>()
|
||||||
|
.Where(x => x.Value)
|
||||||
|
.Select(x => x.Key);
|
||||||
|
|
||||||
|
foreach (VideoViewModel video in videos)
|
||||||
{
|
{
|
||||||
DownloadTask task = _tasksManager.AddTask(video.Video, video.BuildDownloadOptions());
|
DownloadTask task = _tasksManager.AddTask(video.Video, video.BuildDownloadOptions());
|
||||||
if (download)
|
if (download)
|
||||||
@@ -194,25 +303,28 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
foreach (ObservableKeyValuePair<VideoViewModel, bool> item in Videos)
|
foreach (ObservableKeyValuePair<VideoViewModel, bool> item in Videos)
|
||||||
{
|
{
|
||||||
if (!titleRegex.IsMatch(item.Key.Title))
|
VideoViewModel video = item.Key;
|
||||||
{
|
bool hide =
|
||||||
item.Value = false;
|
(
|
||||||
continue;
|
_removedVideos.Contains(video)
|
||||||
}
|
||
|
||||||
|
!titleRegex.IsMatch(video.Title)
|
||||||
if (!authorRegex.IsMatch(item.Key.Author))
|
||
|
||||||
{
|
!authorRegex.IsMatch(video.Author)
|
||||||
item.Value = false;
|
||
|
||||||
continue;
|
MinViewsFilter > video.Views
|
||||||
}
|
||
|
||||||
|
MaxViewsFilter < video.Views
|
||||||
if (_removedVideos.Contains(item.Key))
|
||
|
||||||
{
|
MinDateFilter.Date > video.PublishDate.Date
|
||||||
item.Value = false;
|
||
|
||||||
continue;
|
MaxDateFilter.Date < video.PublishDate.Date
|
||||||
}
|
||
|
||||||
|
MinDurationFilter > video.Duration
|
||||||
item.Value = true;
|
||
|
||||||
|
MaxDurationFilter < video.Duration
|
||||||
|
);
|
||||||
|
item.Value = !hide;
|
||||||
}
|
}
|
||||||
|
|
||||||
RemovedCount = _removedVideos.Count;
|
RemovedCount = _removedVideos.Count;
|
||||||
|
|||||||
@@ -98,12 +98,22 @@
|
|||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<NumberBox Grid.Column="0"
|
<NumberBox Grid.Column="0"
|
||||||
SpinButtonPlacementMode="Compact"/>
|
SpinButtonPlacementMode="Compact"
|
||||||
|
Minimum="{Binding MinViews}"
|
||||||
|
Value="{Binding MinViewsFilter, Mode=TwoWay}"
|
||||||
|
Maximum="{Binding MaxViewsFilter}"
|
||||||
|
SmallChange="1"
|
||||||
|
LargeChange="10"/>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="-"/>
|
Text="-"/>
|
||||||
<NumberBox Grid.Column="2"
|
<NumberBox Grid.Column="2"
|
||||||
SpinButtonPlacementMode="Compact"/>
|
SpinButtonPlacementMode="Compact"
|
||||||
|
Minimum="{Binding MinViewsFilter}"
|
||||||
|
Value="{Binding MaxViewsFilter, Mode=TwoWay}"
|
||||||
|
Maximum="{Binding MaxViews}"
|
||||||
|
SmallChange="1"
|
||||||
|
LargeChange="10"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterDateTextBlock"
|
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterDateTextBlock"
|
||||||
Grid.Row="3"
|
Grid.Row="3"
|
||||||
@@ -117,11 +127,17 @@
|
|||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<CalendarDatePicker Grid.Column="0"/>
|
<CalendarDatePicker Grid.Column="0"
|
||||||
|
MinDate="{Binding MinDate}"
|
||||||
|
Date="{Binding MinDateFilter, Mode=TwoWay}"
|
||||||
|
MaxDate="{Binding MaxDateFilter}"/>
|
||||||
<TextBlock Grid.Column="1"
|
<TextBlock Grid.Column="1"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Text="-"/>
|
Text="-"/>
|
||||||
<CalendarDatePicker Grid.Column="2"/>
|
<CalendarDatePicker Grid.Column="2"
|
||||||
|
MinDate="{Binding MinDateFilter}"
|
||||||
|
Date="{Binding MaxDateFilter, Mode=TwoWay}"
|
||||||
|
MaxDate="{Binding MaxDate}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterDurationTextBlock"
|
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterDurationTextBlock"
|
||||||
Grid.Row="4"
|
Grid.Row="4"
|
||||||
@@ -134,8 +150,14 @@
|
|||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<c:TimeSpanControl Grid.Row="0"/>
|
<c:TimeSpanControl Grid.Row="0"
|
||||||
<c:TimeSpanControl Grid.Row="1"/>
|
Minimum="{Binding MinDuration}"
|
||||||
|
Value="{Binding MinDurationFilter, Mode=TwoWay}"
|
||||||
|
Maximum="{Binding MaxDurationFilter}"/>
|
||||||
|
<c:TimeSpanControl Grid.Row="1"
|
||||||
|
Minimum="{Binding MinDurationFilter}"
|
||||||
|
Value="{Binding MaxDurationFilter, Mode=TwoWay}"
|
||||||
|
Maximum="{Binding MaxDuration}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterRemovedTextBlock"
|
<TextBlock x:Uid="/VDownload.Core.Strings/HomePlaylistViewResources/FilterRemovedTextBlock"
|
||||||
Grid.Row="5"
|
Grid.Row="5"
|
||||||
|
|||||||
Reference in New Issue
Block a user