|
@@ -1,28 +1,19 @@
|
|
|
-import strutils, strformat, times, uri, tables
|
|
|
|
|
-import xmltree, htmlparser
|
|
|
|
|
|
|
+import strutils, strformat, times, uri, tables, xmltree, htmlparser
|
|
|
import regex
|
|
import regex
|
|
|
-
|
|
|
|
|
import types, utils, query
|
|
import types, utils, query
|
|
|
|
|
|
|
|
-from unicode import Rune, `$`
|
|
|
|
|
-
|
|
|
|
|
const
|
|
const
|
|
|
ytRegex = re"([A-z.]+\.)?youtu(be\.com|\.be)"
|
|
ytRegex = re"([A-z.]+\.)?youtu(be\.com|\.be)"
|
|
|
twRegex = re"(www\.|mobile\.)?twitter\.com"
|
|
twRegex = re"(www\.|mobile\.)?twitter\.com"
|
|
|
igRegex = re"(www\.)?instagram.com"
|
|
igRegex = re"(www\.)?instagram.com"
|
|
|
cards = "cards.twitter.com/cards"
|
|
cards = "cards.twitter.com/cards"
|
|
|
tco = "https://t.co"
|
|
tco = "https://t.co"
|
|
|
- nbsp = $Rune(0x000A0)
|
|
|
|
|
|
|
|
|
|
wwwRegex = re"https?://(www[0-9]?\.)?"
|
|
wwwRegex = re"https?://(www[0-9]?\.)?"
|
|
|
m3u8Regex = re"""url="(.+.m3u8)""""
|
|
m3u8Regex = re"""url="(.+.m3u8)""""
|
|
|
manifestRegex = re"(.+(.ts|.m3u8|.vmap))"
|
|
manifestRegex = re"(.+(.ts|.m3u8|.vmap))"
|
|
|
userpicRegex = re"_(normal|bigger|mini|200x200|400x400)(\.[A-z]+)$"
|
|
userpicRegex = re"_(normal|bigger|mini|200x200|400x400)(\.[A-z]+)$"
|
|
|
extRegex = re"(\.[A-z]+)$"
|
|
extRegex = re"(\.[A-z]+)$"
|
|
|
- tombstoneRegex = re"\n* *Learn more"
|
|
|
|
|
-
|
|
|
|
|
-proc stripText*(text: string): string =
|
|
|
|
|
- text.replace(nbsp, " ").strip()
|
|
|
|
|
|
|
|
|
|
proc stripHtml*(text: string): string =
|
|
proc stripHtml*(text: string): string =
|
|
|
var html = parseHtml(text)
|
|
var html = parseHtml(text)
|
|
@@ -129,9 +120,6 @@ proc getLink*(tweet: Tweet; focus=true): string =
|
|
|
result = &"/{username}/status/{tweet.id}"
|
|
result = &"/{username}/status/{tweet.id}"
|
|
|
if focus: result &= "#m"
|
|
if focus: result &= "#m"
|
|
|
|
|
|
|
|
-proc getTombstone*(text: string): string =
|
|
|
|
|
- text.replace(tombstoneRegex, "").stripText().strip(chars={' ', '\n'})
|
|
|
|
|
-
|
|
|
|
|
proc getTwitterLink*(path: string; params: Table[string, string]): string =
|
|
proc getTwitterLink*(path: string; params: Table[string, string]): string =
|
|
|
let
|
|
let
|
|
|
twitter = parseUri("https://twitter.com")
|
|
twitter = parseUri("https://twitter.com")
|