sugusama

package module
v0.0.0-...-3e19a94 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2020 License: MIT Imports: 9 Imported by: 0

README

sugusama

Instagram client in Go

Documentation

Index

Constants

View Source
const (
	PlatformTypeUNKNOWN               = "unknown"
	PlatformTypeIOS                   = "ios"
	PlatformTypeANDROID               = "android"
	PlatformTypeBLACKBERRY            = "blackberry"
	PlatformTypeWINDOWSPHONE          = "windows_phone"
	PlatformTypeWEB                   = "web"
	PlatformTypeWINDOWSPHONE10        = "windows_phone_10"
	PlatformTypeWINDOWSNT10           = "windows_nt_10"
	PlatformTypeOSMETA_WINDOWS_PHONE  = "osmeta_windows_phone"
	PlatformTypeOSMETA_WINDOWS_TABLET = "osmeta_windows_tablet"
	PlatformTypeOSMETA_TIZEN          = "osmeta_tizen"
	PlatformTypeOSMETA_DEFAULT        = "osmeta_default"

	PlatformIndexUNKNOWN = -1
	PlatformIndexIOS     = 0
	PlatformIndexANDROID = 1

	AppleAppStoreAppID     = "389801252"
	AppleAppStoreURL       = "https://itunes.apple.com/app/instagram/id389801252"
	AppleAppStoreIGTVAppID = "1394351700"
	AppleAppStoreIGTVURL   = "https://itunes.apple.com/app/igtv/id1394351700"

	InstagramFBAppID           = "124024574287414"
	InstagramWebFBAppID        = "1217981644879628"
	InstagramWebDesktopFBAppID = "936619743392459"
	IGLiteAppID                = "152431142231154"
	InstagramWindowsPWAAppID   = "487152425211411"
	InstagramGoogleClientID    = "51884436741-uudfu5nafa5ufh5e4fks8jv5aa8rgddd.apps.googleusercontent.com"

	AppVersionForLogging = "1.0.0"

	InstagramWebClientToken        = "65a937f07619e8d4dce239c462a447ce"
	InstagramWebDesktopClientToken = "3cdb3f896252a1db29679cb4554db266"
	IGLiteClientToken              = "0c20b150a63e609a804abbb9925df651"

	GooglePlayURL                 = "https://play.google.com/store/apps/details?id=com.instagram.android"
	GooglePlayIGLiteURL           = "https://play.google.com/store/apps/details?id=com.instagram.lite"
	GooglePlayIGTVURL             = "https://play.google.com/store/apps/details?id=com.instagram.igtv"
	WindowsPhoneAppStoreURL       = "http://www.windowsphone.com/s?appid=3222a126-7f20-4273-ab4a-161120b21aea"
	OSMetaWindowsPhoneAppStoreURL = "https://www.microsoft.com/en-us/store/apps/instagram/9nblggh5l9xt"

	UnknownDownloadURL = "/download/"
	PressSiteURL       = "https://instagram-press.com/"
)

taken from https://www.instagram.com/static/bundles/metro/ConsumerLibCommons.js/061fabe68827.js

View Source
const (
	StoriesHash = "04334405dbdef91f2c4e207b84c204d7"
)

Variables

View Source
var DefaultBases = &Bases{
	Web:  "https://instagram.com",
	Live: "https://i.instagram.com",
}
View Source
var (
	ErrActivityMissing = errors.New("no activity returned")
)
View Source
var (
	ErrAdditionalDataNotFound = errors.New("additional data not found")
)
View Source
var (
	ErrLoginNotAuthenticated = errors.New("login not authenticated")
)
View Source
var (
	ErrSharedDataNotFound = errors.New("shared data not found")
)

Functions

func NotOK

func NotOK(at, stat, msg string) error

Types

type Activity

