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: #created 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

View File

@ -18,11 +18,26 @@ fromNitterTimelineItem: xmlItem
metricsTemp := Dictionary new .
metricsTemp
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'
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'
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'
put: (xmlItem xpath: '//div[@class="icon-container"]') fifth stringValue trimmed.
metrics := metricsTemp.
put: ((((xmlItem xpath: '//div[@class="icon-container"]')
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 ])