nitter/src/types.nim

123 lines
2.3 KiB
Nim
Raw Normal View History

2019-06-20 18:04:18 +00:00
import times, sequtils, strutils, options
import norm/sqlite
2019-06-20 14:16:20 +00:00
2019-06-20 18:04:18 +00:00
export sqlite, options
db("cache.db", "", "", ""):
type
Profile* = object
username*: string
fullname*: string
2019-06-24 00:09:32 +00:00
bio*: string
2019-06-20 18:04:18 +00: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 14:16:20 +00:00
2019-06-20 18:04:18 +00:00
type
QueryType* = enum
replies, media, custom = "search"
Query* = object
filter*: seq[string]
exclude*: seq[string]
sep*: string
fromUser*: string
queryType*: QueryType
2019-06-25 05:37:44 +00:00
VideoType* = enum
2019-06-29 05:45:36 +00:00
vmap, m3u8, mp4
2019-06-25 05:37:44 +00:00
2019-06-24 03:14:14 +00:00
Video* = object
2019-06-29 05:45:36 +00:00
contentId*: string
playbackType*: VideoType
durationMs*: int
2019-06-24 03:14:14 +00:00
url*: string
thumb*: string
views*: string
available*: bool
Gif* = object
url*: string
thumb*: string
2019-06-29 12:11:23 +00:00
Poll* = object
options*: seq[string]
values*: seq[int]
votes*: string
status*: string
leader*: int
2019-06-24 06:07:36 +00:00
Quote* = object
2019-06-24 03:14:14 +00:00
id*: string
profile*: Profile
text*: string
reply*: seq[string]
hasThread*: bool
2019-06-25 00:58:33 +00:00
sensitive*: bool
thumb*: string
badge*: string
2019-06-24 03:14:14 +00:00
2019-07-01 21:22:00 +00:00
Retweet* = object
by*: string
id*: string
2019-07-01 21:48:25 +00:00
TweetStats* = object
replies*: string
retweets*: string
likes*: string
2019-06-24 03:14:14 +00:00
Tweet* = ref object
2019-06-20 14:16:20 +00:00
id*: string
profile*: Profile
text*: string
time*: Time
shortTime*: string
reply*: seq[string]
2019-06-20 14:16:20 +00:00
pinned*: bool
available*: bool
hasThread*: bool
2019-07-01 21:48:25 +00:00
stats*: TweetStats
2019-07-01 21:22:00 +00:00
retweet*: Option[Retweet]
2019-06-24 03:14:14 +00:00
quote*: Option[Quote]
gif*: Option[Gif]
video*: Option[Video]
photos*: seq[string]
2019-06-29 12:11:23 +00:00
poll*: Option[Poll]
2019-06-20 14:16:20 +00:00
Thread* = ref object
2019-07-01 01:13:12 +00:00
tweets*: seq[Tweet]
more*: int
2019-06-20 14:16:20 +00:00
2019-06-24 03:14:14 +00:00
Conversation* = ref object
2019-06-20 14:16:20 +00:00
tweet*: Tweet
2019-07-01 01:13:12 +00:00
before*: Thread
after*: Thread
replies*: seq[Thread]
2019-06-20 14:16:20 +00:00
Timeline* = ref object
2019-07-01 01:13:12 +00:00
tweets*: seq[Tweet]
minId*: string
maxId*: string
hasMore*: bool
query*: Option[Query]
2019-07-01 01:13:12 +00:00
proc contains*(thread: Thread; tweet: Tweet): bool =
thread.tweets.anyIt(it.id == tweet.id)