From af367cd50c5d6a244156ee37eb0a6ce51de561a1 Mon Sep 17 00:00:00 2001 From: ruidajo Date: Tue, 29 Mar 2022 17:10:43 -0500 Subject: [PATCH] Improving NitterUser and Tweet from nitter information. --- .../NitterUser.class/instance/asDictionary.st | 7 +++++++ .../instance/exportProfileImageOn..st | 1 + .../instance/exportWithTemplate.On..st | 11 +++++++++++ .../NitterUser.class/instance/profileBio.st | 4 ++++ .../NitterUser.class/instance/retrieveContents.st | 1 + .../Tweet.class/instance/fromNitter..st | 2 +- .../TwitterUser.class/instance/profileBio.st | 3 +++ .../TwitterUser.class/instance/profileImageFile.st | 3 +++ .../TwitterUser.class/properties.json | 4 +++- 9 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 Datanalitica.package/NitterUser.class/instance/asDictionary.st create mode 100644 Datanalitica.package/NitterUser.class/instance/exportWithTemplate.On..st create mode 100644 Datanalitica.package/NitterUser.class/instance/profileBio.st create mode 100644 Datanalitica.package/TwitterUser.class/instance/profileBio.st create mode 100644 Datanalitica.package/TwitterUser.class/instance/profileImageFile.st diff --git a/Datanalitica.package/NitterUser.class/instance/asDictionary.st b/Datanalitica.package/NitterUser.class/instance/asDictionary.st new file mode 100644 index 0000000..e4f537c --- /dev/null +++ b/Datanalitica.package/NitterUser.class/instance/asDictionary.st @@ -0,0 +1,7 @@ +accessing +asDictionary + + ^ { 'profile-card-avatar' -> self profileImageFile fullName. + 'profile-card-fullname' -> self name . + 'profile-card-username' -> self userName . + 'profile-bio' -> self profileBio } asDictionary \ No newline at end of file diff --git a/Datanalitica.package/NitterUser.class/instance/exportProfileImageOn..st b/Datanalitica.package/NitterUser.class/instance/exportProfileImageOn..st index fcd8fd9..4039d1a 100644 --- a/Datanalitica.package/NitterUser.class/instance/exportProfileImageOn..st +++ b/Datanalitica.package/NitterUser.class/instance/exportProfileImageOn..st @@ -7,5 +7,6 @@ exportProfileImageOn: fileReference file exists ifFalse: [ file ensureCreateFile ]. file binaryWriteStreamDo: [ :stream | stream nextPutAll: profileImageUrl retrieveContents ]. + profileImageFile := file. super class inform: 'Exported as: ', String cr, file fullName. ^ file \ No newline at end of file diff --git a/Datanalitica.package/NitterUser.class/instance/exportWithTemplate.On..st b/Datanalitica.package/NitterUser.class/instance/exportWithTemplate.On..st new file mode 100644 index 0000000..0ff7998 --- /dev/null +++ b/Datanalitica.package/NitterUser.class/instance/exportWithTemplate.On..st @@ -0,0 +1,11 @@ +accessing +exportWithTemplate: mustacheFile On: fileReference + + | directory data mustacheDoc | + directory := fileReference parent. + data := self asDictionary. + self exportProfileImageOn:directory / userName, '-profileImage.jpg'. + mustacheDoc := mustacheFile asMustacheTemplate value: data. + MarkupFile + exportAsFileOn: (directory / (data at:'profile-card-username') asDashedLowercase , 'tex') + containing: mustacheDoc \ No newline at end of file diff --git a/Datanalitica.package/NitterUser.class/instance/profileBio.st b/Datanalitica.package/NitterUser.class/instance/profileBio.st new file mode 100644 index 0000000..cb3348a --- /dev/null +++ b/Datanalitica.package/NitterUser.class/instance/profileBio.st @@ -0,0 +1,4 @@ +accessing +profileBio + + ^ profileBio := (self documentTree xpath: '/html/body/div/div/div[2]/div[1]/div[2]/div[1]') stringValue \ No newline at end of file diff --git a/Datanalitica.package/NitterUser.class/instance/retrieveContents.st b/Datanalitica.package/NitterUser.class/instance/retrieveContents.st index 831b923..1620063 100644 --- a/Datanalitica.package/NitterUser.class/instance/retrieveContents.st +++ b/Datanalitica.package/NitterUser.class/instance/retrieveContents.st @@ -8,4 +8,5 @@ retrieveContents createdAt; url; profileImageUrl; + profileBio; yourself. \ No newline at end of file diff --git a/Datanalitica.package/Tweet.class/instance/fromNitter..st b/Datanalitica.package/Tweet.class/instance/fromNitter..st index 81bfe08..b583e8a 100644 --- a/Datanalitica.package/Tweet.class/instance/fromNitter..st +++ b/Datanalitica.package/Tweet.class/instance/fromNitter..st @@ -1,6 +1,6 @@ accessing fromNitter: aDictionary - "created := (aDictionary at: 'pubDate') asDateAndTime." + created := (aDictionary at: 'pubDate') "asDateAndTime". text := aDictionary at: 'text'. "id := aDictionary at: 'id'. authorId := aDictionary at: 'author_id'." diff --git a/Datanalitica.package/TwitterUser.class/instance/profileBio.st b/Datanalitica.package/TwitterUser.class/instance/profileBio.st new file mode 100644 index 0000000..f971e84 --- /dev/null +++ b/Datanalitica.package/TwitterUser.class/instance/profileBio.st @@ -0,0 +1,3 @@ +accessing +profileBio + ^ profileBio \ No newline at end of file diff --git a/Datanalitica.package/TwitterUser.class/instance/profileImageFile.st b/Datanalitica.package/TwitterUser.class/instance/profileImageFile.st new file mode 100644 index 0000000..bdc9f62 --- /dev/null +++ b/Datanalitica.package/TwitterUser.class/instance/profileImageFile.st @@ -0,0 +1,3 @@ +accessing +profileImageFile + ^ profileImageFile \ No newline at end of file diff --git a/Datanalitica.package/TwitterUser.class/properties.json b/Datanalitica.package/TwitterUser.class/properties.json index cd9b9ff..15e1273 100644 --- a/Datanalitica.package/TwitterUser.class/properties.json +++ b/Datanalitica.package/TwitterUser.class/properties.json @@ -15,7 +15,9 @@ "tweets", "createdAt", "groups", - "url" + "url", + "profileImageFile", + "profileBio" ], "name" : "TwitterUser", "type" : "normal"