Strip nbsp from account names
This commit is contained in:
parent
d864cf95bc
commit
2ee79e7970
|
@ -34,7 +34,7 @@ proc parseIntentProfile*(profile: XmlNode): Profile =
|
||||||
|
|
||||||
proc parseTweetProfile*(profile: XmlNode): Profile =
|
proc parseTweetProfile*(profile: XmlNode): Profile =
|
||||||
result = Profile(
|
result = Profile(
|
||||||
fullname: profile.getAttr("data-name"),
|
fullname: profile.getAttr("data-name").stripNbsp(),
|
||||||
username: profile.getAttr("data-screen-name"),
|
username: profile.getAttr("data-screen-name"),
|
||||||
userpic: profile.getAvatar(".avatar"),
|
userpic: profile.getAvatar(".avatar"),
|
||||||
verified: isVerified(profile)
|
verified: isVerified(profile)
|
||||||
|
@ -48,7 +48,7 @@ proc parseQuote*(quote: XmlNode): Quote =
|
||||||
)
|
)
|
||||||
|
|
||||||
result.profile = Profile(
|
result.profile = Profile(
|
||||||
fullname: quote.selectText(".QuoteTweet-fullname"),
|
fullname: quote.selectText(".QuoteTweet-fullname").stripNbsp(),
|
||||||
username: quote.getAttr("data-screen-name"),
|
username: quote.getAttr("data-screen-name"),
|
||||||
verified: isVerified(quote)
|
verified: isVerified(quote)
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,6 +3,9 @@ import nimquery, regex
|
||||||
|
|
||||||
import ./types, ./formatters, ./api
|
import ./types, ./formatters, ./api
|
||||||
|
|
||||||
|
from unicode import Rune, `$`
|
||||||
|
const nbsp = $Rune(0x000A0)
|
||||||
|
|
||||||
const
|
const
|
||||||
thumbRegex = re".+:url\('([^']+)'\)"
|
thumbRegex = re".+:url\('([^']+)'\)"
|
||||||
gifRegex = re".+thumb/([^\.']+)\.jpg.*"
|
gifRegex = re".+thumb/([^\.']+)\.jpg.*"
|
||||||
|
@ -26,6 +29,9 @@ proc getHeader(profile: XmlNode): XmlNode =
|
||||||
if result.isNil:
|
if result.isNil:
|
||||||
result = profile.querySelector(".ProfileCard-userFields")
|
result = profile.querySelector(".ProfileCard-userFields")
|
||||||
|
|
||||||
|
proc stripNbsp*(text: string): string =
|
||||||
|
text.replace(nbsp, "")
|
||||||
|
|
||||||
proc isVerified*(profile: XmlNode): bool =
|
proc isVerified*(profile: XmlNode): bool =
|
||||||
getHeader(profile).selectText(".Icon.Icon--verified").len > 0
|
getHeader(profile).selectText(".Icon.Icon--verified").len > 0
|
||||||
|
|
||||||
|
@ -33,7 +39,7 @@ proc isProtected*(profile: XmlNode): bool =
|
||||||
getHeader(profile).selectText(".Icon.Icon--protected").len > 0
|
getHeader(profile).selectText(".Icon.Icon--protected").len > 0
|
||||||
|
|
||||||
proc getName*(profile: XmlNode; selector: string): string =
|
proc getName*(profile: XmlNode; selector: string): string =
|
||||||
profile.selectText(selector).strip()
|
profile.selectText(selector).strip().stripNbsp()
|
||||||
|
|
||||||
proc getUsername*(profile: XmlNode; selector: string): string =
|
proc getUsername*(profile: XmlNode; selector: string): string =
|
||||||
profile.selectText(selector).strip(chars={'@', ' '})
|
profile.selectText(selector).strip(chars={'@', ' '})
|
||||||
|
|
Loading…
Reference in New Issue