nitter/src/types.nim

184 lines
3.6 KiB
Nim
Raw Normal View History

2019-08-11 21:26:37 +02:00
import times, sequtils, options
2019-06-20 20:04:18 +02:00
import norm/sqlite
2019-06-20 16:16:20 +02:00
2019-09-08 13:01:20 +02:00
import prefs_impl
2019-06-20 20:04:18 +02:00
export sqlite, options
2019-08-06 19:02:38 +02:00
type
VideoType* = enum
vmap, m3u8, mp4
2019-09-08 12:22:52 +02:00
dbTypes:
2019-06-20 20:04:18 +02:00
type
Profile* = object
username*: string
fullname*: string
location*: string
website*: 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
likes*: string
2019-08-11 23:24:02 +02:00
media*: string
2019-08-15 22:44:59 +02:00
verified*: bool
protected*: bool
joinDate* {.
2019-08-13 19:44:29 +02:00
dbType: "INTEGER"
parseIt: it.i.fromUnix()
2019-08-15 22:44:59 +02:00
formatIt: dbValue(it.toUnix())
.}: Time
2019-06-20 20:04:18 +02:00
updated* {.
2019-08-13 19:44:29 +02:00
dbType: "INTEGER"
parseIt: it.i.fromUnix()
2019-08-15 22:44:59 +02:00
formatIt: dbValue(getTime().toUnix())
2019-06-20 20:04:18 +02:00
.}: Time
2019-06-20 16:16:20 +02:00
2019-08-06 19:02:38 +02:00
Video* = object
videoId*: string
contentId*: string
durationMs*: int
url*: string
thumb*: string
views*: string
2019-08-15 22:44:59 +02:00
available*: bool
2019-08-19 22:03:00 +02:00
reason*: string
2019-08-06 19:02:38 +02:00
playbackType* {.
dbType: "STRING"
parseIt: parseEnum[VideoType](it.s)
2019-08-15 22:44:59 +02:00
formatIt: dbValue($it)
2019-08-06 19:02:38 +02:00
.}: VideoType
2019-09-08 13:01:20 +02:00
genPrefsType()
2019-09-08 12:22:52 +02:00
dbFromTypes("cache.db", "", "", "", [Profile, Video])
2019-06-20 20:04:18 +02:00
type
2019-07-11 19:22:23 +02:00
QueryKind* = enum
posts, replies, media, users, tweets, userList
Query* = object
2019-07-11 19:22:23 +02:00
kind*: QueryKind
2019-09-13 13:20:08 +02:00
text*: string
2019-07-04 11:55:19 +02:00
filters*: seq[string]
includes*: seq[string]
excludes*: seq[string]
2019-08-06 17:41:06 +02:00
fromUser*: seq[string]
2019-09-19 22:11:38 +02:00
since*: string
until*: string
2019-09-19 23:36:21 +02:00
near*: string
2019-07-04 11:55:19 +02:00
sep*: string
2019-08-23 02:15:25 +02:00
Result*[T] = ref object
content*: seq[T]
minId*: string
maxId*: string
hasMore*: bool
beginning*: bool
2019-09-19 02:23:22 +02:00
query*: Query
2019-08-23 02:15:25 +02:00
2019-06-24 05:14:14 +02:00
Gif* = object
url*: string
thumb*: string
2019-07-04 04:18:32 +02:00
GalleryPhoto* = object
url*: string
tweetId*: string
color*: string
2019-06-29 14:11:23 +02:00
Poll* = object
options*: seq[string]
values*: seq[int]
votes*: string
status*: string
leader*: int
2019-07-11 19:22:23 +02:00
CardKind* = enum
2019-07-15 16:03:01 +02:00
summary = "summary"
summaryLarge = "summary_large_image"
promoWebsite = "promo_website"
promoVideo = "promo_video_website"
player = "player"
liveEvent = "live_event"
2019-07-11 19:22:23 +02:00
Card* = object
kind*: CardKind
id*: string
query*: string
url*: string
title*: string
dest*: string
text*: string
2019-07-15 16:03:01 +02:00
image*: Option[string]
video*: Option[Video]
2019-07-11 19:22:23 +02:00
2019-06-24 08:07:36 +02:00
Quote* = object
id*: int
2019-06-24 05:14:14 +02:00
profile*: Profile
text*: string
reply*: seq[string]
hasThread*: bool
2019-06-25 02:58:33 +02:00
sensitive*: bool
2019-07-04 04:38:23 +02:00
available*: bool
tombstone*: string
thumb*: string
badge*: string
2019-06-24 05:14:14 +02:00
2019-07-01 23:22:00 +02:00
Retweet* = object
by*: string
id*: int
2019-07-01 23:22:00 +02:00
2019-07-01 23:48:25 +02:00
TweetStats* = object
replies*: string
retweets*: string
likes*: string
2019-06-24 05:14:14 +02:00
Tweet* = ref object
id*: int
threadId*: int
2019-06-20 16:16:20 +02:00
profile*: Profile
text*: string
time*: Time
shortTime*: string
reply*: seq[string]
2019-06-20 16:16:20 +02:00
pinned*: bool
hasThread*: bool
available*: bool
tombstone*: string
2019-07-01 23:48:25 +02:00
stats*: TweetStats
2019-07-01 23:22:00 +02:00
retweet*: Option[Retweet]
2019-06-24 05:14:14 +02:00
quote*: Option[Quote]
2019-07-11 19:22:23 +02:00
card*: Option[Card]
2019-06-24 05:14:14 +02:00
gif*: Option[Gif]
video*: Option[Video]
photos*: seq[string]
2019-06-29 14:11:23 +02:00
poll*: Option[Poll]
2019-06-20 16:16:20 +02:00
Chain* = ref object
2019-08-23 02:15:25 +02:00
content*: seq[Tweet]
2019-07-01 03:13:12 +02:00
more*: int
2019-06-20 16:16:20 +02:00
2019-06-24 05:14:14 +02:00
Conversation* = ref object
2019-06-20 16:16:20 +02:00
tweet*: Tweet
before*: Chain
after*: Chain
replies*: Result[Chain]
2019-06-20 16:16:20 +02:00
2019-08-23 02:15:25 +02:00
Timeline* = Result[Tweet]
2019-07-31 02:15:43 +02:00
Config* = ref object
address*: string
port*: int
useHttps*: bool
2019-07-31 02:15:43 +02:00
staticDir*: string
title*: string
hostname*: string
2019-07-31 02:15:43 +02:00
cacheDir*: string
profileCacheTime*: int
2019-10-23 14:06:47 +02:00
defaultTheme*: string
2019-07-31 02:15:43 +02:00
proc contains*(thread: Chain; tweet: Tweet): bool =
2019-08-23 02:15:25 +02:00
thread.content.anyIt(it.id == tweet.id)