twitwoo

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrBreak = errors.New("end each iterator")

ErrBreak exits the Each iterator.

Functions

func All

func All[T Ptr[U], U any](d *Data, dt DataType) ([]T, error)

All returns all items of a data type.

func Each

func Each[T Ptr[U], U any](d *Data, dt DataType, fn func(T) error) error

Each calls fn for each data type item.

func EachRaw

func EachRaw(d *Data, dt DataType, fn func(map[string]any) error) error

EachRaw calls fn for each data type item, but all items are map[string]any.

Types

type ArchiveInfo

type ArchiveInfo struct {
	GenerationDate   time.Time `json:"generationDate"`
	SizeBytes        int64     `json:"sizeBytes"`
	MaxPartSizeBytes int64     `json:"maxPartSizeBytes"`
	IsPartialArchive bool      `json:"isPartialArchive"`
}

ArchiveInfo is the structure of the archive info section of the manifest.json file.

type Data

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

Data is a struct that provides an interface to the data archive.

func New

func New(fs afero.Fs) *Data

New returns a new Data struct.

func (*Data) EachProfile

func (d *Data) EachProfile(fn func(*Profile) error) error

EachProfile calls fn for each Profile item.

func (*Data) EachTweet

func (d *Data) EachTweet(fn func(*Tweet) error) error

EachTweet calls fn for each tweet.

func (*Data) Manifest

func (d *Data) Manifest() (*Manifest, error)

Manifest is the manifest.json file in the archive.

func (*Data) Profiles

func (d *Data) Profiles() ([]*Profile, error)

Profiles returns all the Profile items.

func (*Data) Tweets

func (d *Data) Tweets() ([]*Tweet, error)

Tweets returns a slice of tweets.

type DataFile

type DataFile struct {
	Name     string `json:"fileName"`
	Preamble string `json:"globalName"`
	Count    int64  `json:"count"`
}

DataFile is the structure of the data file sections of the manifest.json file.

type DataType

type DataType struct {
	MediaDir string     `json:"mediaDirectory,omitempty"`
	Files    []DataFile `json:"files"`
}

DataType is the structure of the data type sections of the manifest.json file.

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

Link represents a link in a tweet.

type Manifest

