diff --git a/scraper/src/Models/Station.cs b/scraper/src/Models/Station.cs index 7752742..8682eef 100644 --- a/scraper/src/Models/Station.cs +++ b/scraper/src/Models/Station.cs @@ -38,6 +38,7 @@ namespace InfoferScraper.Models.Station { public interface IStationStatus : IStatus { new int Delay { get; } new bool Real { get; } + public bool Cancelled { get; } public string? Platform { get; } } @@ -102,6 +103,7 @@ namespace InfoferScraper.Models.Station { internal record StationStatus : IStationStatus { public int Delay { get; internal set; } public bool Real { get; internal set; } + public bool Cancelled { get; internal set; } public string? Platform { get; internal set; } } diff --git a/scraper/src/Scrapers/Station.cs b/scraper/src/Scrapers/Station.cs index 1f3dd3e..4ebe5c6 100644 --- a/scraper/src/Scrapers/Station.cs +++ b/scraper/src/Scrapers/Station.cs @@ -170,8 +170,16 @@ namespace InfoferScraper.Scrapers { .Text() .WithCollapsedSpaces() ).Groups as IEnumerable).Skip(1).Select(group => group.Value); - arrDep.ModifyableStatus.Real = string.IsNullOrEmpty(approx); - arrDep.ModifyableStatus.Delay = delayMin.Length == 0 ? 0 : int.Parse(delayMin); + if (delayMin is null && delayDiv.Text().WithCollapsedSpaces() == "anulat") { + arrDep.ModifyableStatus.Cancelled = true; + } + else if (delayMin is null) { + throw new Exception($"Unexpected delayDiv value: {delayDiv.Text().WithCollapsedSpaces()}"); + } + else { + arrDep.ModifyableStatus.Real = string.IsNullOrEmpty(approx); + arrDep.ModifyableStatus.Delay = delayMin.Length == 0 ? 0 : int.Parse(delayMin); + } if (statusDivComponents.Length < 2) return; diff --git a/scraper/src/Utils/RoLettersToEn.cs b/scraper/src/Utils/RoLettersToEn.cs index a3c75d4..7cc821f 100644 --- a/scraper/src/Utils/RoLettersToEn.cs +++ b/scraper/src/Utils/RoLettersToEn.cs @@ -1,24 +1,23 @@ using System.Collections.Generic; using System.Linq; -using System.Runtime.InteropServices.ComTypes; -namespace InfoferScraper { - public static partial class Utils { - private static readonly Dictionary RoToEn = new() { - { 'ă', 'a' }, - { 'Ă', 'A' }, - { 'â', 'a' }, - { 'Â', 'A' }, - { 'î', 'i' }, - { 'Î', 'I' }, - { 'ș', 's' }, - { 'Ș', 'S' }, - { 'ț', 't' }, - { 'Ț', 'T' }, - }; +namespace InfoferScraper; - public static string RoLettersToEn(this string str) { - return string.Concat(str.Select(letter => RoToEn.GetValueOrDefault(letter, letter))); - } +public static partial class Utils { + private static readonly Dictionary RoToEn = new() { + { 'ă', 'a' }, + { 'Ă', 'A' }, + { 'â', 'a' }, + { 'Â', 'A' }, + { 'î', 'i' }, + { 'Î', 'I' }, + { 'ș', 's' }, + { 'Ș', 'S' }, + { 'ț', 't' }, + { 'Ț', 'T' }, + }; + + public static string RoLettersToEn(this string str) { + return string.Concat(str.Select(letter => RoToEn.GetValueOrDefault(letter, letter))); } -} \ No newline at end of file +}