From 7d123e9452d4a9d4f107c46a05c18c1a99f0cd29 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 4 Jan 2020 15:10:32 +0100 Subject: [PATCH] small updates, add cache link generator --- Pages/Conference.cshtml | 17 ++++++++++------- Pages/Info.cshtml | 17 +++++++++++------ c3stream.cs | 27 ++++++++++++++++++++------- 3 files changed, 41 insertions(+), 20 deletions(-) diff --git a/Pages/Conference.cshtml b/Pages/Conference.cshtml index 7bc354c..8cf3e53 100644 --- a/Pages/Conference.cshtml +++ b/Pages/Conference.cshtml @@ -37,11 +37,14 @@ 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 category = tagV switch { - 0 => talk.Tags[0], - 1 => talk.Tags[2], - 2 => talk.Tags[3], - _ => "" + var category = talk.Tags.Count switch { + 0 => "", + 1 => talk.Tags[0], + 2 => "", + 3 => talk.Tags[2], + 4 => talk.Tags[3], + 5 => talk.Tags[3], + _ => "" }; @Html.Raw(eventName) @@ -56,7 +59,7 @@ else { @talk.Title } - @talk.Persons.Aggregate((s, s1) => $"{s}, {s1}") + @(talk.Persons.Any() ? talk.Persons.Aggregate((s, s1) => $"{s}, {s1}") : "") @talk.OriginalLanguage
@@ -73,7 +76,7 @@ } - + @if (isWatched) { diff --git a/Pages/Info.cshtml b/Pages/Info.cshtml index 497facd..ce7a77a 100644 --- a/Pages/Info.cshtml +++ b/Pages/Info.cshtml @@ -33,13 +33,18 @@ var isMarked = state == "marked"; var file = $"{talk.Slug}.mp4"; var conference = c3stream.GetConferenceByEventGuid(talk.Guid); - var eventName = talk.Tags[0].Replace("-", "-
"); - var category = c3stream.GetConferenceByEventGuid(Request.Query["guid"]).TagVersion switch { - 0 => talk.Tags[0], - 1 => talk.Tags[2], - 2 => talk.Tags[3], - _ => "" + var tagV = c3stream.Conferences.First(c => c.Acronym == Request.Query["c"]).TagVersion; + var eventName = tagV == 0 ? conference.Acronym : talk.Tags[0].Replace("-", "-
"); + + var category = talk.Tags.Count switch { + 0 => "", + 1 => talk.Tags[0], + 2 => "", + 3 => talk.Tags[2], + 4 => talk.Tags[3], + 5 => talk.Tags[3], + _ => "" }; } diff --git a/c3stream.cs b/c3stream.cs index 41aedfc..4a8ad6d 100644 --- a/c3stream.cs +++ b/c3stream.cs @@ -10,18 +10,22 @@ using Microsoft.Extensions.Hosting; namespace c3stream { public static class c3stream { - public const string DataPath = "data"; - public const string DbFile = "c3stream.user.json"; - public const string CachePath = "/mnt/storage/archive/Video/congress/"; - public const string CacheUrl = "https://mirror.c3stream.de/"; - public static object Lock = new object(); - public static string DbPath = Path.Combine(DataPath, DbFile); + public const string DataPath = "data"; + public const string DbFile = "c3stream.user.json"; + public const string CachePath = "/mnt/storage/archive/Video/congress/"; + public const string CacheUrl = "https://mirror.c3stream.de/"; + public static object Lock = new object(); + public static string DbPath = Path.Combine(DataPath, DbFile); + public static List Conferences = new List { new ConferenceObject("36c3", 2, true), + new ConferenceObject("camp2019"), new ConferenceObject("35c3", 1), new ConferenceObject("34c3", 1), new ConferenceObject("33c3"), new ConferenceObject("32c3"), + new ConferenceObject("31c3"), + new ConferenceObject("30c3") }; public static void Main(string[] args) { @@ -47,7 +51,16 @@ namespace c3stream { conference.Talks.AddRange(parsed.Events); } - CreateHostBuilder(args).Build().Run(); + if (args.Length != 0) { + if (Conferences.All(p => p.Acronym != args[0])) + Console.WriteLine("No matching conference found."); + else + foreach (var talk in Conferences.First(p => p.Acronym == args[0]).Talks) + Console.WriteLine($"youtube-dl -f \"best[ext = mp4]\" {talk.FrontendLink} -o \"{Path.Combine(CachePath, args[0], talk.Slug)}.mp4\""); + } + else { + CreateHostBuilder(args).Build().Run(); + } } public static void UpdateCookie(HttpRequest resquest, HttpResponse response, string redirectUri) {