exsrapi

package module
v2.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2025 License: MIT Imports: 19 Imported by: 2

README

※ システム全体の構成要素と各要素の整合性のとれるバージョンについてはSRCGI - READMEの末尾にあります

exsrapi

A set of auxiliary functions for using the API of the video distribution service SHOWROOM

SHOWROOMのAPI、その使い方とサンプルソース

  【Windows】Githubにあるサンプルプログラムの実行方法

  【Unix/Linux】Githubにあるサンプルプログラムの実行方法

Documentation

Overview

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2024 chouette.21.00@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Ver.0.0.1 ConfigのFncを削除する。

Ver.0.1.0 ApiLiveCurrentUser()の引数roomidをstringとしたことへ対応する。ApiLiveCurrentUser()実行時のroomidにRoomid[0]を渡す。 Ver.1.0.0 下位の関数で戻り値をstatusかrerrに変更したことに対応する。

Copyright © 2025 chouette2100@gmail.com Released under the MIT license https://opensource.org/licenses/mit-license.php

Index

Constants

View Source
const Version = "00AD01"

Variables

View Source
var Hdrspc = ""
View Source
var SortByFollowers bool

Functions

func CheckExistingLock added in v2.3.0

func CheckExistingLock(lockFilePath string) bool

既存のロックファイルをチェックし、有効なプロセスが実行中かを確認

func CreateLogfile

func CreateLogfile(dsc ...string) (logfile *os.File, err error)

ログファイルを作る。

func CreateNewClient

func CreateNewClient(
	cookiename string,
) (
	client *http.Client,
	jar *cookiejar.Jar,
	err error,
)

HTTPクライアントを作り、cookiejarをセットする。

func FuncNameOfThisFunction

func FuncNameOfThisFunction(
	level int,
) (
	funcname string,
)

func GetEventidOfEventBox

func GetEventidOfEventBox(
	eventid string,
) (
	namelist []string,
	err error,
)

func GetEventinf

func GetEventinf(
	eventid string,
	eventinfo *Event_Inf,
) (
	err error,
)

GetEventinf は、イベント情報を取得します。

イベント情報は、Event_Inf構造体に格納されます。
イベント情報は、イベントIDを指定して取得します。

func GetEventinfAndRoomList

func GetEventinfAndRoomList(
	eventid string,
	breg int,
	ereg int,
	eventinfo *Event_Inf,
	roominfolist *RoomInfoList,
) (
	status int,
)

func GetEventinfAndRoomListBR

func GetEventinfAndRoomListBR(
	client *http.Client,
	eventid string,
	breg int,
	ereg int,
	eventinfo *Event_Inf,
	roominfolist *RoomInfoList,
) (
	status int,
)

func GetRoominfFromEventOfBR

func GetRoominfFromEventOfBR(
	client *http.Client,
	eventid string,
	breg int,
	ereg int,
) (
	roomlistinf *srapi.RoomListInf,
	err error,
)

func LoadConfig

func LoadConfig(filePath string, config interface{}) (err error)

設定ファイルを読み込む

以下の記事を参考にさせていただきました。
	【Go初学】設定ファイル、環境変数から設定情報を取得する
		https://note.com/artefactnote/n/n8c22d1ac4b86

func LoginShowroom

func LoginShowroom(
	client *http.Client,
	acct string,
	pswd string,
) (
	userid string,
	err error,
)

Showroomのサービスにログインし、ユーザIDを取得する。

func MakePeriod

func MakePeriod(
	started_at int64,
	ended_at int64,
) (
	period string,
	err error,
)

func MakeSampleTime

func MakeSampleTime(
	cval int,
	cvar int,
) (stm, sts int)

MakeSampleTime() 獲得ポイントを取得するタイミングをランダムに返す

5分に一回を前提として、240秒±40秒のように設定する。

func MkRoomsForStarCollec

func MkRoomsForStarCollec(
	client *http.Client,
	category string,
	aplmin int,
	maxnoroom int,
	excllist *ExclList,
	roomvisit *map[int]time.Time,
) (
	lives *[]srapi.Live,
	err error,
)

星集め、種集めの対象とするルームの一覧を作成する。

func PrintExf

func PrintExf(comment ...string) func()

func PrtHdr

func PrtHdr() (
	fncname string,
)

func SetThdata

func SetThdata(eventinf *Event_Inf, thdata *Thdata) (err error)

データ取得対象となるルームのポイント基準値を設定する。

func TestOfApiActivefanNextlevel

func TestOfApiActivefanNextlevel(filename string) (err error)

ファンレベルの達成状況を取得する

使用しているSHOWROOMのAPI
	srapi.ApiLiveCurrentUser()
	srapi.CsrfToken()
	srapi.UserLogin()
	srapi.ApiActivefanNextlevel()

Types

type Block

type Block struct {
	Label    string
	Block_id int
}

type BlockInf

type BlockInf struct {
	Show_rank_label string
	Block_list      []Block
}

type BlockInfList

type BlockInfList struct {
	Blockinf []BlockInf
}

func GetEventidOfBlockEvent

func GetEventidOfBlockEvent(
	eventid string,
) (
	blockinflist BlockInfList,

	err error,
)

ブロックイベントの子のイベントのeventidを取得する。

