Skip to content

Commit 867fc90

Browse files
authored
fix: add gifs (#13)
2 parents e608bff + 8fd9dad commit 867fc90

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/jsons/timeline.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ proc formatTweetAsJson*(tweet: Tweet): JsonNode =
6464
"card": if tweet.card.isSome: %*get(tweet.card) else: newJNull(),
6565
"poll": if tweet.poll.isSome: %*get(tweet.poll) else: newJNull(),
6666
"gif": if tweet.gif.isSome: %*get(tweet.gif) else: newJNull(),
67+
"gifs": if tweet.gifs.len > 0: %tweet.gifs else: newJNull(),
6768
"video": if tweet.video.isSome: %*get(tweet.video) else: newJNull(),
6869
"photos": if tweet.photos.len > 0: %tweet.photos else: newJNull()
6970
}

src/parser.nim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ proc parseTweet(js: JsonNode; jsCard: JsonNode = newJNull()): Tweet =
267267
else:
268268
result.attribution = some(parseGraphUser(user))
269269
of "animated_gif":
270-
result.gif = some(parseGif(m))
270+
let gif = parseGif(m)
271+
result.gif = some(gif)
272+
result.gifs.add gif
271273
else: discard
272274

273275
with url, m{"url"}:
@@ -400,6 +402,7 @@ proc parseGraphConversation*(js: JsonNode; tweetId: string; v2=true): Conversati
400402

401403
proc parseGraphTimeline*(js: JsonNode; root: string; after=""): Profile =
402404
result = Profile(tweets: Timeline(beginning: after.len == 0))
405+
echo "json str", js
403406

404407
let instructions =
405408
if root == "list": ? js{"data", "list", "timeline_response", "timeline", "instructions"}

src/types.nim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ type
212212
card*: Option[Card]
213213
poll*: Option[Poll]
214214
gif*: Option[Gif]
215+
gifs*: seq[Gif]
215216
video*: Option[Video]
216217
photos*: seq[string]
217218

0 commit comments

Comments
 (0)