diff --git a/Socialmetrica.package/Tweet.class/instance/fromNitterHtmlItem..st b/Socialmetrica.package/Tweet.class/instance/fromNitterHtmlItem..st new file mode 100644 index 0000000..46273c1 --- /dev/null +++ b/Socialmetrica.package/Tweet.class/instance/fromNitterHtmlItem..st @@ -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 \ No newline at end of file diff --git a/Socialmetrica.package/Tweet.class/instance/fromNitterTimelineItem..st b/Socialmetrica.package/Tweet.class/instance/fromNitterTimelineItem..st deleted file mode 100644 index 03a3f71..0000000 --- a/Socialmetrica.package/Tweet.class/instance/fromNitterTimelineItem..st +++ /dev/null @@ -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 ]) \ No newline at end of file diff --git a/Socialmetrica.package/Tweet.class/instance/metrics..st b/Socialmetrica.package/Tweet.class/instance/metrics..st new file mode 100644 index 0000000..0a4c68d --- /dev/null +++ b/Socialmetrica.package/Tweet.class/instance/metrics..st @@ -0,0 +1,4 @@ +accessing +metrics: anObject + + metrics := anObject \ No newline at end of file diff --git a/Socialmetrica.package/Tweet.class/instance/metrics.st b/Socialmetrica.package/Tweet.class/instance/metrics.st new file mode 100644 index 0000000..c560a19 --- /dev/null +++ b/Socialmetrica.package/Tweet.class/instance/metrics.st @@ -0,0 +1,4 @@ +accessing +metrics + + ^ metrics ifNil: [ metrics := Dictionary new ] \ No newline at end of file diff --git a/Socialmetrica.package/Tweet.class/instance/metricsFromNitterHtml..st b/Socialmetrica.package/Tweet.class/instance/metricsFromNitterHtml..st new file mode 100644 index 0000000..92ae422 --- /dev/null +++ b/Socialmetrica.package/Tweet.class/instance/metricsFromNitterHtml..st @@ -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' \ No newline at end of file