types.nim 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import times, sequtils, options
  2. import norm/sqlite
  3. export sqlite, options
  4. type
  5. VideoType* = enum
  6. vmap, m3u8, mp4
  7. db("cache.db", "", "", ""):
  8. type
  9. Profile* = object
  10. username*: string
  11. fullname*: string
  12. location*: string
  13. website*: string
  14. bio*: string
  15. userpic*: string
  16. banner*: string
  17. following*: string
  18. followers*: string
  19. tweets*: string
  20. likes*: string
  21. media*: string
  22. verified*: bool
  23. protected*: bool
  24. joinDate* {.
  25. dbType: "INTEGER"
  26. parseIt: it.i.fromUnix()
  27. formatIt: dbValue(it.toUnix())
  28. .}: Time
  29. updated* {.
  30. dbType: "INTEGER"
  31. parseIt: it.i.fromUnix()
  32. formatIt: dbValue(getTime().toUnix())
  33. .}: Time
  34. Video* = object
  35. videoId*: string
  36. contentId*: string
  37. durationMs*: int
  38. url*: string
  39. thumb*: string
  40. views*: string
  41. available*: bool
  42. playbackType* {.
  43. dbType: "STRING"
  44. parseIt: parseEnum[VideoType](it.s)
  45. formatIt: dbValue($it)
  46. .}: VideoType
  47. Prefs* = object
  48. videoPlayback*: bool
  49. autoplayGifs*: bool
  50. hideTweetStats*: bool
  51. hideBanner*: bool
  52. stickyProfile*: bool
  53. replaceYouTube*: string
  54. replaceTwitter*: string
  55. type
  56. QueryKind* = enum
  57. replies, media, multi, custom = "search"
  58. Query* = object
  59. kind*: QueryKind
  60. filters*: seq[string]
  61. includes*: seq[string]
  62. excludes*: seq[string]
  63. fromUser*: seq[string]
  64. sep*: string
  65. Gif* = object
  66. url*: string
  67. thumb*: string
  68. GalleryPhoto* = object
  69. url*: string
  70. tweetId*: string
  71. color*: string
  72. Poll* = object
  73. options*: seq[string]
  74. values*: seq[int]
  75. votes*: string
  76. status*: string
  77. leader*: int
  78. CardKind* = enum
  79. summary = "summary"
  80. summaryLarge = "summary_large_image"
  81. promoWebsite = "promo_website"
  82. promoVideo = "promo_video_website"
  83. player = "player"
  84. liveEvent = "live_event"
  85. Card* = object
  86. kind*: CardKind
  87. id*: string
  88. query*: string
  89. url*: string
  90. title*: string
  91. dest*: string
  92. text*: string
  93. image*: Option[string]
  94. video*: Option[Video]
  95. Quote* = object
  96. id*: string
  97. profile*: Profile
  98. text*: string
  99. reply*: seq[string]
  100. hasThread*: bool
  101. sensitive*: bool
  102. available*: bool
  103. thumb*: string
  104. badge*: string
  105. Retweet* = object
  106. by*: string
  107. id*: string
  108. TweetStats* = object
  109. replies*: string
  110. retweets*: string
  111. likes*: string
  112. Tweet* = ref object
  113. id*: string
  114. threadId*: string
  115. profile*: Profile
  116. text*: string
  117. time*: Time
  118. shortTime*: string
  119. reply*: seq[string]
  120. pinned*: bool
  121. available*: bool
  122. hasThread*: bool
  123. stats*: TweetStats
  124. retweet*: Option[Retweet]
  125. quote*: Option[Quote]
  126. card*: Option[Card]
  127. gif*: Option[Gif]
  128. video*: Option[Video]
  129. photos*: seq[string]
  130. poll*: Option[Poll]
  131. Thread* = ref object
  132. tweets*: seq[Tweet]
  133. more*: int
  134. Conversation* = ref object
  135. tweet*: Tweet
  136. before*: Thread
  137. after*: Thread
  138. replies*: seq[Thread]
  139. Timeline* = ref object
  140. tweets*: seq[Tweet]
  141. minId*: string
  142. maxId*: string
  143. hasMore*: bool
  144. beginning*: bool
  145. query*: Option[Query]
  146. Config* = ref object
  147. address*: string
  148. port*: int
  149. title*: string
  150. staticDir*: string
  151. cacheDir*: string
  152. profileCacheTime*: int
  153. proc contains*(thread: Thread; tweet: Tweet): bool =
  154. thread.tweets.anyIt(it.id == tweet.id)