Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Category ¶
type Category int
Category represents the category for searching torrents in Nyaa. The available category varies by different providers.
const ( CategoryAll Category = 0x000 CategoryNyaaAnime Category = 0x110 CategoryNyaaAnimeMusicVideo Category = 0x111 CategoryNyaaAnimeEnglishTranslated Category = 0x112 CategoryNyaaAnimeNonEnglishTranslated Category = 0x113 CategoryNyaaAnimeRaw Category = 0x114 CategoryNyaaAudio Category = 0x120 CategoryNyaaAudioLossless Category = 0x121 CategoryNyaaAudioLossy Category = 0x122 CategoryNyaaLiterature Category = 0x130 CategoryNyaaLiteratureEnglishTranslated Category = 0x131 CategoryNyaaLiteratureNonEnglishTranslated Category = 0x132 CategoryNyaaLiteratureRaw Category = 0x133 CategoryNyaaLiveAction Category = 0x140 CategoryNyaaLiveActionEnglishTranslated Category = 0x141 CategoryNyaaPictures Category = 0x150 CategoryNyaaPicturesGraphics Category = 0x151 CategoryNyaaPicturesPhotos Category = 0x152 CategoryNyaaSoftware Category = 0x160 CategoryNyaaSoftwareApplications Category = 0x161 CategoryNyaaSoftwareGames Category = 0x162 CategorySukebeiArt Category = 0x210 CategorySukebeiArtAnime Category = 0x211 CategorySukebeiArtDoujinshi Category = 0x212 CategorySukebeiArtGames Category = 0x213 CategorySukebeiArtManga Category = 0x214 CategorySukebeiArtPictures Category = 0x215 CategorySukebeiRealLife Category = 0x220 CategorySukebeiRealLifePhotobooksAndPictures Category = 0x221 CategorySukebeiRealLifeVideos Category = 0x222 )
The categories for the currently supported providers.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a Nyaa client.
func (*Client) Search ¶
Search sends a request based on the given SearchOptions and returns the matched torrents information.
Example ¶
c := nyaa.NewClient() torrents, _, err := c.Search(context.Background(), nyaa.SearchOptions{ Provider: nyaa.ProviderNyaa, FilterBy: nyaa.FilterByNoFilter, Category: nyaa.CategoryAll, Query: "Nana Mizuki - NANA CLIP 8 BDMV", SortBy: nyaa.SortByDate, SortOrder: nyaa.SortOrderDesc, }) if err != nil { log.Fatalln(err) } for _, torrent := range torrents { fmt.Printf("%s\n", torrent.Name) fmt.Printf(" - %s\n", torrent.Category) fmt.Printf(" - %s\n", torrent.Size) fmt.Printf(" - %s\n", torrent.Link) fmt.Printf(" - %s\n", torrent.Date.UTC()) // fmt.Printf(" - %d\n", torrent.Seeders) // fmt.Printf(" - %d\n", torrent.Leechers) // fmt.Printf(" - %d\n", torrent.CompletedDownloads) }
Output: [水樹奈々] Nana Mizuki - NANA CLIP 8 BDMV - Live Action - Non-English-translated - 35.9 GiB - https://nyaa.si/download/1421189.torrent - 2021-08-15 00:06:05 +0000 UTC
type FilterBy ¶
type FilterBy int
FilterBy represents a way to filter the torrents when searching.
The current ways for filtering torrents.
type Page ¶ added in v0.3.0
type Page int
Page represents the page number in both request and response.
type PageInfo ¶ added in v0.3.0
PageInfo represents the pagination information parsed from the web page.
type Provider ¶
type Provider int
Provider represents the supported sites of Nyaa.
const ( // ProviderNyaa is for http://nyaa.si. ProviderNyaa Provider = iota // ProviderSukebei is for http://sukebei.nyaa.si (NSFW). ProviderSukebei )
Currently supported providers.
type SearchOptions ¶
type SearchOptions struct { Provider Provider FilterBy FilterBy Category Category Query string SortBy SortBy SortOrder SortOrder Page Page }
SearchOptions represents the options for searching torrents.
type SortBy ¶
type SortBy int
SortBy represents the way to sort the torrent when searching.
type SortOrder ¶
type SortOrder int
SortOrder represents the order of the torrent when searching.
type Torrent ¶
type Torrent struct { Category string `json:"category"` Name string `json:"name"` Link string `json:"link"` Magnet string `json:"magnet"` Size string `json:"size"` Date time.Time `json:"date"` Seeders int64 `json:"seeders"` Leechers int64 `json:"leechers"` CompletedDownloads int64 `json:"completeDownloads"` // contains filtered or unexported fields }
Torrent represents a torrent with information retrieved from Nyaa.