From 68136de07bfe3ac4ac5f74b0735aa3b9a4849247 Mon Sep 17 00:00:00 2001 From: jackyzy823 Date: Sat, 20 Nov 2021 22:12:33 +0000 Subject: [PATCH] add new card kind, and do not raise error for unknown card kind (#467) --- src/parser.nim | 4 ++-- src/types.nim | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/parser.nim b/src/parser.nim index fffb3c9..de00e20 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -169,7 +169,7 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card = let vals = ? js{"binding_values"} name = js{"name"}.getStr - kind = parseEnum[CardKind](name[(name.find(":") + 1) ..< name.len]) + kind = parseEnum[CardKind](name[(name.find(":") + 1) ..< name.len], unknown) result = Card( kind: kind, @@ -195,7 +195,7 @@ proc parseCard(js: JsonNode; urls: JsonNode): Card = result.url = vals{"player_url"}.getStrVal if "youtube.com" in result.url: result.url = result.url.replace("/embed/", "/watch?v=") - of unified: + of unified, unknown: result.title = "This card type is not supported." else: discard diff --git a/src/types.nim b/src/types.nim index d405e26..d3e2fff 100644 --- a/src/types.nim +++ b/src/types.nim @@ -126,6 +126,8 @@ type videoDirectMessage = "video_direct_message" imageDirectMessage = "image_direct_message" audiospace = "audiospace" + newsletter_publication = "newsletter_publication" + unknown Card* = object kind*: CardKind