Socialmetrica/Socialmetrica.package/Tweet.class/instance/metadataFromNitterHtml..st

19 lines
640 B
Smalltalk

accessing
metadataFromNitterHtml: xmlItem
| quoteSubtree |
self metadata
at: 'pinned'
put: (xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed
= 'Pinned Tweet';
at: 'replie to'
put: (xmlItem xpath: '//div[@class="tweet-body"]//div[@class="replying-to"]') stringValue trimmed.
quoteSubtree := xmlItem xpath: '//div[@class="tweet-body"]//div[@class="quote quote-big"]//a[@class="quote-link"]'.
quoteSubtree set isEmpty
ifTrue: [ self metadata at: 'quote' put: '' ]
ifFalse: [
self metadata
at: 'quote'
put: ((quoteSubtree postCopy asString splitOn: 'href="/')
second removeSuffix: '"/>)')
]