Archived
1
0
This commit is contained in:
Michael Gordeev
2018-12-14 12:49:55 +03:00
parent b415dbd00a
commit 7597981420
2 changed files with 4 additions and 23 deletions
+4 -5
View File
@@ -4,6 +4,7 @@ using Google.Apis.YouTube.v3.Data;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
using Windows.ApplicationModel.Background; using Windows.ApplicationModel.Background;
using Windows.Storage; using Windows.Storage;
@@ -37,13 +38,11 @@ namespace FoxTube.Background
else else
lastCheck = DateTime.Parse(settings.Values["lastCheck"] as string); lastCheck = DateTime.Parse(settings.Values["lastCheck"] as string);
//ToastNotificationManager.CreateToastNotifier().Show(Notification.GetInternalToast(null, $"{DateTime.Now} Retrieving videos since", lastCheck.ToString(), null, null));
bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json"))); bool[] notificationsSettings = JsonConvert.DeserializeObject<bool[]>(await FileIO.ReadTextAsync(await ApplicationData.Current.RoamingFolder.GetFileAsync("notifications.json")));
if (notificationsSettings[0]) if (notificationsSettings[0])
CheckAnnouncements(); CheckAnnouncements();
if (notificationsSettings[1]) if (notificationsSettings[1])
CheckAccount(); await CheckAccount();
} }
catch { } catch { }
finally finally
@@ -53,7 +52,7 @@ namespace FoxTube.Background
} }
} }
async void CheckAccount() async Task CheckAccount()
{ {
try try
{ {
@@ -61,7 +60,7 @@ namespace FoxTube.Background
foreach (var s in subscriptions) foreach (var s in subscriptions)
{ {
SearchResource.ListRequest request = Service.Search.List("snippet"); SearchResource.ListRequest request = Service.Search.List("snippet");
request.PublishedAfter = lastCheck.Subtract(TimeSpan.FromDays(1)); request.PublishedAfter = lastCheck;
request.ChannelId = s.Key; request.ChannelId = s.Key;
request.Type = "video"; request.Type = "video";
request.MaxResults = 5; request.MaxResults = 5;
-18
View File
@@ -102,24 +102,6 @@ namespace FoxTube
Initialize(); Initialize();
} }
async void GetVideosFromToday()
{
foreach (Subscription i in SecretsVault.Subscriptions)
{
SearchResource.ListRequest request = SecretsVault.NoAuthService.Search.List("snippet");
request.PublishedAfter = DateTime.Now.Subtract(TimeSpan.FromDays(1));
Debug.WriteLine(DateTime.Now.Subtract(TimeSpan.FromDays(1)));
request.ChannelId = i.Snippet.ResourceId.ChannelId;
request.Type = "video";
request.MaxResults = 5;
SearchListResponse response = await request.ExecuteAsync();
foreach (SearchResult result in response.Items)
ToastNotificationManager.CreateToastNotifier().Show(
FoxTube.Background.Notification.GetVideoToast(result.Id.VideoId, result.Snippet.ChannelId, result.Snippet.Title, result.Snippet.ChannelTitle, result.Snippet.Thumbnails.Medium.Url, i.Snippet.Thumbnails.Medium.Url));
}
}
public async void Initialize() public async void Initialize()
{ {
bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] }; bool[] notificationsSettings = new bool[] { (bool)settings.Values["newVideoNotification"], (bool)settings.Values["devNews"] };