twarc

package
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2025 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Overview

Package twarc provides tools and types to parse a Twitter/X archive.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        ID        `json:"accountId"`
	Username  string    `json:"username"`
	Email     string    `json:"email"`
	CreatedAt time.Time `json:"createdAt"`
}

type Archive

type Archive struct {
	// contains filtered or unexported fields
}

func Open

func Open(name string) (Archive, error)

func (*Archive) Account

func (arc *Archive) Account() (acc Account, err error)

func (*Archive) Close

func (arc *Archive) Close() (err error)

func (*Archive) Followers

func (arc *Archive) Followers() iter.Seq2[Follower, error]

func (*Archive) Followings

func (arc *Archive) Followings() iter.Seq2[Following, error]

func (*Archive) Tweets

func (arc *Archive) Tweets() iter.Seq2[Tweet, error]

type Entities

type Entities struct {
	Mentions []Mention `json:"user_mentions"`
	URLs     []URL     `json:"urls"`
	Symbols  []Symbol  `json:"symbols"`
	Media    []Media   `json:"media"`
	HashTags []HashTag `json:"hashtags"`
}

type ExtEntities

type ExtEntities struct {
	Media []Media `json:"media"`
}

type Follower

type Follower struct {
	ID   ID     `json:"accountId"`
	Link string `json:"userLink"`
}

type Following

type Following struct {
	ID   ID     `json:"accountId"`
	Link string `json:"userLink"`
}

type HashTag

type HashTag struct {
	Text string `json:"text"`
	Pos  Range  `json:"indices"`
}

type ID

type ID int64

func (ID) MarshalJSON

func (id ID) MarshalJSON() ([]byte, error)

func (*ID) UnmarshalJSON

func (id *ID) UnmarshalJSON(p []byte) error

type Int64

type Int64 int64

func (Int64) MarshalJSON

func (i Int64) MarshalJSON() ([]byte, error)

func (*Int64) UnmarshalJSON

func (i *Int64) UnmarshalJSON(p []byte) error
type Link struct {
	DisplayURL  string `json:"display_url"`
	ExpandedURL string `json:"expanded_url"`
}

Link represents a link in a tweet.

type Media

type Media struct {
	ID             ID        `json:"id"`
	Type           string    `json:"type"`
	URL            string    `json:"url"`
	MediaURL       string    `json:"media_url_https"`
	ExpandedURL    string    `json:"expanded_url"`
	DisplayURL     string    `json:"display_url"`
	SourceStatusID ID        `json:"source_status_id"`
	VideoInfo      VideoInfo `json:"video_info"`
}

Media represents a media item in a tweet.

type Mention

type Mention struct {
	ID         ID     `json:"id"`
	Name       string `json:"name"`
	ScreenName string `json:"screen_name"`
	Pos        Range  `json:"indices"`
}

Mention represents a mention of a user in a tweet.

type Range

type Range struct {
	Beg int64
	End int64
}

func (Range) MarshalJSON

func (rng Range) MarshalJSON() ([]byte, error)

func (*Range) UnmarshalJSON

func (rng *Range) UnmarshalJSON(p []byte) error

type Symbol

type Symbol struct {
	Text string `json:"text"`
	Pos  Range  `json:"indices"`
}

type Thread

type Thread struct {
	Tweet   Tweet
	Replies []*Thread
}

Thread of tweets.

func (*Thread) Display

func (th *Thread) Display() string

func (*Thread) Tweets

func (th *Thread) Tweets() iter.Seq2[int, Tweet]

type Time

type Time struct {
	T time.Time
}

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(p []byte) error

type Tweet

type Tweet struct {
	ID                ID          `json:"id"`
	CreatedAt         Time        `json:"created_at"`
	FullText          string      `json:"full_text"`
	InReplyToUserID   ID          `json:"in_reply_to_user_id"`
	InReplyToStatusID ID          `json:"in_reply_to_status_id"`
	DisplayTextRange  Range       `json:"display_text_range"`
	NumRetweet        Int64       `json:"retweet_count"`
	NumFavorite       Int64       `json:"favorite_count"`
	Entities          Entities    `json:"entities"`
	Lang              string      `json:"lang"`
	ExtEntities       ExtEntities `json:"extended_entities"`
}

Tweet represents a single tweet.

func (*Tweet) IsRT

func (tw *Tweet) IsRT() bool

type URL

type URL struct {
	URL         string `json:"url"`
	ExpandedURL string `json:"expanded_url"`
	DisplayURL  string `json:"display_url"`
}

type Variant

type Variant struct {
	ContentType string `json:"content_type"`
	URL         string `json:"url"`
	Bitrate     Int64  `json:"bitrate"`
}

type VideoInfo

type VideoInfo struct {
	Duration Int64     `json:"duration_millis"`
	Variants []Variant `json:"variants"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL