refine import a little more
This commit is contained in:
parent
ba298e452a
commit
f85c7c7654
21
import.go
21
import.go
|
@ -47,6 +47,7 @@ func importTwitter(username, source string) {
|
||||||
Created_at string
|
Created_at string
|
||||||
Full_text string
|
Full_text string
|
||||||
In_reply_to_screen_name string
|
In_reply_to_screen_name string
|
||||||
|
In_reply_to_status_id string
|
||||||
Entities struct {
|
Entities struct {
|
||||||
Hashtags []struct {
|
Hashtags []struct {
|
||||||
Text string
|
Text string
|
||||||
|
@ -61,7 +62,7 @@ func importTwitter(username, source string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
date time.Time
|
date time.Time
|
||||||
text string
|
convoy string
|
||||||
}
|
}
|
||||||
|
|
||||||
var tweets []*Tweet
|
var tweets []*Tweet
|
||||||
|
@ -69,6 +70,7 @@ func importTwitter(username, source string) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
// skip past window.YTD.tweet.part0 =
|
||||||
fd.Seek(25, 0)
|
fd.Seek(25, 0)
|
||||||
dec := json.NewDecoder(fd)
|
dec := json.NewDecoder(fd)
|
||||||
err = dec.Decode(&tweets)
|
err = dec.Decode(&tweets)
|
||||||
|
@ -76,16 +78,27 @@ func importTwitter(username, source string) {
|
||||||
log.Fatalf("error parsing json: %s", err)
|
log.Fatalf("error parsing json: %s", err)
|
||||||
}
|
}
|
||||||
fd.Close()
|
fd.Close()
|
||||||
|
tweetmap := make(map[string]*Tweet)
|
||||||
for _, t := range tweets {
|
for _, t := range tweets {
|
||||||
t.date, _ = time.Parse("Mon Jan 02 15:04:05 -0700 2006", t.Created_at)
|
t.date, _ = time.Parse("Mon Jan 02 15:04:05 -0700 2006", t.Created_at)
|
||||||
|
tweetmap[t.ID_str] = t
|
||||||
}
|
}
|
||||||
sort.Slice(tweets, func(i, j int) bool {
|
sort.Slice(tweets, func(i, j int) bool {
|
||||||
return tweets[i].date.Before(tweets[j].date)
|
return tweets[i].date.Before(tweets[j].date)
|
||||||
})
|
})
|
||||||
for _, t := range tweets {
|
for _, t := range tweets {
|
||||||
what := "honk"
|
what := "honk"
|
||||||
if t.In_reply_to_screen_name != "" {
|
noise := ""
|
||||||
|
if parent := tweetmap[t.In_reply_to_status_id]; parent != nil {
|
||||||
|
t.convoy = parent.convoy
|
||||||
what = "tonk"
|
what = "tonk"
|
||||||
|
} else {
|
||||||
|
t.convoy = "data:,acoustichonkytonk-" + xfiltrate()
|
||||||
|
if t.In_reply_to_screen_name != "" {
|
||||||
|
noise = fmt.Sprintf("re: https://twitter.com/%s/status/%s\n\n",
|
||||||
|
t.In_reply_to_screen_name, t.In_reply_to_status_id)
|
||||||
|
what = "tonk"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
audience := []string{thewholeworld}
|
audience := []string{thewholeworld}
|
||||||
xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate())
|
xid := fmt.Sprintf("%s/%s/%s", user.URL, honkSep, xfiltrate())
|
||||||
|
@ -98,11 +111,11 @@ func importTwitter(username, source string) {
|
||||||
Date: t.date,
|
Date: t.date,
|
||||||
Format: "markdown",
|
Format: "markdown",
|
||||||
Audience: audience,
|
Audience: audience,
|
||||||
Convoy: "data:,acoustichonkytonk-" + xfiltrate(),
|
Convoy: t.convoy,
|
||||||
Public: true,
|
Public: true,
|
||||||
Whofore: 2,
|
Whofore: 2,
|
||||||
}
|
}
|
||||||
noise := t.Full_text
|
noise += t.Full_text
|
||||||
// unbelievable
|
// unbelievable
|
||||||
noise = html.UnescapeString(noise)
|
noise = html.UnescapeString(noise)
|
||||||
for _, r := range t.Entities.Urls {
|
for _, r := range t.Entities.Urls {
|
||||||
|
|
Loading…
Reference in New Issue