douyin

package
v0.0.0-...-bf7ecd3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2025 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 这个名字是日志中的名字,如果不知道取什么名字,可以和Site一样
	ConcernName = "douyin-concern"

	// 插件支持的网站名
	Site = "douyin"
	// 这个插件支持的订阅类型可以像这样自定义,然后在 Types 中返回
	Live concern_type.Type = "live"
	// 当像这样定义的时候,支持 /watch -s mysite -t type1 id
	// 当实现的时候,请修改上面的定义
	// API Base URL
	BaseHost     = "https://www.douyin.com"
	BaseLiveHost = "https://live.douyin.com"
	ErrNotFound  = "not found"
)
View Source
const PathCheckUserLiveStatus = "/webcast/distribution/check_user_live_status"
View Source
const PathGetUserInfo = "/user/"

Variables

View Source
var (
	Cookie   *cookiejar.Jar
	BasePath = map[string]string{
		PathGetUserInfo:         BaseHost,
		PathCheckUserLiveStatus: BaseLiveHost,
	}
)
View Source
var (
	UserAgent   = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36 Edg/135.0.0.0"
	AcSignature = ""
	AcNonce     = ""
	Stop        = false
)

Functions

func DPath

func DPath(path string) string

func FreshLiveStatus

func FreshLiveStatus(id string) (bool, error)

func SetRequestOptions

func SetRequestOptions() []requests.Option

Types

type Concern

type Concern struct {
	*StateManager
	// contains filtered or unexported fields
}

func NewConcern

func NewConcern(notifyChan chan<- concern.Notify) *Concern

func (*Concern) Add

func (d *Concern) Add(ctx mmsg.IMsgCtx, groupCode int64, id interface{}, ctype concern_type.Type) (concern.IdentityInfo, error)

func (*Concern) AddUserInfo

func (d *Concern) AddUserInfo(info *UserInfo) error

func (Concern) CurrentLiveKey

func (e Concern) CurrentLiveKey(keys ...interface{}) string

func (*Concern) FindOrLoadUserInfo

func (d *Concern) FindOrLoadUserInfo(uid string) (*UserInfo, error)

func (*Concern) FindUserInfo

func (d *Concern) FindUserInfo(id string, refresh bool) (*UserInfo, error)

func (Concern) FreshKey

func (e Concern) FreshKey(keys ...interface{}) string

func (*Concern) Get

func (d *Concern) Get(id interface{}) (concern.IdentityInfo, error)

func (*Concern) GetCurrentLive

func (d *Concern) GetCurrentLive(id string) (bool, error)

func (*Concern) GetFreshTime

func (d *Concern) GetFreshTime(id string) (int64, error)

func (*Concern) GetStateManager

func (d *Concern) GetStateManager() concern.IStateManager

func (*Concern) GetUserInfo

func (d *Concern) GetUserInfo(uid string) (*UserInfo, error)

func (*Concern) GroupWatchNotify

func (d *Concern) GroupWatchNotify(groupCode int64, mid string)

func (*Concern) ParseId

func (d *Concern) ParseId(s string) (interface{}, error)

func (*Concern) Remove

func (d *Concern) Remove(ctx mmsg.IMsgCtx, groupCode int64, id interface{}, ctype concern_type.Type) (concern.IdentityInfo, error)

func (*Concern) SetCurrentLive

func (d *Concern) SetCurrentLive(id string, j interface{}) error

func (*Concern) SetFreshTime

func (d *Concern) SetFreshTime(id string, ts time.Time) error

func (*Concern) Site

func (d *Concern) Site() string

func (*Concern) Start

func (d *Concern) Start() error

func (*Concern) Stop

func (d *Concern) Stop()

func (*Concern) Types

func (d *Concern) Types() []concern_type.Type

func (Concern) UserInfoKey

func (e Concern) UserInfoKey(keys ...interface{}) string

type ConcernLiveNotify

type ConcernLiveNotify struct {
	GroupCode int64
	*LiveInfo
}

func NewConcernLiveNotify

func NewConcernLiveNotify(groupCode int64, info *LiveInfo) *ConcernLiveNotify

func (*ConcernLiveNotify) GetGroupCode

func (notify *ConcernLiveNotify) GetGroupCode() int64

func (*ConcernLiveNotify) Logger

func (notify *ConcernLiveNotify) Logger() *logrus.Entry

