nitter/src/types.nim

146 lines
2.8 KiB
Nim
Raw Normal View History

2019-06-20 19:04:18 +01:00
import times, sequtils, strutils, options
import norm/sqlite
2019-06-20 15:16:20 +01:00
2019-06-20 19:04:18 +01:00
export sqlite, options
db("cache.db", "", "", ""):
type
Profile* = object
username*: string
fullname*: string
2019-06-24 01:09:32 +01:00
bio*: string
2019-06-20 19:04:18 +01:00
userpic*: string
banner*: string
following*: string
followers*: string
tweets*: string
verified* {.
dbType: "STRING",
parseIt: parseBool(it.s)
formatIt: $it
.}: bool
protected* {.
dbType: "STRING",
parseIt: parseBool(it.s)
formatIt: $it
.}: bool
updated* {.
dbType: "INTEGER",
parseIt: it.i.fromUnix(),
formatIt: getTime().toUnix()
.}: Time
2019-06-20 15:16:20 +01:00
2019-06-20 19:04:18 +01:00
type
2019-07-11 18:22:23 +01:00
QueryKind* = enum
replies, media, custom = "search"
Query* = object
2019-07-11 18:22:23 +01:00
kind*: QueryKind
2019-07-04 10:55:19 +01:00
filters*: seq[string]
includes*: seq[string]
excludes*: seq[string]
fromUser*: string
sep*: string
2019-06-25 06:37:44 +01:00
VideoType* = enum
2019-06-29 06:45:36 +01:00
vmap, m3u8, mp4
2019-06-25 06:37:44 +01:00
2019-06-24 04:14:14 +01:00
Video* = object
2019-06-29 06:45:36 +01:00
contentId*: string
playbackType*: VideoType
durationMs*: int
2019-06-24 04:14:14 +01:00
url*: string
thumb*: string
views*: string
available*: bool
Gif* = object
url*: string
thumb*: string
2019-07-04 03:18:32 +01:00
GalleryPhoto* = object
url*: string
tweetId*: string
color*: string
2019-06-29 13:11:23 +01:00
Poll* = object
options*: seq[string]
values*: seq[int]
votes*: string
status*: string
leader*: int
2019-07-11 18:22:23 +01:00
CardKind* = enum
summary, summaryLarge, liveEvent, player, promoWebsite
Card* = object
kind*: CardKind
id*: string
query*: string
url*: string
title*: string
dest*: string
text*: string
image*: string
2019-06-24 07:07:36 +01:00
Quote* = object
2019-06-24 04:14:14 +01:00
id*: string
profile*: Profile
text*: string
reply*: seq[string]
hasThread*: bool
2019-06-25 01:58:33 +01:00
sensitive*: bool
2019-07-04 03:38:23 +01:00
available*: bool
thumb*: string
badge*: string
2019-06-24 04:14:14 +01:00
2019-07-01 22:22:00 +01:00
Retweet* = object
by*: string
id*: string
2019-07-01 22:48:25 +01:00
TweetStats* = object
replies*: string
retweets*: string
likes*: string
2019-06-24 04:14:14 +01:00
Tweet* = ref object
2019-06-20 15:16:20 +01:00
id*: string
threadId*: string
2019-06-20 15:16:20 +01:00
profile*: Profile
text*: string
time*: Time
shortTime*: string
reply*: seq[string]
2019-06-20 15:16:20 +01:00
pinned*: bool
available*: bool
hasThread*: bool
2019-07-01 22:48:25 +01:00
stats*: TweetStats
2019-07-01 22:22:00 +01:00
retweet*: Option[Retweet]
2019-06-24 04:14:14 +01:00
quote*: Option[Quote]
2019-07-11 18:22:23 +01:00
card*: Option[Card]
2019-06-24 04:14:14 +01:00
gif*: Option[Gif]
video*: Option[Video]
photos*: seq[string]
2019-06-29 13:11:23 +01:00
poll*: Option[Poll]
2019-06-20 15:16:20 +01:00
Thread* = ref object
2019-07-01 02:13:12 +01:00
tweets*: seq[Tweet]
more*: int
2019-06-20 15:16:20 +01:00
2019-06-24 04:14:14 +01:00
Conversation* = ref object
2019-06-20 15:16:20 +01:00
tweet*: Tweet
2019-07-01 02:13:12 +01:00
before*: Thread
after*: Thread
replies*: seq[Thread]
2019-06-20 15:16:20 +01:00
Timeline* = ref object
2019-07-01 02:13:12 +01:00
tweets*: seq[Tweet]
minId*: string
maxId*: string
hasMore*: bool
beginning*: bool
query*: Option[Query]
2019-07-01 02:13:12 +01:00
proc contains*(thread: Thread; tweet: Tweet): bool =
thread.tweets.anyIt(it.id == tweet.id)