subscriptions module finished
This commit is contained in:
@@ -159,4 +159,7 @@
|
|||||||
<data name="StartAtMeteredConnectionDialogTitle" xml:space="preserve">
|
<data name="StartAtMeteredConnectionDialogTitle" xml:space="preserve">
|
||||||
<value>Warning</value>
|
<value>Warning</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="SubscriptionVideoListName" xml:space="preserve">
|
||||||
|
<value>Subscriptions</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
@@ -132,6 +132,12 @@
|
|||||||
<data name="OptionBarMessageLoading" xml:space="preserve">
|
<data name="OptionBarMessageLoading" xml:space="preserve">
|
||||||
<value>Loading...</value>
|
<value>Loading...</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="OptionBarMessageVideosFound" xml:space="preserve">
|
||||||
|
<value>New videos:</value>
|
||||||
|
</data>
|
||||||
|
<data name="OptionBarMessageVideosNotFound" xml:space="preserve">
|
||||||
|
<value>No new videos</value>
|
||||||
|
</data>
|
||||||
<data name="OptionBarPlaylistSearch.Label" xml:space="preserve">
|
<data name="OptionBarPlaylistSearch.Label" xml:space="preserve">
|
||||||
<value>Playlist search</value>
|
<value>Playlist search</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ using VDownload.Core.Tasks;
|
|||||||
using VDownload.Models;
|
using VDownload.Models;
|
||||||
using VDownload.Services.Data.Configuration;
|
using VDownload.Services.Data.Configuration;
|
||||||
using VDownload.Services.Data.Settings;
|
using VDownload.Services.Data.Settings;
|
||||||
|
using VDownload.Services.Data.Subscriptions;
|
||||||
using VDownload.Services.UI.Dialogs;
|
using VDownload.Services.UI.Dialogs;
|
||||||
using VDownload.Services.UI.StringResources;
|
using VDownload.Services.UI.StringResources;
|
||||||
using VDownload.Sources;
|
using VDownload.Sources;
|
||||||
@@ -52,6 +53,7 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
protected readonly ISettingsService _settingsService;
|
protected readonly ISettingsService _settingsService;
|
||||||
protected readonly IStringResourcesService _stringResourcesService;
|
protected readonly IStringResourcesService _stringResourcesService;
|
||||||
protected readonly ISearchService _searchService;
|
protected readonly ISearchService _searchService;
|
||||||
|
protected readonly ISubscriptionsDataService _subscriptionsDataService;
|
||||||
protected readonly IDialogsService _dialogsService;
|
protected readonly IDialogsService _dialogsService;
|
||||||
|
|
||||||
protected readonly IDownloadTaskManager _downloadTaskManager;
|
protected readonly IDownloadTaskManager _downloadTaskManager;
|
||||||
@@ -88,6 +90,9 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private OptionBarMessageIconType _optionBarMessageIcon;
|
private OptionBarMessageIconType _optionBarMessageIcon;
|
||||||
|
|
||||||
|
[ObservableProperty]
|
||||||
|
private bool _optionBarLoadSubscriptionButtonChecked;
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
private bool _optionBarVideoSearchButtonChecked;
|
private bool _optionBarVideoSearchButtonChecked;
|
||||||
|
|
||||||
@@ -112,12 +117,13 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
|
|
||||||
#region CONSTRUCTORS
|
#region CONSTRUCTORS
|
||||||
|
|
||||||
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel)
|
public HomeViewModel(IConfigurationService configurationService, ISettingsService settingsService, IStringResourcesService stringResourcesService, ISearchService searchService, ISubscriptionsDataService subscriptionsDataService, IDialogsService dialogsService, IDownloadTaskManager downloadTaskManager, HomeVideoViewModel videoViewModel, HomeVideoCollectionViewModel videoCollectionViewModel)
|
||||||
{
|
{
|
||||||
_configurationService = configurationService;
|
_configurationService = configurationService;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_stringResourcesService = stringResourcesService;
|
_stringResourcesService = stringResourcesService;
|
||||||
_searchService = searchService;
|
_searchService = searchService;
|
||||||
|
_subscriptionsDataService = subscriptionsDataService;
|
||||||
_dialogsService = dialogsService;
|
_dialogsService = dialogsService;
|
||||||
|
|
||||||
_downloadTaskManager = downloadTaskManager;
|
_downloadTaskManager = downloadTaskManager;
|
||||||
@@ -145,6 +151,7 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
OptionBarContent = OptionBarContentType.None;
|
OptionBarContent = OptionBarContentType.None;
|
||||||
OptionBarMessageIcon = OptionBarMessageIconType.None;
|
OptionBarMessageIcon = OptionBarMessageIconType.None;
|
||||||
OptionBarMessage = null;
|
OptionBarMessage = null;
|
||||||
|
OptionBarLoadSubscriptionButtonChecked = false;
|
||||||
OptionBarVideoSearchButtonChecked = false;
|
OptionBarVideoSearchButtonChecked = false;
|
||||||
OptionBarPlaylistSearchButtonChecked = false;
|
OptionBarPlaylistSearchButtonChecked = false;
|
||||||
OptionBarSearchNotPending = true;
|
OptionBarSearchNotPending = true;
|
||||||
@@ -154,16 +161,64 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
public void LoadFromSubscription()
|
public async Task LoadFromSubscription()
|
||||||
{
|
{
|
||||||
MainContent = _downloadsView;
|
MainContent = _downloadsView;
|
||||||
|
OptionBarMessageIcon = OptionBarMessageIconType.None;
|
||||||
|
OptionBarMessage = null;
|
||||||
|
|
||||||
|
if (OptionBarLoadSubscriptionButtonChecked)
|
||||||
|
{
|
||||||
OptionBarContent = OptionBarContentType.None;
|
OptionBarContent = OptionBarContentType.None;
|
||||||
OptionBarVideoSearchButtonChecked = false;
|
OptionBarVideoSearchButtonChecked = false;
|
||||||
OptionBarPlaylistSearchButtonChecked = false;
|
OptionBarPlaylistSearchButtonChecked = false;
|
||||||
OptionBarSearchNotPending = false;
|
|
||||||
|
|
||||||
//TODO: Load videos
|
OptionBarSearchNotPending = false;
|
||||||
|
OptionBarMessageIcon = OptionBarMessageIconType.ProgressRing;
|
||||||
|
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageLoading");
|
||||||
|
|
||||||
|
SubscriptionsVideoList subList = new SubscriptionsVideoList { Name = _stringResourcesService.CommonResources.Get("SubscriptionVideoListName") };
|
||||||
|
List<Task> tasks = new List<Task>();
|
||||||
|
foreach (Subscription sub in _subscriptionsDataService.Data.ToArray())
|
||||||
|
{
|
||||||
|
tasks.Add(Task.Run(async () =>
|
||||||
|
{
|
||||||
|
Playlist playlist;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
playlist = await _searchService.SearchPlaylist(sub.Url.OriginalString, 0);
|
||||||
|
}
|
||||||
|
catch (MediaSearchException)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerable<Video> newIds = playlist.Where(x => !sub.VideoIds.Contains(x.Id));
|
||||||
|
subList.AddRange(newIds);
|
||||||
|
foreach (Video video in newIds)
|
||||||
|
{
|
||||||
|
sub.VideoIds.Add(video.Id);
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
await Task.WhenAll(tasks);
|
||||||
|
await _subscriptionsDataService.Save();
|
||||||
|
|
||||||
|
if (subList.Count > 0)
|
||||||
|
{
|
||||||
|
OptionBarMessage = $"{_stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosFound")} {subList.Count}";
|
||||||
|
|
||||||
|
_videoCollectionViewModel.LoadCollection(subList);
|
||||||
|
MainContent = _videoCollectionView;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OptionBarMessage = _stringResourcesService.HomeViewResources.Get("OptionBarMessageVideosNotFound");
|
||||||
|
}
|
||||||
|
|
||||||
|
OptionBarSearchNotPending = true;
|
||||||
|
OptionBarMessageIcon = OptionBarMessageIconType.None;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[RelayCommand]
|
[RelayCommand]
|
||||||
@@ -178,6 +233,7 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
{
|
{
|
||||||
OptionBarContent = OptionBarContentType.VideoSearch;
|
OptionBarContent = OptionBarContentType.VideoSearch;
|
||||||
OptionBarPlaylistSearchButtonChecked = false;
|
OptionBarPlaylistSearchButtonChecked = false;
|
||||||
|
OptionBarLoadSubscriptionButtonChecked = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -197,6 +253,7 @@ namespace VDownload.Core.ViewModels.Home
|
|||||||
{
|
{
|
||||||
OptionBarContent = OptionBarContentType.PlaylistSearch;
|
OptionBarContent = OptionBarContentType.PlaylistSearch;
|
||||||
OptionBarVideoSearchButtonChecked = false;
|
OptionBarVideoSearchButtonChecked = false;
|
||||||
|
OptionBarLoadSubscriptionButtonChecked = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -129,9 +129,10 @@
|
|||||||
</ctuc:UniformGrid>
|
</ctuc:UniformGrid>
|
||||||
<StackPanel Grid.Column="2"
|
<StackPanel Grid.Column="2"
|
||||||
Orientation="Horizontal">
|
Orientation="Horizontal">
|
||||||
<AppBarButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarLoadSubscription"
|
<AppBarToggleButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarLoadSubscription"
|
||||||
Icon="Favorite"
|
Icon="Favorite"
|
||||||
IsEnabled="{Binding OptionBarSearchNotPending}"
|
IsEnabled="{Binding OptionBarSearchNotPending}"
|
||||||
|
IsChecked="{Binding OptionBarLoadSubscriptionButtonChecked, Mode=TwoWay}"
|
||||||
Command="{Binding LoadFromSubscriptionCommand}"/>
|
Command="{Binding LoadFromSubscriptionCommand}"/>
|
||||||
<AppBarToggleButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarVideoSearch"
|
<AppBarToggleButton x:Uid="/VDownload.Core.Strings/HomeViewResources/OptionBarVideoSearch"
|
||||||
Icon="Video"
|
Icon="Video"
|
||||||
|
|||||||
@@ -62,7 +62,8 @@
|
|||||||
</Image>
|
</Image>
|
||||||
<TextBlock Grid.Row="1"
|
<TextBlock Grid.Row="1"
|
||||||
Text="{Binding Name}"
|
Text="{Binding Name}"
|
||||||
HorizontalAlignment="Center"/>
|
HorizontalAlignment="Center"
|
||||||
|
TextTrimming="CharacterEllipsis"/>
|
||||||
<HyperlinkButton x:Uid="/VDownload.Core.Strings/SubscriptionsViewResources/RemovePlaylistButton"
|
<HyperlinkButton x:Uid="/VDownload.Core.Strings/SubscriptionsViewResources/RemovePlaylistButton"
|
||||||
Grid.Row="2"
|
Grid.Row="2"
|
||||||
Content="Remove"
|
Content="Remove"
|
||||||
@@ -87,7 +88,8 @@
|
|||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBox x:Uid="/VDownload.Core.Strings/SubscriptionsViewResources/PlaylistUrlTextBox"
|
<TextBox x:Uid="/VDownload.Core.Strings/SubscriptionsViewResources/PlaylistUrlTextBox"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Text="{Binding Url, Mode=TwoWay}"/>
|
Text="{Binding Url, Mode=TwoWay}"
|
||||||
|
IsEnabled="{Binding Loading, Converter={StaticResource BoolNegationConverter}}"/>
|
||||||
<ctuc:SwitchPresenter Grid.Column="1"
|
<ctuc:SwitchPresenter Grid.Column="1"
|
||||||
Value="{Binding Loading, Converter={StaticResource ObjectToStringConverter}}">
|
Value="{Binding Loading, Converter={StaticResource ObjectToStringConverter}}">
|
||||||
<ctuc:Case Value="True">
|
<ctuc:Case Value="True">
|
||||||
|
|||||||
Reference in New Issue
Block a user