@@ -289,23 +289,6 @@ proc parseTweet(js: JsonNode; jsCard: JsonNode = newJNull()): Tweet =
289289 result .text.removeSuffix (" Learn more." )
290290 result .available = false
291291
292- proc parsePhotoRail * (js: JsonNode ): PhotoRail =
293- with error, js{" error" }:
294- if error.getStr == " Not authorized." :
295- return
296-
297- for tweet in js:
298- let
299- t = parseTweet (tweet, js{" tweet_card" })
300- url = if t.photos.len > 0 : t.photos[0 ]
301- elif t.video.isSome: get (t.video).thumb
302- elif t.gif.isSome: get (t.gif).thumb
303- elif t.card.isSome: get (t.card).image
304- else : " "
305-
306- if url.len == 0 : continue
307- result .add GalleryPhoto (url: url, tweetId: $ t.id)
308-
309292proc parseGraphTweet (js: JsonNode ; isLegacy= false ): Tweet =
310293 if js.kind == JNull :
311294 return Tweet ()
@@ -445,6 +428,34 @@ proc parseGraphTimeline*(js: JsonNode; root: string; after=""): Profile =
445428 tweet.id = parseBiggestInt (entryId)
446429 result .pinned = some tweet
447430
431+ proc parseGraphPhotoRail * (js: JsonNode ): PhotoRail =
432+ result = @ []
433+
434+ let instructions =
435+ ? js{" data" , " user_result" , " result" , " timeline_response" , " timeline" , " instructions" }
436+
437+ for i in instructions:
438+ if i{" __typename" }.getStr == " TimelineAddEntries" :
439+ for e in i{" entries" }:
440+ let entryId = e{" entryId" }.getStr
441+ if entryId.startsWith (" tweet" ):
442+ with tweetResult, e{" content" , " content" , " tweetResult" , " result" }:
443+ let t = parseGraphTweet (tweetResult, false )
444+ if not t.available:
445+ t.id = parseBiggestInt (entryId.getId ())
446+
447+ let url =
448+ if t.photos.len > 0 : t.photos[0 ]
449+ elif t.video.isSome: get (t.video).thumb
450+ elif t.gif.isSome: get (t.gif).thumb
451+ elif t.card.isSome: get (t.card).image
452+ else : " "
453+
454+ result .add GalleryPhoto (url: url, tweetId: $ t.id)
455+
456+ if result .len == 16 :
457+ break
458+
448459proc parseGraphSearch * [T: User | Tweets ](js: JsonNode ; after= " " ): Result [T] =
449460 result = Result [T](beginning: after.len == 0 )
450461
0 commit comments