Code review. Improving modularization and naming.
This commit is contained in:
parent
89a73603a3
commit
65c36e924c
@ -0,0 +1,20 @@
|
|||||||
|
accessing
|
||||||
|
fromNitterHtmlItem: xmlItem
|
||||||
|
|
||||||
|
| author authorAndId timeTemp |
|
||||||
|
authorAndId := (((xmlItem xpath: '//a[@class="tweet-link"]') asString
|
||||||
|
splitOn: 'href="') second splitOn: '/') reject: [
|
||||||
|
:i | i isEmpty or: [ i = '>)' ] ].
|
||||||
|
author := authorAndId first.
|
||||||
|
user := NitterUser new userName: author.
|
||||||
|
timeTemp := (((xmlItem xpath: '//span[@class="tweet-date"]') asString
|
||||||
|
splitOn: 'title="') second splitOn: '">') first.
|
||||||
|
timeTemp := ((timeTemp copyReplaceAll: ' · ' with: ' ')
|
||||||
|
copyReplaceAll: 'UTC'
|
||||||
|
with: '+00:00') asDateAndTime.
|
||||||
|
created := timeTemp.
|
||||||
|
text := (xmlItem xpath: '//div[@class="tweet-content media-body"]')
|
||||||
|
stringValue.
|
||||||
|
id := authorAndId last copyReplaceAll: '#m"' with: ''.
|
||||||
|
authorId := self user id.
|
||||||
|
self metricsFromNitterHtml: xmlItem
|
@ -1,43 +0,0 @@
|
|||||||
accessing
|
|
||||||
fromNitterTimelineItem: xmlItem
|
|
||||||
| author authorAndId metricsTemp timeTemp |
|
|
||||||
authorAndId := (((xmlItem xpath: '//a[@class="tweet-link"]')
|
|
||||||
asString splitOn: 'href="' ) second splitOn: '/') reject: [ :i | i isEmpty or: [i = '>)']].
|
|
||||||
author := authorAndId first.
|
|
||||||
user := NitterUser new
|
|
||||||
userName: author .
|
|
||||||
|
|
||||||
timeTemp := (((xmlItem xpath: '//span[@class="tweet-date"]')asString splitOn: 'title="') second splitOn: '">')first.
|
|
||||||
timeTemp := ((timeTemp copyReplaceAll: ' · ' with: ' ') copyReplaceAll: 'UTC' with: '+00:00') asDateAndTime.
|
|
||||||
created := timeTemp.
|
|
||||||
|
|
||||||
text := (xmlItem xpath: '//div[@class="tweet-content media-body"]')stringValue.
|
|
||||||
id := authorAndId last copyReplaceAll: '#m"' with: ''.
|
|
||||||
authorId := self user id.
|
|
||||||
|
|
||||||
metricsTemp := Dictionary new .
|
|
||||||
metricsTemp
|
|
||||||
at: 'comment'
|
|
||||||
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"]')
|
|
||||||
select: [ :item | item asString includesSubstring: 'retweet' ])
|
|
||||||
stringValue trimmed) copyReplaceAll: ',' with: '');
|
|
||||||
at: 'quote'
|
|
||||||
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"]')
|
|
||||||
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 ])
|
|
4
Socialmetrica.package/Tweet.class/instance/metrics..st
Normal file
4
Socialmetrica.package/Tweet.class/instance/metrics..st
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
accessing
|
||||||
|
metrics: anObject
|
||||||
|
|
||||||
|
metrics := anObject
|
4
Socialmetrica.package/Tweet.class/instance/metrics.st
Normal file
4
Socialmetrica.package/Tweet.class/instance/metrics.st
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
accessing
|
||||||
|
metrics
|
||||||
|
|
||||||
|
^ metrics ifNil: [ metrics := Dictionary new ]
|
@ -0,0 +1,30 @@
|
|||||||
|
accessing
|
||||||
|
metricsFromNitterHtml: xmlItem
|
||||||
|
|
||||||
|
self metrics
|
||||||
|
at: 'comment'
|
||||||
|
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"]') select: [ :item |
|
||||||
|
item asString includesSubstring: 'retweet' ]) stringValue
|
||||||
|
trimmed copyReplaceAll: ',' with: '');
|
||||||
|
at: 'quote'
|
||||||
|
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"]') select: [ :item |
|
||||||
|
item asString includesSubstring: 'heart' ]) stringValue trimmed
|
||||||
|
copyReplaceAll: ','
|
||||||
|
with: '').
|
||||||
|
|
||||||
|
metadata
|
||||||
|
at: 'pinned'
|
||||||
|
put: (xmlItem xpath: '//div[@class="pinned"]') stringValue trimmed = 'Pinned Tweet'
|
Loading…
Reference in New Issue
Block a user