type Activity struct {
	CommentLikes  int `json:"comment_likes"`
	Comments      int `json:"comments"`
	Likes         int `json:"likes"`
	Relationships int `json:"relationships"`
	UserTags      int `json:"usertags"`
}

type Bases

type Bases struct {
	Web  string
	Live string
}

type BroadcastsResp

type BroadcastsResp struct {
	Broadcasts []interface{} `json:"broadcasts"`
	// contains filtered or unexported fields
}

type Client

type Client struct {
	*State

	Client *http.Client
	Bases  *Bases
}

func NewClient

func NewClient(bases *Bases) (*Client, error)

func (*Client) Broadcasts

func (c *Client) Broadcasts() (*BroadcastsResp, error)

func (*Client) BroadcastsOptions

func (c *Client) BroadcastsOptions() error

func (*Client) DirectBadgeCount

func (c *Client) DirectBadgeCount(noRaven bool) (*DirectBadgeCountResp, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) FetchActivity

func (c *Client) FetchActivity() error

func (*Client) FetchHome

func (c *Client) FetchHome() error

func (*Client) GraphQL

func (c *Client) GraphQL(hash string, variables interface{}, ret interface{}) error

func (*Client) Login

func (c *Client) Login(user, pass string) error

func (*Client) Stories

func (c *Client) Stories(opts *StoriesOpts) (*StoriesResp, error)

type Comment

type Comment struct {
	CreatedAt       int64  `json:"created_at"`
	DidReportAsSpam bool   `json:"did_report_as_spam"`
	ID              string `json:"id"`
	Owner           *User  `json:"owner"`
	Text            string `json:"text"`
	ViewerHasLiked  bool   `json:"viewer_has_liked"`
}

type DirectBadgeCountResp

type DirectBadgeCountResp struct {
	UserID         int64 `json:"user_id"`
	BadgeCount     int   `json:"badge_count"`
	SeqID          int   `json:"seq_id"`
	BadgeCountAtMS int64 `json:"badge_count_at_ms"`
	// contains filtered or unexported fields
}

type DisplayResource

type DisplayResource struct {
	ConfigHeight int64  `json:"config_height"`
	ConfigWidth  int64  `json:"config_width"`
	Src          string `json:"src"`
}

type NotOKError

type NotOKError struct {
	At      string
	Status  string
	Message string
}

func (NotOKError) Error

func (n NotOKError) Error() string

type PageInfo

type PageInfo struct {
	EndCursor   string `json:"end_cursor"`
	HasNextPage bool   `json:"has_next_page"`
}

type Post

