nitter/src/types.nim

94 lines
1.8 KiB
Nim
Raw Normal View History

2019-06-20 20:04:18 +02:00
import times, sequtils, strutils, options
import norm/sqlite
2019-06-20 16:16:20 +02:00
2019-06-20 20:04:18 +02:00
export sqlite, options
db("cache.db", "", "", ""):
type
Profile* = object
username*: string
fullname*: string
2019-06-24 02:09:32 +02:00
bio*: string
2019-06-20 20:04:18 +02: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 16:16:20 +02:00
2019-06-20 20:04:18 +02:00
type
2019-06-25 07:37:44 +02:00
VideoType* = enum
vmap, m3u8
2019-06-24 05:14:14 +02:00
Video* = object
2019-06-25 07:37:44 +02:00
contentType*: VideoType
2019-06-24 05:14:14 +02:00
url*: string
thumb*: string
2019-06-25 07:37:44 +02:00
id*: string
2019-06-24 05:14:14 +02:00
views*: string
2019-06-25 07:37:44 +02:00
length*: int
2019-06-24 05:14:14 +02:00
available*: bool
Gif* = object
url*: string
thumb*: string
2019-06-24 08:07:36 +02:00
Quote* = object
2019-06-24 05:14:14 +02:00
id*: string
profile*: Profile
link*: string
text*: string
2019-06-25 02:58:33 +02:00
sensitive*: bool
2019-06-24 08:07:36 +02:00
thumb*: Option[string]
badge*: Option[string]
2019-06-24 05:14:14 +02:00
Tweet* = ref object
2019-06-20 16:16:20 +02:00
id*: string
profile*: Profile
link*: string
text*: string
time*: Time
shortTime*: string
replies*: string
retweets*: string
likes*: string
pinned*: bool
2019-06-24 05:14:14 +02:00
quote*: Option[Quote]
2019-06-20 20:04:18 +02:00
retweetBy*: Option[string]
retweetId*: Option[string]
2019-06-24 05:14:14 +02:00
gif*: Option[Gif]
video*: Option[Video]
photos*: seq[string]
2019-06-26 21:06:42 +02:00
available*: bool
2019-06-20 16:16:20 +02:00
Tweets* = seq[Tweet]
2019-06-24 05:14:14 +02:00
Conversation* = ref object
2019-06-20 16:16:20 +02:00
tweet*: Tweet
before*: Tweets
after*: Tweets
replies*: seq[Tweets]
Timeline* = ref object
tweets*: Tweets
minId*: string
maxId*: string
hasMore*: bool
2019-06-20 16:16:20 +02:00
proc contains*(thread: Tweets; tweet: Tweet): bool =
thread.anyIt(it.id == tweet.id)