Feedback hub removed, Subscription page development, changelog notifications
This commit is contained in:
@@ -32,7 +32,6 @@ namespace FoxTube.Background
|
||||
ClientId = "349735264870-2ekqlm0a4mkg3mmrfcv90s3qp3o15dq0.apps.googleusercontent.com",
|
||||
ClientSecret = "BkVZOAaCU2Zclf0Zlicg6y2_"
|
||||
};
|
||||
|
||||
private YouTubeService Service => new YouTubeService(new BaseClientService.Initializer()
|
||||
{
|
||||
ApiKey = "AIzaSyBgHrCnrlzlVmk0cJKL8RqP9Y8x6XSuk_0",
|
||||
@@ -41,6 +40,7 @@ namespace FoxTube.Background
|
||||
|
||||
XmlDocument doc = new XmlDocument();
|
||||
BackgroundTaskDeferral def;
|
||||
|
||||
public void Run(IBackgroundTaskInstance taskInstance)
|
||||
{
|
||||
def = taskInstance.GetDeferral();
|
||||
@@ -48,16 +48,17 @@ namespace FoxTube.Background
|
||||
settings.Values.Add("lastCheck", XmlConvert.ToString(DateTime.Now, "YYYY-MM-DDThh:mm:ss"));
|
||||
else lastCheck = XmlConvert.ToDateTime(settings.Values["lastCheck"] as string, XmlDateTimeSerializationMode.Unspecified);
|
||||
|
||||
if (settings.Values["notificationsHistory"] != null)
|
||||
doc.LoadXml(settings.Values["notificationsHistory"] as string);
|
||||
else
|
||||
try
|
||||
{
|
||||
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||
doc.AppendChild(doc.CreateElement("history"));
|
||||
settings.Values.Add("notificationsHistory", doc.InnerXml);
|
||||
doc.LoadXml(settings.Values["notificationsHistory"] as string);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CheckAnnouncements();
|
||||
CheckAccount();
|
||||
|
||||
SendNSave();
|
||||
|
||||
@@ -78,36 +79,37 @@ namespace FoxTube.Background
|
||||
subRequest.Mine = true;
|
||||
subRequest.MaxResults = 50;
|
||||
SubscriptionListResponse subResponse = await subRequest.ExecuteAsync();
|
||||
List<KeyValuePair<string, string>> subs = new List<KeyValuePair<string, string>>();
|
||||
Dictionary<string, string> subs = new Dictionary<string, string>();
|
||||
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||
subs.Add(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url);
|
||||
|
||||
string nextToken = subResponse.NextPageToken;
|
||||
while (nextToken != null)
|
||||
{
|
||||
subRequest.PageToken = nextToken;
|
||||
subResponse = await subRequest.ExecuteAsync();
|
||||
nextToken = subResponse.NextPageToken;
|
||||
|
||||
foreach (Subscription s in subResponse.Items)
|
||||
subs.Add(new KeyValuePair<string, string>(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url));
|
||||
subs.Add(s.Snippet.ResourceId.ChannelId, s.Snippet.Thumbnails.Standard.Url);
|
||||
}
|
||||
|
||||
foreach(var s in subs)
|
||||
{
|
||||
var request = Service.Search.List("snippet");
|
||||
SearchResource.ListRequest request = Service.Search.List("snippet");
|
||||
request.PublishedAfter = lastCheck;
|
||||
request.ChannelId = s.Key;
|
||||
request.Type = "video";
|
||||
var response = await request.ExecuteAsync();
|
||||
SearchListResponse response = await request.ExecuteAsync();
|
||||
|
||||
if(response.Items.Count > 0)
|
||||
foreach (var a in response.Items)
|
||||
Notifications.Add(new Notification("video", a.Id.VideoId,
|
||||
a.Snippet.ChannelTitle,
|
||||
a.Snippet.Title,
|
||||
a.Snippet.PublishedAt.Value,
|
||||
a.Snippet.Thumbnails.Standard.Url,
|
||||
s.Value));
|
||||
foreach (var i in response.Items)
|
||||
Notifications.Add(new Notification("video", i.Id.VideoId,
|
||||
i.Snippet.ChannelTitle,
|
||||
i.Snippet.Title,
|
||||
i.Snippet.PublishedAt.Value,
|
||||
i.Snippet.Thumbnails.Standard.Url,
|
||||
s.Value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,10 +119,10 @@ namespace FoxTube.Background
|
||||
doc.Load(XmlReader.Create("http://foxgame.hol.es/foxtube-messages.xml"));
|
||||
if ((XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss") - lastCheck.ToUniversalTime()).TotalSeconds > 0)
|
||||
Notifications.Add(new Notification("internal", (doc["posts"].FirstChild as XmlElement).GetAttribute("id"),
|
||||
doc["posts"].FirstChild["header"].InnerText,
|
||||
doc["posts"].FirstChild["notificationHeader"].InnerText,
|
||||
doc["posts"].FirstChild["content"].InnerText,
|
||||
XmlConvert.ToDateTimeOffset((doc["posts"].FirstChild as XmlElement).GetAttribute("time"), "YYYY-MM-DDThh:mm:ss"),
|
||||
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), null));
|
||||
(doc["posts"].FirstChild as XmlElement).GetAttribute("image"), (doc["posts"].FirstChild as XmlElement).GetAttribute("avatar")));
|
||||
}
|
||||
|
||||
void SendNotification(Notification notification)
|
||||
|
||||
Reference in New Issue
Block a user