JmComic

package module
v0.0.0-...-3550214 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_IMAGE_URL   = "https://cdn-msp.jmapinodeudzn.net"
	DEFAULT_USER_AGENTS = "" /* 127-byte string literal not displayed */
	VERSION             = "2.0.1"
)
View Source
const (
	API_SETTING = "/setting"
	API_SEARCH  = "/search"
	API_ALBUM   = "/album"
	API_CHAPTER = "/chapter"
)
View Source
const (
	API_SECRET_REQ  = "18comicAPPContent" // combine with timestamp
	API_SECRET_RESP = "185Hcomic3PAPP7R"  // combine with timestamp
	SVR_SECRET      = "diosfjckwpqpdfjkvnqQjsik"
)
View Source
const DOWNLOAD_TYPE_COVER = "<COVER>"
View Source
const NEW_SERVER_URL = "https://rup4a04-c02.tos-cn-hongkong.bytepluses.com/newsvr-2025.txt"

Variables

View Source
var (
	ImageUrl  = DEFAULT_IMAGE_URL
	UserAgent = DEFAULT_USER_AGENTS
	ApiHost   = constant.ApiHosts[0] // TODO: 轮换
)

Functions

func BuildApiHeaders

func BuildApiHeaders(t time.Time) map[string]string

func BuildCoverUrl

func BuildCoverUrl(comicId int) string

func BuildImageHeaders

func BuildImageHeaders() map[string]string

func BuildImageUrl

func BuildImageUrl(chapterId int, imageName string) string

func CalcNumParts

func CalcNumParts(chapterId int, imageName string) (numParts int)

CalcNumParts 计算混淆分块数

func DescrambleImage

func DescrambleImage(imgData []byte, num int) (_ []byte, err error)

DescrambleImage 反混淆图片

func DoApi

func DoApi(req *http.Request, t time.Time) ([]byte, error)

DoApi 带解密

func DownloadComicIter

func DownloadComicIter(ctx context.Context, chapter *Chapter) iter.Seq2[Image, error]

func DownloadCover

func DownloadCover(ctx context.Context, comicId int) ([]byte, error)

func DownloadCoversIter

func DownloadCoversIter(ctx context.Context, search *SearchResp) iter.Seq2[Image, error]

func Get

func Get(ctx context.Context, url string) (_ []byte, _ *http.Response, err error)

Get 返回 body

func GetApi

func GetApi(ctx context.Context, url string) ([]byte, error)

GetApi 带解密

func PostApi

func PostApi(ctx context.Context, url string, data io.Reader) ([]byte, error)

PostApi 带解密

func SetThreads

func SetThreads(n int)

SetThreads 设置下载并发数

func SetUseEnvProxy

func SetUseEnvProxy(b bool)

SetUseEnvProxy 设置是否使用系统环境变量中的代理

默认为 true

Types

type Album

type Album struct {
	Id          int      `json:"id"`
	Name        string   `json:"name"`
	Images      []string `json:"images"`      // empty
	Addtime     string   `json:"addtime"`     // timestamp (second)
	Description string   `json:"description"` // ""
	TotalViews  int      `json:"total_views"`
	Likes       int      `json:"likes"`

	Series   []Serie `json:"series"`    // empty when single
	SeriesId string  `json:"series_id"` // single: "0" || multi: == .Id

	CommentTotal int `json:"comment_total"`

	Author []string `json:"author"`
	Tags   []string `json:"tags"`
	Works  []string `json:"works"`  // 作品 // "公主连结"
	Actors []string `json:"actors"` // 人物 // "贪吃佩可"

	RelatedList []struct {
		Id     string   `json:"id"`
		Author string   `json:"author"`
		Name   string   `json:"name"`
		Images []string `json:"images"` // ""
	} `json:"related_list"`

	Liked      bool   `json:"liked"`
	IsFavorite bool   `json:"is_favorite"`
	IsAids     bool   `json:"is_aids"`
	Price      string `json:"price"`     // ""
	Purchased  string `json:"purchased"` // ""
}

func GetAlbum

func GetAlbum(ctx context.Context, comicId int) (*Album, error)

type ApiResponse

type ApiResponse struct {
	Code int    `json:"code"`
	Data string `json:"data"` // encrypted

}

func (*ApiResponse) Decrypt

func (ar *ApiResponse) Decrypt(t time.Time) ([]byte, error)

type Chapter

type Chapter struct {
	Id         int      `json:"id"`
	Series     []Serie  `json:"series"`
	Tags       string   `json:"tags"` // space separated list, empty after series[0]
	Name       string   `json:"name"`
	Images     []string `json:"images"`  // "00001.webp"
	Addtime    string   `json:"addtime"` // timestamp (second)
	SeriesId   int      `json:"series_id"`
	IsFavorite bool     `json:"is_favorite"`
	Liked      bool     `json:"liked"`
}

func GetChapter

func GetChapter(ctx context.Context, chapterId int) (*Chapter, error)