type Post struct {
	Typename             string                 `json:"__typename"`
	AccessibilityCaption string                 `json:"accessibility_caption"`
	Attribution          interface{}            `json:"attribution"`
	CommentsDisabled     bool                   `json:"comments_disabled"`
	DashInfo             additionalDataDashInfo `json:"dash_info"`

	Dimensions struct {
		Height int64 `json:"height"`
		Width  int64 `json:"width"`
	} `json:"dimensions"`

	DisplayResources []DisplayResource `json:"display_resources"`
	DisplayURL       string            `json:"display_url"`

	RawComments struct {
		Count int64 `json:"count"`

		Edges []struct {
			Node *Comment `json:"node"`
		} `json:"edges"`

		PageInfo PageInfo `json:"page_info"`
	} `json:"edge_media_preview_comment"`

	RawLikes struct {
		Count int64 `json:"count"`

		Edges []struct {
			Node *User `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_preview_like"`

	RawCaptions struct {
		Edges []struct {
			Node struct {
				Text string `json:"text"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_caption"`

	RawSponsorUsers struct {
		Edges []interface{} `json:"edges"`
	} `json:"edge_media_to_sponsor_user"`

	RawTaggedUsers struct {
		Edges []struct {
			Node struct {
				User *User   `json:"user"`
				X    float64 `json:"x"`
				Y    float64 `json:"y"`
			} `json:"node"`
		} `json:"edges"`
	} `json:"edge_media_to_tagged_user"`

	RawChildren struct {
		Edges []struct {
			Node *Post `json:"node"`
		} `json:"edges"`
	} `json:"edge_sidecar_to_children"`

	FactCheckInformation       interface{} `json:"fact_check_information"`
	FactCheckOverallRating     interface{} `json:"fact_check_overall_rating"`
	FollowHashtagInfo          interface{} `json:"follow_hashtag_info"`
	GatingInfo                 interface{} `json:"gating_info"`
	ID                         string      `json:"id"`
	IsVideo                    bool        `json:"is_video"`
	Location                   interface{} `json:"location"`
	MediaPreview               string      `json:"media_preview"`
	Owner                      *User       `json:"owner"`
	Shortcode                  string      `json:"shortcode"`
	TakenAtTimestamp           int64       `json:"taken_at_timestamp"`
	TrackingToken              string      `json:"tracking_token"`
	VideoURL                   string      `json:"video_url"`
	VideoViewCount             int64       `json:"video_view_count"`
	ViewerCanReshare           bool        `json:"viewer_can_reshare"`
	ViewerHasLiked             bool        `json:"viewer_has_liked"`
	ViewerHasSaved             bool        `json:"viewer_has_saved"`
	ViewerHasSavedToCollection bool        `json:"viewer_has_saved_to_collection"`
	ViewerInPhotoOfYou         bool        `json:"viewer_in_photo_of_you"`
}

type State

type State struct {
	Viewer   *User
	Activity *Activity
	Feed     []*Post

	CSRF     string
	AppID    string
	WWWClaim string
}

type StoriesData

type StoriesData struct {
	User StoriesDataUser `json:"user"`
}

type StoriesDataEdge

type StoriesDataEdge struct {
	Node Story `json:"node"`
}

type StoriesDataEdgeReelsTrayToReel

type StoriesDataEdgeReelsTrayToReel struct {
	Edges []StoriesDataEdge `json:"edges"`
}

type StoriesDataFeedReelsTray

type StoriesDataFeedReelsTray struct {
	EdgeReelsTrayToReel StoriesDataEdgeReelsTrayToReel `json:"edge_reels_tray_to_reel"`
}

type StoriesDataUser

type StoriesDataUser struct {
	FeedReelsTray StoriesDataFeedReelsTray `json:"feed_reels_tray"`
}

type StoriesOpts

type StoriesOpts struct {
	OnlyStories       bool `json:"only_stories"`
	Prefetch          bool `json:"stories_prefetch"`
	VideoDashManifest bool `json:"stories_video_dash_manifest"`
}

type StoriesResp

type StoriesResp struct {
	Data StoriesData `json:"data"`
	// contains filtered or unexported fields
}

func (*StoriesResp) Stories

func (s *StoriesResp) Stories() []Story

type StoriesUser

type StoriesUser struct {
	Typename   string `json:"__typename"`
	ID         string `json:"id"`
	ProfilePic string `json:"profile_pic_url"`
	Username   string `json:"username"`
	Followed   bool   `json:"followed_by_viewer"`
	Requested  bool   `json:"requested_by_viewer"`
}

type Story

type Story struct {
	Typename              string      `json:"__typename"`
	HasBestiesMedia       bool        `json:"has_besties_media"`
	HasPrideMedia         bool        `json:"has_pride_media"`
	ID                    string      `json:"id"`
	CanReply              bool        `json:"can_reply"`
	CanReshare            bool        `json:"can_reshare"`
	ExpiringAt            int         `json:"expiring_at"`
	LatestReelMedia       int         `json:"latest_reel_media"`
	Muted                 bool        `json:"muted"`
	SupportsReelReactions interface{} `json:"supports_reel_reactions"`
	Items                 []StoryItem `json:"items"`
	PrefetchCount         int         `json:"prefetch_count"`
	RankedPosition        int         `json:"ranked_position"`
	Seen                  int         `json:"seen"`
	SeenRankedPosition    int         `json:"seen_ranked_position"`
	User                  StoriesUser `json:"user"`
	Owner                 StoriesUser `json:"owner"`
}

type StoryItem

type StoryItem struct {
	Typename               string                      `json:"__typename"`
	Audience               string                      `json:"audience"`
	ID                     string                      `json:"id"`
	Dimensions             StoryItemDimensions         `json:"dimensions"`
	StoryViewCount         int                         `json:"story_view_count"`
	EdgeStoryMediaViewers  StoryItemMediaViewers       `json:"edge_story_media_viewers"`
	DisplayResources       []DisplayResource           `json:"display_resources"`
	DisplayURL             string                      `json:"display_url"`
	MediaPreview           string                      `json:"media_preview"`
	GatingInfo             interface{}                 `json:"gating_info"`
	FactCheckOverallRating interface{}                 `json:"fact_check_overall_rating"`
	FactCheckInformation   interface{}                 `json:"fact_check_information"`
	TakenAtTimestamp       int                         `json:"taken_at_timestamp"`
	ExpiringAtTimestamp    int                         `json:"expiring_at_timestamp"`
	StoryCtaURL            interface{}                 `json:"story_cta_url"`
	IsVideo                bool                        `json:"is_video"`
	Owner                  StoriesUser                 `json:"owner"`
	TrackingToken          string                      `json:"tracking_token"`
	TappableObjects        []StoryItemTappableObject   `json:"tappable_objects"`
	StoryAppAttribution    interface{}                 `json:"story_app_attribution"`
	MediaToSponsorUser     StoryItemMediaToSponsorUser `json:"edge_media_to_sponsor_user"`
}

type StoryItemDimensions

type StoryItemDimensions struct {
	Height int `json:"height"`
	Width  int `json:"width"`
}

type StoryItemMediaToSponsorUser

type StoryItemMediaToSponsorUser struct {
	Edges []interface{} `json:"edges"`
}

type StoryItemMediaViewers

type StoryItemMediaViewers struct {
	Count    int                           `json:"count"`
	Edges    []StoryItemMediaViewersEdge   `json:"edges"`
	PageInfo StoryItemMediaViewersPageInfo `json:"page_info"`
}

type StoryItemMediaViewersEdge

type StoryItemMediaViewersEdge struct {
	Node StoriesUser `json:"node"`
}

type StoryItemMediaViewersPageInfo

type StoryItemMediaViewersPageInfo struct {
	HasNextPage bool   `json:"has_next_page"`
	EndCursor   string `json:"end_cursor"`
}

type StoryItemTappableObject

type StoryItemTappableObject struct {
	Typename    string                       `json:"__typename"`
	X           float64                      `json:"x"`
	Y           float64                      `json:"y"`
	Width       float64                      `json:"width"`
	Height      float64                      `json:"height"`
	Rotation    float64                      `json:"rotation"`
	CustomTitle interface{}                  `json:"custom_title"`
	Attribution interface{}                  `json:"attribution"`
	Media       StoryItemTappableObjectMedia `json:"media"`
}

type StoryItemTappableObjectMedia

type StoryItemTappableObjectMedia struct {
	ID        string `json:"id"`
	Shortcode string `json:"shortcode"`
}

type User

type User struct {
	ID         string `json:"id"`
	Username   string `json:"username"`
	Password   string `json:"-"`
	FullName   string `json:"full_name"`
	ProfilePic string `json:"profile_pic_url"`

	Blocked    bool `json:"blocked_by_viewer"`
	Followed   bool `json:"followed_by_viewer"`
	HasBlocked bool `json:"has_blocked_viewer"`
	Private    bool `json:"is_private"`
	Verified   bool `json:"is_verified"`
	Requested  bool `json:"requested_by_viewer"`
	Restricted bool `json:"restricted_by_viewer"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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