mtorrent

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIPath_GenerateDownloadToken = "/api/torrent/genDlToken"
	APIPath_TorrentSearch         = "/api/torrent/search"
	APIPath_Profile               = "/api/member/profile"
)
View Source
const (
	TorrentSearchMode_Normal = "normal"
	TorrentSearchMode_Adult  = "adult"

	TorrentSearchDirection_Asc  = "ASC"
	TorrentSearchDirection_Desc = "DESC"

	// Torrent discount
	TorrentDiscount_Normal    = "NORMAL"
	TorrentDiscount_50Percent = "PERCENT_50" // 50%
	TorrentDiscount_70Percent = "PERCENT_70" // 30%
	TorrentDiscount_Free      = "FREE"       // Free
)

Variables

This section is empty.

Functions

func NewSite

func NewSite(name string, siteConfig *config.SiteConfigStruct, config *config.ConfigStruct) (site.Site, error)

Types

type DownloadTokenResponse

type DownloadTokenResponse struct {
	ResponseCode
	Data string `json:"data"`
}

type Float64String

type Float64String string

func (Float64String) Value

func (ci Float64String) Value() float64

type Int64

type Int64 int64

func (*Int64) MarshalJSON

func (ci *Int64) MarshalJSON() ([]byte, error)

func (*Int64) UnmarshalJSON

func (ci *Int64) UnmarshalJSON(data []byte) error

func (*Int64) Value

func (ci *Int64) Value() int64

type Int64String

type Int64String string

func (Int64String) Value

func (ci Int64String) Value() int64

type Profile

type Profile struct {
	Id               string `json:"id"`
	CreateDate       Time   `json:"createdDate"`
	LastModifiedDate Time   `json:"lastModifiedDate"`
	UserName         string `json:"username"`
	MemberCount      struct {
		Bonus      Int64String   `json:"bonus"`
		Uploaded   Int64String   `json:"uploaded"`
		Downloaded Int64String   `json:"downloaded"`
		ShareRate  Float64String `json:"shareRate"`
	} `json:"memberCount"`
}

type ProfileResponse

type ProfileResponse struct {
	ResponseCode
	Data Profile `json:"data"`
}

type ResponseCode

type ResponseCode struct {
	Message string `json:"message"`
	Code    Int64  `json:"code"`
}

func (ResponseCode) GetError

func (r ResponseCode) GetError() error

type Site

type Site struct {
	Name        string
	SiteConfig  *config.SiteConfigStruct
	HttpClient  *azuretls.Session
	HttpHeaders [][]string
}

func (*Site) DownloadTorrent

func (m *Site) DownloadTorrent(url string) (content []byte, filename string, id string, err error)

DownloadTorrent download torrent by url like `https://kp.m-team.cc/api/rss/dl?credential=xxx` if url is id, find real url by this id then call DownloadTorrentById

func (*Site) DownloadTorrentById

func (m *Site) DownloadTorrentById(id string) (content []byte, filename string, err error)

DownloadTorrentById download torrent by id

func (*Site) GetAllTorrents

func (m *Site) GetAllTorrents(sort string, desc bool, pageMarker string, baseUrl string) (torrents []*site.Torrent, nextPageMarker string, err error)

func (*Site) GetDefaultHttpHeaders

func (m *Site) GetDefaultHttpHeaders() [][]string

func (*Site) GetLatestTorrents

func (m *Site) GetLatestTorrents(full bool) ([]*site.Torrent, error)

func (*Site) GetName

func (m *Site) GetName() string

func (*Site) GetSiteConfig

func (m *Site) GetSiteConfig() *config.SiteConfigStruct

func (*Site) GetStatus

func (m *Site) GetStatus() (*site.Status, error)

func (*Site) PublishTorrent

func (m *Site) PublishTorrent(contents []byte, metadata neturl.Values) (id string, err error)

PublishTorrent implements site.Site.

func (*Site) PurgeCache

func (m *Site) PurgeCache()

func (*Site) SearchTorrents

func (m *Site) SearchTorrents(keyword string, baseUrl string) (torrents []*site.Torrent, err error)

type Time

type Time struct {
	time.Time
}

func (*Time) MarshalJSON

func (ct *Time) MarshalJSON() ([]byte, error)

func (*Time) UnixWithDefault

func (ct *Time) UnixWithDefault(defaultValue int64) int64

func (*Time) UnmarshalJSON

func (ct *Time) UnmarshalJSON(data []byte) error

type Torrent

type Torrent struct {
	Id               string        `json:"id"`
	CreateDate       *Time         `json:"createdDate"`
	LastModifiedDate *Time         `json:"lastModifiedDate"`
	Name             string        `json:"name"`
	Description      string        `json:"smallDescr"`
	Category         string        `json:"category"`
	Size             Int64         `json:"size"`
	Status           TorrentStatus `json:"status"`
}

type TorrentList

type TorrentList struct {
	PageNumber Int64     `json:"pageNumber"`
	PageSize   Int64     `json:"pageSize"`
	Total      Int64     `json:"total"`
	TotalPages Int64     `json:"totalPages"`
	Data       []Torrent `json:"data"`
}

type TorrentSearchRequest

type TorrentSearchRequest struct {
	Mode          string   `json:"mode"`
	Categories    []string `json:"categories"`
	Visible       int      `json:"visible"`
	Keyword       string   `json:"keyword,omitempty"`
	PageNumber    int64    `json:"pageNumber"`
	PageSize      int      `json:"pageSize"`
	SortDirection string   `json:"sortDirection,omitempty"`
	SortField     string   `json:"sortField,omitempty"`
}

func NewTorrentSearchRequest

func NewTorrentSearchRequest(opts ...TorrentSearchRequestOption) TorrentSearchRequest

type TorrentSearchRequestOption

type TorrentSearchRequestOption func(*TorrentSearchRequest)

func WithKeyword

func WithKeyword(keyword string) TorrentSearchRequestOption

func WithMode

func WithMode(mode string) TorrentSearchRequestOption

func WithPageNumber

func WithPageNumber(pageNumber int64) TorrentSearchRequestOption

func WithSortDirection

func WithSortDirection(desc bool) TorrentSearchRequestOption

func WithSortField

func WithSortField(field string) TorrentSearchRequestOption

type TorrentSearchResponse

type TorrentSearchResponse struct {
	ResponseCode
	Data TorrentList `json:"data"`
}

type TorrentStatus

type TorrentStatus struct {
	Discount        string `json:"discount"`
	DiscountEndTime *Time  `json:"discountEndTime"`
	Leechers        Int64  `json:"leechers"`
	Seeders         Int64  `json:"seeders"`
	Status          string `json:"status"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