type ComicBasic

type ComicBasic struct {
	Id          string `json:"id"`
	Author      string `json:"author"`
	Description string `json:"description"` // null
	Name        string `json:"name"`
	Image       string `json:"image"` // ""

	Category    ComicBasicCategory `json:"category"`
	CategorySub ComicBasicCategory `json:"category_sub"`

	Liked      bool `json:"liked"`
	IsFavorite bool `json:"is_favorite"`
}

type ComicBasicCategory

type ComicBasicCategory struct {
	Id    string `json:"id"`    // "1", "2", "5"
	Title string `json:"title"` // "同人", "单本", "韩漫"
}

type Error

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

Error 附带了更详细的信息

jmErr := JmComic.UnwarpErr(err)
isXxx := jmErr.Is(JmComic.ErrXXX)

-

func UnwrapErr

func UnwrapErr(err error) *Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

func (*Error) Unwrap

func (e *Error) Unwrap() error

type Image

type Image struct {
	ChapterId           int    // 反混淆用
	Name                string // "00001.webp"
	P                   int
	Data                []byte
	Type                ImageType
	IsDescrambledNeeded bool
}

func (*Image) String

func (i *Image) String() string

type ImageType

type ImageType int
const (
	IMAGE_TYPE_UNKNOWN ImageType = iota

	IMAGE_TYPE_WEBP
	IMAGE_TYPE_JPEG
	IMAGE_TYPE_PNG
	IMAGE_TYPE_GIF
)

func (ImageType) String

func (it ImageType) String() string

type SearchResp

type SearchResp struct {
	SearchQuery string       `json:"search_query"`
	Total       int          `json:"total"`
	Content     []ComicBasic `json:"content"`
}
func Search(ctx context.Context, keyword string, order string, page int) (*SearchResp, error)

type Serie

type Serie struct {
	Id   string `json:"id"`
	Name string `json:"name"` // if .Name == "" { name = sort }
	Sort string `json:"sort"`
}

type Server

type Server struct {
	Setting   []string   `json:"Setting"`
	Server    []string   `json:"Server"`
	Jm3Server [][]string `json:"jm3_Server"` // [0]: host, [1]: "綫路n"
}

func GetServer

func GetServer(ctx context.Context) (*Server, error)

type Setting

type Setting struct {
	Version     string `json:"version"`      // "1.8.2"
	TestVersion string `json:"test_version"` // "1.8.2"
	StoreLink   string `json:"store_link"`

	IosVersion     string `json:"ios_version"`      // "1.8.2"
	IosTestVersion string `json:"ios_test_version"` // "1.8.2"
	IosStoreLink   string `json:"ios_store_link"`

	Jm3Version     string `json:"jm3_version"`      // "2.0.12"
	Jm3TestVersion string `json:"jm3_test_version"` // "2.0.12"
	Jm3StoreLink   string `json:"jm3_store_link"`

	Jm3IOSVersion     string `json:"jm3_ios_version"`      // "1.0.0"
	Jm3IOSTestVersion string `json:"jm3_ios_test_version"` // "1.0.0"
	Jm3DownloadUrl    string `json:"jm3_download_url"`

	IpCountry string `json:"ipcountry"` // "CA"

	NewYearEvent   bool   `json:"newYearEvent"`
	AdCacheVersion int    `json:"ad_cache_version"`
	BundleUrl      string `json:"bundle_url"`
	DownloadUrl    string `json:"download_url"`
	AppLandingPage string `json:"app_landing_page"`

	VersionInfo    string `json:"version_info"`
	Jm3IsHotUpdate bool   `json:"jm3_is_hot_update"`
	Jm3VersionInfo string `json:"jm3_version_info"`
	IsHotUpdate    bool   `json:"is_hot_update"`

	BaseUrl     string `json:"base_url"` // "https://www.cdnaspa.vip"
	DonateUrl   string `json:"donate_url"`
	MainWebHost string `json:"main_web_host"`

	// "https://tencent.jmdanjonproxy.xyz" | "https://cdn-msp.jmdanjonproxy.xyz"
	ImgHost string `json:"img_host"`
	// "https://tencent.jmdanjonproxy.xyz/media/logo/channel_log.png?v=" | "cdn-msp"
	ApiBannerPath string `json:"api_banner_path"`
	// "https://tencent.jmdanjonproxy.xyz/media/logo/new_logo.png" | "cdn-msp"
	LogoPath string `json:"logo_path"`

	FloatAd bool `json:"float_ad"`

	IsCn      int    `json:"is_cn"`
	CnBaseURL string `json:"cn_base_url"` // "https://www.cdnaspa.vip"

	AppShunts []SettingAppShunt `json:"app_shunts"`

	FoolsDayEvent bool `json:"foolsDayEvent"`
}

func GetSetting

func GetSetting(ctx context.Context) (*Setting, error)

type SettingAppShunt

type SettingAppShunt struct {
	Title string `json:"title"`
	Key   int    `json:"key"`
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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