diff --git a/Pages/Conference.cshtml b/Pages/Conference.cshtml
index 8cf3e53..cac37c8 100644
--- a/Pages/Conference.cshtml
+++ b/Pages/Conference.cshtml
@@ -13,6 +13,9 @@
ViewData["Title"] = Request.Query["c"];
var wc = new WebClient();
var conference = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]);
+ if (conference.Ongoing) {
+ c3stream.UpdateConference(conference);
+ }
wc.Dispose();
}
@@ -35,8 +38,7 @@
var isWatched = state == "watched";
var isMarked = state == "marked";
var file = $"{talk.Slug}.mp4";
- var tagV = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]).TagVersion;
- var eventName = tagV == 0 ? conference.Acronym : talk.Tags[0].Replace("-", "-
");
+ var eventName = talk.Tags.Count > 1 ? conference.Acronym : talk.Tags[0].Replace("-", "-
");
var category = talk.Tags.Count switch {
0 => "",
1 => talk.Tags[0],
diff --git a/Pages/Conference.cshtml.cs b/Pages/Conference.cshtml.cs
index d9c9355..a757866 100644
--- a/Pages/Conference.cshtml.cs
+++ b/Pages/Conference.cshtml.cs
@@ -39,9 +39,8 @@ namespace c3stream.Pages {
}
public static void WriteUserData() {
- lock (c3stream.Lock) {
+ lock (c3stream.Lock)
System.IO.File.WriteAllText(c3stream.DbPath, JsonConvert.SerializeObject(UserData));
- }
}
public class UserStatus {
diff --git a/Pages/Info.cshtml b/Pages/Info.cshtml
index ce7a77a..f8354ca 100644
--- a/Pages/Info.cshtml
+++ b/Pages/Info.cshtml
@@ -34,8 +34,7 @@
var file = $"{talk.Slug}.mp4";
var conference = c3stream.GetConferenceByEventGuid(talk.Guid);
- var tagV = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]).TagVersion;
- var eventName = tagV == 0 ? conference.Acronym : talk.Tags[0].Replace("-", "-
");
+ var eventName = talk.Tags.Count > 1 ? conference.Acronym : talk.Tags[0].Replace("-", "-
");
var category = talk.Tags.Count switch {
0 => "",
diff --git a/c3stream.cs b/c3stream.cs
index 4a8ad6d..8312cae 100644
--- a/c3stream.cs
+++ b/c3stream.cs
@@ -18,10 +18,10 @@ namespace c3stream {
public static string DbPath = Path.Combine(DataPath, DbFile);
public static List Conferences = new List {
- new ConferenceObject("36c3", 2, true),
+ new ConferenceObject("36c3", true),
new ConferenceObject("camp2019"),
- new ConferenceObject("35c3", 1),
- new ConferenceObject("34c3", 1),
+ new ConferenceObject("35c3"),
+ new ConferenceObject("34c3"),
new ConferenceObject("33c3"),
new ConferenceObject("32c3"),
new ConferenceObject("31c3"),
@@ -34,22 +34,8 @@ namespace c3stream {
if (!File.Exists(DbPath))
ConferenceModel.WriteUserData();
- using var wc = new WebClient();
-
- foreach (var conference in Conferences) {
- var jsonpath = Path.Combine(DataPath, conference.Acronym + "_index.json");
- var json = "";
- if (conference.Ongoing || !File.Exists(jsonpath)) {
- json = wc.DownloadString($"https://api.media.ccc.de/public/conferences/{conference.Acronym}");
- File.WriteAllText(jsonpath, json);
- }
- else {
- json = File.ReadAllText(jsonpath);
- }
-
- var parsed = Conference.FromJson(json);
- conference.Talks.AddRange(parsed.Events);
- }
+ foreach (var conference in Conferences)
+ UpdateConference(conference);
if (args.Length != 0) {
if (Conferences.All(p => p.Acronym != args[0]))
@@ -63,6 +49,29 @@ namespace c3stream {
}
}
+ public static void UpdateConference(ConferenceObject conference) {
+ using var wc = new WebClient();
+
+ var jsonpath = Path.Combine(DataPath, conference.Acronym + "_index.json");
+ var json = "";
+ if (!File.Exists(jsonpath)) {
+ json = wc.DownloadString($"https://api.media.ccc.de/public/conferences/{conference.Acronym}");
+ File.WriteAllText(jsonpath, json);
+ }
+ else if (conference.Ongoing) {
+ json = wc.DownloadString($"https://api.media.ccc.de/public/conferences/{conference.Acronym}");
+ }
+ else {
+ json = File.ReadAllText(jsonpath);
+ }
+
+ var parsed = Conference.FromJson(json);
+ lock (Lock) {
+ conference.Talks.Clear();
+ conference.Talks.AddRange(parsed.Events);
+ }
+ }
+
public static void UpdateCookie(HttpRequest resquest, HttpResponse response, string redirectUri) {
//if new bookmark is in uri
if (resquest.Query.ContainsKey("bookmark") && resquest.Cookies["bookmark"] != resquest.Query["bookmark"]) {
@@ -95,13 +104,11 @@ namespace c3stream {
public class ConferenceObject {
public string Acronym;
public bool Ongoing;
- public int TagVersion;
public List Talks = new List();
- public ConferenceObject(string acronym, int tagVersion = 0, bool ongoing = false) {
- Acronym = acronym;
- TagVersion = tagVersion;
- Ongoing = ongoing;
+ public ConferenceObject(string acronym, bool ongoing = false) {
+ Acronym = acronym;
+ Ongoing = ongoing;
}
}
}