mirror of
https://github.com/zedeus/nitter
synced 2024-11-22 01:45:22 +01:00
Add enum hooks to log parseHook jsony errors
This commit is contained in:
parent
6a7e56b613
commit
da4d6eabdd
@ -82,6 +82,8 @@ proc parseUnifiedCard*(json: string): Card =
|
||||
component.parseMedia(card, result)
|
||||
of buttonGroup:
|
||||
discard
|
||||
of unknown:
|
||||
echo "ERROR: Unknown component type: ", json
|
||||
|
||||
case component.kind
|
||||
of twitterListDetails:
|
||||
|
@ -17,6 +17,7 @@ type
|
||||
twitterListDetails
|
||||
communityDetails
|
||||
mediaWithDetailsHorizontal
|
||||
unknown
|
||||
|
||||
Component* = object
|
||||
kind*: ComponentType
|
||||
@ -77,3 +78,28 @@ converter fromText*(text: Text): string = text.content
|
||||
proc renameHook*(v: var HasTypeField; fieldName: var string) =
|
||||
if fieldName == "type":
|
||||
fieldName = "kind"
|
||||
|
||||
proc enumHook*(s: string; v: var ComponentType) =
|
||||
v = case s
|
||||
of "details": details
|
||||
of "media": media
|
||||
of "swipeable_media": swipeableMedia
|
||||
of "button_group": buttonGroup
|
||||
of "app_store_details": appStoreDetails
|
||||
of "twitter_list_details": twitterListDetails
|
||||
of "community_details": communityDetails
|
||||
of "media_with_details_horizontal": mediaWithDetailsHorizontal
|
||||
else: echo "ERROR: Unknown enum value (ComponentType): ", s; unknown
|
||||
|
||||
proc enumHook*(s: string; v: var AppType) =
|
||||
v = case s
|
||||
of "android_app": androidApp
|
||||
of "iphone_app": iPhoneApp
|
||||
of "ipad_app": iPadApp
|
||||
else: echo "ERROR: Unknown enum value (AppType): ", s; androidApp
|
||||
|
||||
proc enumHook*(s: string; v: var MediaType) =
|
||||
v = case s
|
||||
of "video": video
|
||||
of "photo": photo
|
||||
else: echo "ERROR: Unknown enum value (MediaType): ", s; photo
|
||||
|
Loading…
Reference in New Issue
Block a user