func (*ConcernLiveNotify) ToMessage

func (notify *ConcernLiveNotify) ToMessage() (m *mmsg.MSG)

type GroupConcernConfig

type GroupConcernConfig struct {
	concern.IConfig
}

GroupConcernConfig 创建一个新结构,准备重写 FilterHook

func NewGroupConcernConfig

func NewGroupConcernConfig(g concern.IConfig) *GroupConcernConfig

NewGroupConcernConfig 创建一个新的 GroupConcernConfig

func (*GroupConcernConfig) FilterHook

FilterHook 可以在这里自定义过滤逻辑

type LiveInfo

type LiveInfo struct {
	UserInfo
	IsLiving bool `json:"living"`
	// contains filtered or unexported fields
}

func (*LiveInfo) GetMSG

func (l *LiveInfo) GetMSG() *mmsg.MSG

func (*LiveInfo) IsLive

func (l *LiveInfo) IsLive() bool

func (*LiveInfo) LiveStatusChanged

func (l *LiveInfo) LiveStatusChanged() bool

func (*LiveInfo) Living

func (l *LiveInfo) Living() bool

func (*LiveInfo) Logger

func (l *LiveInfo) Logger() *logrus.Entry

func (*LiveInfo) Site

func (l *LiveInfo) Site() string

func (*LiveInfo) TitleChanged

func (l *LiveInfo) TitleChanged() bool

func (*LiveInfo) Type

func (l *LiveInfo) Type() concern_type.Type

type LiveStatus

type LiveStatus struct {
	StatusCode int `json:"status_code"`
	Data       []struct {
		SceneId  int `json:"scene_id"`
		UserLive []struct {
			AdType       int    `json:"ad_type"`
			FilterReason string `json:"filter_reason"`
			LiveStatus   int    `json:"live_status"`
			Msg          string `json:"msg"`
			RoomId       int64  `json:"room_id"`
			RoomIdStr    string `json:"room_id_str"`
			UserId       int64  `json:"user_id"`
			UserIdStr    string `json:"user_id_str"`
		} `json:"user_live"`
	} `json:"data"`
	Extra struct {
		Now int64 `json:"now"`
	} `json:"extra"`
}

type StateManager

type StateManager struct {
	*concern.StateManager
	// contains filtered or unexported fields
}

func (*StateManager) CurrentLiveKey

func (e *StateManager) CurrentLiveKey(keys ...interface{}) string

func (*StateManager) FreshKey

func (e *StateManager) FreshKey(keys ...interface{}) string

func (*StateManager) GetGroupConcernConfig

func (d *StateManager) GetGroupConcernConfig(groupCode int64, id interface{}) concern.IConfig

GetGroupConcernConfig 重写 concern.StateManager 的GetGroupConcernConfig方法,让我们自己定义的 GroupConcernConfig 生效

func (*StateManager) UserInfoKey

func (e *StateManager) UserInfoKey(keys ...interface{}) string

type UserInfo

type UserInfo struct {
	Uid       string `json:"uid"`
	SecUid    string `json:"secUid"`
	NikeName  string `json:"nickname"`
	RealName  string `json:"realName"`
	Desc      string `json:"desc"`
	WebRoomId string `json:"web_rid"`
}

func GetUserInfo

func GetUserInfo(uid string) (*UserInfo, error)

func ParseUserInfoResp

func ParseUserInfoResp(body []byte) (*UserInfo, error)

func (*UserInfo) GetName

func (u *UserInfo) GetName() string

func (*UserInfo) GetRoomId

func (u *UserInfo) GetRoomId() string

func (*UserInfo) GetUid

func (u *UserInfo) GetUid() interface{}

func (*UserInfo) SetRoomId

func (u *UserInfo) SetRoomId(strId string)

type UserInfoResp

