Improving tweets parsing from nitter timeline item.

This commit is contained in:
ruidajo 2022-04-08 23:50:31 -05:00
parent d9af46ec37
commit a84e9504f9
2 changed files with 22 additions and 6 deletions

View File

@ -5,5 +5,6 @@ reStoreDefinition
define: #text as: String; define: #text as: String;
define: #created as: String; define: #created as: String;
define: #authorId as: String; define: #authorId as: String;
define: #timelines as: (Dictionary of: String -> String); define: #timelines as: (Dictionary of: String -> String);
define: #metrics as: (Dictionary of: String -> String);
yourself yourself

View File

@ -18,11 +18,26 @@ fromNitterTimelineItem: xmlItem
metricsTemp := Dictionary new . metricsTemp := Dictionary new .
metricsTemp metricsTemp
at: 'comment' at: 'comment'
put: (xmlItem xpath: '//div[@class="icon-container"]') second stringValue trimmed; put: ((((xmlItem xpath: '//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'comment' ])
stringValue trimmed) copyReplaceAll: ',' with: '');
at: 'retweet' at: 'retweet'
put: (xmlItem xpath: '//div[@class="icon-container"]') third stringValue trimmed; put: ((((xmlItem xpath: '//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'retweet' ])
stringValue trimmed) copyReplaceAll: ',' with: '');
at: 'quote' at: 'quote'
put: (xmlItem xpath: '//div[@class="icon-container"]') fourth stringValue trimmed; put: ((((xmlItem xpath: '//div[@class="icon-container"]')
select: [ :item | item asString includesSubstring: 'quote' ])
stringValue trimmed) copyReplaceAll: ',' with: '');
at: 'heart' at: 'heart'
put: (xmlItem xpath: '//div[@class="icon-container"]') fifth stringValue trimmed. put: ((((xmlItem xpath: '//div[@class="icon-container"]')
metrics := metricsTemp. select: [ :item | item asString includesSubstring: 'heart' ])
stringValue trimmed) copyReplaceAll: ',' with: '').
metrics := metricsTemp.
metadata := Dictionary new.
metadata
at: 'pinned'
put: (((xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed) = 'Pinned Tweet'
ifTrue: [ True ]
ifFalse: [ False ])