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

19 lines
640 B
Smalltalk
Raw Normal View History

accessing
metadataFromNitterHtml: xmlItem
2022-04-19 03:14:17 +00:00
| quoteSubtree |
self metadata
at: 'pinned'
put: (xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed
= 'Pinned Tweet';
2022-04-19 03:14:17 +00:00
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: '"/>)')
]