type UserInfoResp struct {
	User struct {
		StatusCode int         `json:"statusCode"`
		StatusMsg  interface{} `json:"statusMsg"`
		LogPb      struct {
			ImprId string `json:"impr_id"`
		} `json:"logPb"`
		User struct {
			Uid                        string      `json:"uid"`
			SecUid                     string      `json:"secUid"`
			ShortId                    string      `json:"shortId"`
			RealName                   string      `json:"realName"`
			RemarkName                 string      `json:"remarkName"`
			Nickname                   string      `json:"nickname"`
			Desc                       string      `json:"desc"`
			DescExtra                  any         `json:"descExtra"`
			Gender                     interface{} `json:"gender"`
			AvatarUrl                  string      `json:"avatarUrl"`
			Avatar300Url               string      `json:"avatar300Url"`
			FollowStatus               int         `json:"followStatus"`
			FollowerStatus             int         `json:"followerStatus"`
			AwemeCount                 int         `json:"awemeCount"`
			FollowingCount             int         `json:"followingCount"`
			FollowerCount              int         `json:"followerCount"`
			FollowerCountStr           string      `json:"followerCountStr"`
			MplatformFollowersCount    int         `json:"mplatformFollowersCount"`
			MplatformFollowersCountStr string      `json:"mplatformFollowersCountStr"`
			FavoritingCount            int         `json:"favoritingCount"`
			WatchLaterCount            int         `json:"watchLaterCount"`
			TotalFavorited             int         `json:"totalFavorited"`
			TotalFavoritedStr          string      `json:"totalFavoritedStr"`
			HideTotalFavorited         string      `json:"hideTotalFavorited"`
			UserCollectCount           struct {
				LogPb            string `json:"logPb"`
				CollectCountList string `json:"collectCountList"`
				StatusCode       string `json:"statusCode"`
				Extra            string `json:"extra"`
			} `json:"userCollectCount"`
			UniqueId          string `json:"uniqueId"`
			CustomVerify      string `json:"customVerify"`
			GeneralPermission struct {
				FansPageToast              int  `json:"fans_page_toast"`
				FollowingFollowerListToast int  `json:"following_follower_list_toast"`
				IsHitActiveFansGrayed      bool `json:"is_hit_active_fans_grayed"`
			} `json:"generalPermission"`
			PunishRemindInfo       string      `json:"punishRemindInfo"`
			Age                    interface{} `json:"age"`
			Birthday               string      `json:"birthday"`
			Country                interface{} `json:"country"`
			Province               interface{} `json:"province"`
			City                   interface{} `json:"city"`
			District               interface{} `json:"district"`
			School                 interface{} `json:"school"`
			SchoolVisible          string      `json:"schoolVisible"`
			EnterpriseVerifyReason string      `json:"enterpriseVerifyReason"`
			Secret                 int         `json:"secret"`
			UserCanceled           bool        `json:"userCanceled"`
			RoomData               struct {
				Status    int `json:"status"`
				UserCount int `json:"user_count"`
				StreamUrl struct {
					DefaultResolution string `json:"default_resolution"`
					Extra             struct {
						Height int `json:"height"`
						Width  int `json:"width"`
					} `json:"extra"`
					FlvPullUrl struct {
						FULLHD1 string `json:"FULL_HD1"`
						HD1     string `json:"HD1"`
						SD1     string `json:"SD1"`
						SD2     string `json:"SD2"`
					} `json:"flv_pull_url"`
					CandidateResolution []string `json:"candidate_resolution"`
					FlvPullUrlParams    struct {
						HD1 string `json:"HD1"`
						SD1 string `json:"SD1"`
						SD2 string `json:"SD2"`
					} `json:"flv_pull_url_params"`
					LiveCoreSdkData struct {
						PullData struct {
							StreamData string `json:"stream_data"`
							Options    struct {
								DefaultQuality struct {
									Name   string `json:"name"`
									SdkKey string `json:"sdk_key"`
								} `json:"default_quality"`
								Qualities []struct {
									Name       string `json:"name"`
									SdkKey     string `json:"sdk_key"`
									VCodec     string `json:"v_codec"`
									Resolution string `json:"resolution"`
									Level      int    `json:"level"`
									VBitRate   int    `json:"v_bit_rate"`
									Fps        int    `json:"fps,omitempty"`
								} `json:"qualities"`
							} `json:"options"`
						} `json:"pull_data"`
					} `json:"live_core_sdk_data"`
					StreamOrientation int `json:"stream_orientation"`
					Play              struct {
						Horizontal string `json:"horizontal"`
						Vertical   string `json:"vertical"`
					} `json:"play"`
				} `json:"stream_url"`
				Owner struct {
					WebRid string `json:"web_rid"`
				} `json:"owner"`
				LiveTypeNormal bool `json:"live_type_normal"`
				PaidLiveData   struct {
					PayAbType int `json:"pay_ab_type"`
				} `json:"paid_live_data"`
				EcomData struct {
					RoomCartV2 struct {
						ShowCart int `json:"show_cart"`
					} `json:"room_cart_v2"`
				} `json:"ecom_data"`
				PackMeta struct {
					Scene   string `json:"scene"`
					Env     string `json:"env"`
					Dc      string `json:"dc"`
					Cluster string `json:"cluster"`
				} `json:"pack_meta"`
			} `json:"roomData"`
			ShareQrcodeUrl string `json:"shareQrcodeUrl"`
			ShareInfo      struct {
				BoolPersist   int    `json:"boolPersist"`
				ShareDesc     string `json:"shareDesc"`
				ShareImageUrl struct {
					Uri     string   `json:"uri"`
					UrlList []string `json:"url_list"`
				} `json:"shareImageUrl"`
				ShareQrcodeUrl struct {
					Uri     string        `json:"uri"`
					UrlList []interface{} `json:"url_list"`
				} `json:"shareQrcodeUrl"`
				ShareUrl       string `json:"shareUrl"`
				ShareWeiboDesc string `json:"shareWeiboDesc"`
			} `json:"shareInfo"`
			CoverAndHeadImageInfo struct {
				ProfileCoverList []struct {
					CoverUrl struct {
						Uri     string   `json:"uri"`
						UrlList []string `json:"urlList"`
					} `json:"coverUrl"`
					DarkCoverColor  string `json:"darkCoverColor"`
					LightCoverColor string `json:"lightCoverColor"`
				} `json:"profileCoverList"`
			} `json:"coverAndHeadImageInfo"`
			RoomId                       int64       `json:"roomId"`
			IsBlocked                    bool        `json:"isBlocked"`
			IsBlock                      bool        `json:"isBlock"`
			IsBan                        bool        `json:"isBan"`
			FavoritePermission           int         `json:"favoritePermission"`
			ShowFavoriteList             bool        `json:"showFavoriteList"`
			ViewHistoryPermission        bool        `json:"viewHistoryPermission"`
			IpLocation                   string      `json:"ipLocation"`
			IsNotShowBaseTag             string      `json:"isNotShowBaseTag"`
			IsGovMediaVip                bool        `json:"isGovMediaVip"`
			IsStar                       bool        `json:"isStar"`
			HideLocation                 string      `json:"hideLocation"`
			NeedSpecialShowFollowerCount bool        `json:"needSpecialShowFollowerCount"`
			IsNotShow                    bool        `json:"isNotShow"`
			AvatarAuditing               string      `json:"avatarAuditing"`
			ContinuationState            int         `json:"continuationState"`
			ImRoleIds                    interface{} `json:"im_role_ids"`
			RoomIdStr                    string      `json:"roomIdStr"`
			CloseConsecutiveChat         string      `json:"close_consecutive_chat"`
			AccountCertInfo              struct {
				LabelStyle   any    `json:"labelStyle"`
				LabelText    string `json:"labelText"`
				IsBizAccount any    `json:"isBizAccount"`
			} `json:"accountCertInfo"`
			ProfileRecordParams string      `json:"profileRecordParams"`
			ProfileRankLabel    interface{} `json:"profileRankLabel"`
			ProfileTabInfo      struct {
				ProfileLandingTab int           `json:"profile_landing_tab"`
				ProfileTabList    interface{}   `json:"profile_tab_list"`
				ProfileTabListV2  []interface{} `json:"profile_tab_list_v2"`
			} `json:"profileTabInfo"`
			IsOverFollower bool `json:"isOverFollower"`
		} `json:"user"`
	} `json:"user"`
	StatusCode    int         `json:"statusCode"`
	Mix           interface{} `json:"mix"`
	Series        interface{} `json:"series"`
	Post          interface{} `json:"post"`
	Uid           string      `json:"uid"`
	IsHideImpInfo bool        `json:"isHideImpInfo"`
	IsClient      bool        `json:"isClient"`
	OsInfo        struct {
		Os      string `json:"os"`
		Version string `json:"version"`
		IsMas   bool   `json:"isMas"`
	} `json:"osInfo"`
	IsSpider     bool   `json:"isSpider"`
	RedirectFrom string `json:"redirectFrom"`
}

Jump to

Keyboard shortcuts

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