type Event_Inf

type Event_Inf struct {
	Event_ID    string
	I_Event_ID  int
	Event_name  string
	Period      string
	Dperiod     float64
	Start_time  time.Time
	Sstart_time string
	Start_date  float64
	End_time    time.Time
	Send_time   string
	NoEntry     int
	NoRoom      int //      ルーム数
	Intervalmin int
	Modmin      int
	Modsec      int
	Fromorder   int
	Toorder     int
	Resethh     int
	Resetmm     int
	Nobasis     int
	Maxdsp      int
	Cmap        int
	Target      int
	Rstatus     string
	Maxpoint    int //      グラフのy軸のスケールを固定する
	Thinit      int
	Thdelta     int
	MaxPoint    int //      DBには該当するものはない(データ中最大のポイント値を意味し、内部的に使用する)
	Gscale      int //      DBのMaxpoint = 構造体の Maxpoint + Gscale
	Achk        int //      1: ブロック、2:ボックス、子ルーム未処理のあいだはそれぞれ +4
	Aclr        int //		gtplの制御のために一時的に使用する

	EventStatus string //   "Over", "BeingHeld", "NotHeldYet"
	Pntbasis    int
	Ordbasis    int
	League_ids  string
	Valid       bool //	データとして有効か?(内部処理で処理の分岐に使う)

}

func ConvertEventToEventinf

func ConvertEventToEventinf(
	event *srapi.Event,
) (
	Eventinf *Event_Inf,
)

ApiEventSearch()で得られるイベント情報構造体 srapi.Eventを データベースのeventテーブルに対応したexsrapi.Event_Infに変換する

type ExclList

type ExclList map[int]string //	除外ルームIDリスト

除外リスト

func (ExclList) Read

func (el ExclList) Read(
	category string,
	exclfilename string,
) (
	err error,
)

除外リストの読み込み

type Ptdata

type Ptdata struct {
	Elm     [2]string // Elm[0] 対象となるイベントID(の一部)、#lm[1] 対象となるイベント名(の一部)
	Thinit  int       // 基準ポイントの初期値
	Thdelta int       // Thinit * Thdelta * イベント開始後の経過時間(hour) を基準ポイントとする
}

データ取得対象とするルームの基準ポイント

type RoomAfnl

type RoomAfnl struct {
	Room_id   string //	配信者のID
	Main_name string //	配信者の名前
	Afnl      srapi.ActiveFanNextLevel
}

配信者のリストから、ファンレベルの達成状況を調べる。

func GetActiveFanNextLevel

func GetActiveFanNextLevel(
	client *http.Client,
	userid string,
	rooms []srapi.RoomFollowed,
) (
	roomafnls []RoomAfnl,
	err error,
)

type RoomInfo

type RoomInfo struct {
	Name      string //     ルーム名のリスト
	Longname  string
	Shortname string
	Account   string //     アカウントのリスト、アカウントは配信のURLの最後の部分の英数字です。
	ID        string //     IDのリスト、IDはプロフィールのURLの最後の部分で5~6桁の数字です。
	Userno    int
	//      APIで取得できるデータ(1)
	Genre      string
	Rank       string
	Irank      int
	Nrank      string
	Prank      string
	Followers  int
	Sfollowers string
	Fans       int
	Fans_lst   int
	Level      int
	Slevel     string
	//      APIで取得できるデータ(2)
	Order        int
	Point        int //     イベント終了後12時間〜36時間はイベントページから取得できることもある
	Spoint       string
	Istarget     string
	Graph        string
	Iscntrbpoint string
	Color        string
	Colorvalue   string
	//	Colorinflist ColorInfList
	Formid      string
	Eventid     string
	Status      string
	Statuscolor string
}

type RoomInfoList

type RoomInfoList []RoomInfo

func (RoomInfoList) Choose

func (r RoomInfoList) Choose(from, to int) (s RoomInfoList)

func (RoomInfoList) Len

func (r RoomInfoList) Len() int

sort.Sort()のための関数三つ

func (RoomInfoList) Less

func (r RoomInfoList) Less(i, j int) bool

降順に並べる

func (RoomInfoList) Swap

func (r RoomInfoList) Swap(i, j int)

type RoomVisit

type RoomVisit struct {
	Rvlfn     string
	Category  string
	Roomvisit map[int]time.Time
}

訪問済みルーム情報

func (*RoomVisit) Restore

func (r *RoomVisit) Restore(
	category string,
	rvlfn string,
	aplmin int,
) (
	err error,
)

配信ルーム訪問情報の読み込み

func (*RoomVisit) Save

func (r *RoomVisit) Save() (
	err error,
)

配信ルーム訪問情報の書き出し

type Thdata

type Thdata struct {
	Hh      int
	From    int
	To      int
	Ptdlist []Ptdata
}

func ReadThdata

func ReadThdata() (
	thdata *Thdata,
	err error,
)

実行パラメータとデータ取得対象となるルームのポイント基準値を読み込む Thdata Hh int, 開催中のイベントとhh時間以内に始まるイベントをデータ取得対象とする。 From int, 順位がfromからtoまでの範囲をデータ取得の対象とする To int, Ptdlist *[]Ptdata, データ取得対象とするポイント基準

Jump to

Keyboard shortcuts

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