type Manifest struct {
	DataTypes struct {
		Account                         DataType `json:"account"`
		AccountCreationIP               DataType `json:"accountCreationIp"`
		AccountLabel                    DataType `json:"accountLabel"`
		AccountSuspension               DataType `json:"accountSuspension"`
		AccountTimezone                 DataType `json:"accountTimezone"`
		AdEngagements                   DataType `json:"adEngagements"`
		AdImpressions                   DataType `json:"adImpressions"`
		AdMobileConversionsUnattributed DataType `json:"adMobileConversionsUnattributed"`
		AdMobileConversionsAttributed   DataType `json:"adMobileConversionsAttributed"`
		AdOnlineConversionsUnattributed DataType `json:"adOnlineConversionsUnattributed"`
		AdOnlineConversionsAttributed   DataType `json:"adOnlineConversionsAttributed"`
		AgeInfo                         DataType `json:"ageInfo"`
		App                             DataType `json:"app"`
		Block                           DataType `json:"block"`
		BranchLinks                     DataType `json:"branchLinks"`
		CatalogItem                     DataType `json:"catalogItem"`
		CommerceCatalog                 DataType `json:"commerceCatalog"`
		CommunityNote                   DataType `json:"communityNote"`
		CommunityNoteRating             DataType `json:"communityNoteRating"`
		CommunityNoteTombstone          DataType `json:"communityNoteTombstone"`
		CommunityTweet                  DataType `json:"communityTweet"`
		ConnectedApplication            DataType `json:"connectedApplication"`
		Contact                         DataType `json:"contact"`
		DeletedNoteTweet                DataType `json:"deletedNoteTweet"`
		DeletedTweetHeaders             DataType `json:"deletedTweetHeaders"`
		DeletedTweets                   DataType `json:"deletedTweets"`
		DeviceToken                     DataType `json:"deviceToken"`
		DirectMessageGroupHeaders       DataType `json:"directMessageGroupHeaders"`
		DirectMessageHeaders            DataType `json:"directMessageHeaders"`
		DirectMessageMute               DataType `json:"directMessageMute"`
		DirectMessages                  DataType `json:"directMessages"`
		DirectMessagesGroup             DataType `json:"directMessagesGroup"`
		EmailAddressChange              DataType `json:"emailAddressChange"`
		Follower                        DataType `json:"follower"`
		Following                       DataType `json:"following"`
		IPAudit                         DataType `json:"ipAudit"`
		KeyRegistry                     DataType `json:"keyRegistry"`
		Like                            DataType `json:"like"`
		ListsCreated                    DataType `json:"listsCreated"`
		ListsMember                     DataType `json:"listsMember"`
		ListsSubscribed                 DataType `json:"listsSubscribed"`
		Moment                          DataType `json:"moment"`
		Mute                            DataType `json:"mute"`
		NIDevices                       DataType `json:"niDevices"`
		NoteTweet                       DataType `json:"noteTweet"`
		PeriscopeAccountInformation     DataType `json:"periscopeAccountInformation"`
		PeriscopeBanInformation         DataType `json:"periscopeBanInformation"`
		PeriscopeBroadcastMetadata      DataType `json:"periscopeBroadcastMetadata"`
		PeriscopeCommentsMadeByUser     DataType `json:"periscopeCommentsMadeByUser"`
		PeriscopeExpiredBroadcasts      DataType `json:"periscopeExpiredBroadcasts"`
		PeriscopeFollowers              DataType `json:"periscopeFollowers"`
		PeriscopeProfileDescription     DataType `json:"periscopeProfileDescription"`
		Personalization                 DataType `json:"personalization"`
		PhoneNumber                     DataType `json:"phoneNumber"`
		ProductDrop                     DataType `json:"productDrop"`
		ProductSet                      DataType `json:"productSet"`
		ProfessionalData                DataType `json:"professionalData"`
		Profile                         DataType `json:"profile"`
		ProtectedHistory                DataType `json:"protectedHistory"`
		ReplyPrompt                     DataType `json:"replyPrompt"`
		SavedSearch                     DataType `json:"savedSearch"`
		ScreenNameChange                DataType `json:"screenNameChange"`
		ShopModule                      DataType `json:"shopModule"`
		ShopifyAccount                  DataType `json:"shopifyAccount"`
		Smartblock                      DataType `json:"smartblock"`
		SpacesMetadata                  DataType `json:"spacesMetadata"`
		SSO                             DataType `json:"sso"`
		TweetHeaders                    DataType `json:"tweetHeaders"`
		TweetDeck                       DataType `json:"tweetdeck"`
		Tweets                          DataType `json:"tweets"`
		TwitterArticle                  DataType `json:"twitterArticle"`
		TwitterArticleMetadata          DataType `json:"twitterArticleMetadata"`
		TwitterCircle                   DataType `json:"twitterCircle"`
		TwitterCircleMember             DataType `json:"twitterCircleMember"`
		TwitterCircleTweet              DataType `json:"twitterCircleTweet"`
		TwitterShop                     DataType `json:"twitterShop"`
		UserLinkClicks                  DataType `json:"userLinkClicks"`
		Verified                        DataType `json:"verified"`
	} `json:"dataTypes"`
	UserInfo    UserInfo    `json:"userInfo"`
	ArchiveInfo ArchiveInfo `json:"archiveInfo"`
}

Manifest is the structure of the manifest.json file.

type Media

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

Media represents a media item in a tweet.

type Mention

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

Mention represents a mention of a user in a tweet.

type Profile

type Profile struct {
	Description struct {
		Bio      string `json:"bio"`
		Website  string `json:"website"`
		Location string `json:"location"`
	} `json:"description"`
	Avatar string `json:"avatarMediaUrl"`
	Header string `json:"headerMediaUrl"`
}

Profile is the structure of the data/profile.js file.

type Ptr

type Ptr[T any] interface {
	*T
}

type Tweet

type Tweet struct {
	CreatedAt         time.Time       `json:"created_at"`
	URLMap            map[string]Link `json:"urlmap"`
	FullText          string          `json:"full_text"`
	Hashtags          []string        `json:"hashtags"`
	Mentions          []Mention       `json:"mentions"`
	Media             []Media         `json:"media"`
	InReplyToUserID   int64           `json:"in_reply_to_user_id"`
	InReplyToStatusID int64           `json:"in_reply_to_status_id"`
	ID                int64           `json:"id"`
	RetweetCount      int64           `json:"retweet_count"`
	FavoriteCount     int64           `json:"favorite_count"`
}

Tweet represents a single tweet.

func (*Tweet) SearchIndex added in v1.2.0

func (t *Tweet) SearchIndex() TweetSearchIndex

SearchIndex returns a search index entry for a tweet.

type TweetSearchIndex added in v1.2.0

type TweetSearchIndex struct {
	Title string `json:"title"`
	URL   string `json:"url"`
}

TweetSearchIndex represents a search index entry for a tweet.

type UserInfo

type UserInfo struct {
	UserName    string `json:"userName"`
	DisplayName string `json:"displayName"`
	AccountID   int64  `json:"accountId"`
}

UserInfo is the structure of the user info section of the manifest.json file.

type Variant

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

Variant represents a video variant.

Jump to

Keyboard shortcuts

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