types.nim 3.5 KB

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