old101 / go-nyaa

πŸˆπŸ“¦ nyaa.si client library for Go

Home Page:https://nyaa.si

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸˆπŸ“¦ go-nyaa

Go Reference Go Report Card

nyaa.si client library for Go

Built on top of:
gofeed - search using RSS
colly - scrap torrent details page

Original idea:
ejnshtein/nyaa-api

Installation πŸ”¨

go get github.com/mmcdole/gofeed
go get github.com/gocolly/colly
go get -u github.com/irevenko/go-nyaa

Contributing 🀝

Contributions, issues and feature requests are welcome! πŸ‘
Feel free to check open issues.

Docs πŸ“’

Go reference, Examples

Search Example

Search returns []Torrent

import ( 
	"fmt"
	"log"

	"github.com/irevenko/go-nyaa/nyaa"
)

func main() {
    opt := nyaa.SearchOptions{
        Provider: "nyaa", // Provider is the only required option
        Query:    "LN",
        Category: "literature",
        SortBy:   "seeders",
        Filter:   "trusted-only",
    }

    torrents, err := nyaa.Search(opt)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println(torrents)
}

Search Options

type SearchOptions struct {
	Provider string
	Query    string
	Category string
	SortBy   string
	Filter   string
}

Provider

  • nyaa - nyaa.si
  • sukebei - sukebei.nyaa.si

Query

  • your desired search string

Category

nyaa

  • all - All Categories
  • anime - All Anime
    • anime-amv
    • anime-eng
    • anime-non-eng
    • anime-raw
  • audio - All Audio
    • audio-lossless
    • audio-lossy
  • literature - All Literature
    • literature-eng
    • literature-non-eng
    • literature-raw
  • live-action - All Live Action
    • live-action-idol-prom
    • live-action-eng
    • live-action-non-eng
    • live-action-raw
  • pictures - All Pictures
    • pictures-graphics
    • pictures-photos
  • software - All Software
    • software-apps
    • software-games

sukebei

  • all - All Categories
  • art - All Art
    • art-anime
    • art-doujinshi
    • art-manga
    • art-games
    • art-pictures
  • real-life - All Real Life
    • real-life-photos
    • real-life-videos

SortBy

  • comments
  • downloads
  • date
  • seeders
  • leechers
  • size

Filter

  • no-filter
  • no-remakes
  • trusted-only

TorrentComments

TorrentComments returns []Comment

import ( 
	"fmt"
	"log"
	
	"github.com/irevenko/go-nyaa/nyaa"
)

func main() {
	comms, err := nyaa.TorrentComments("https://nyaa.si/view/1366002") // nyaa.si or sukebei.nyaa.si
	if err != nil {
		log.Fatal(err)
	}

	for _, v := range comms {
		fmt.Println("user: " + v.User)
		fmt.Println("at: " + v.Date)
		fmt.Println("text: " + v.Text)
		fmt.Println()
	}
}

TorrentDescription

TorrentDescription returns string

import ( 
	"fmt"
	"log"

	"github.com/irevenko/go-nyaa/nyaa"
)

func main() {
	desc, err := nyaa.TorrentDescription("https://nyaa.si/view/1366002") // nyaa.si or sukebei.nyaa.si
	if err != nil {
		log.Fatal(err)
	}

   	fmt.Println(desc)
}

TorrentFiles

TorrentFiles returns []string

import ( 
	"fmt"
	"log"

	"github.com/irevenko/go-nyaa/nyaa"
)

func main() {
	files, err := nyaa.TorrentFiles("https://nyaa.si/view/1366002") // nyaa.si or sukebei.nyaa.si
	if err != nil {
		log.Fatal(err)
	}

	for _, v := range files {
		fmt.Println(v)
	}
}

Notes

  • Pagination does not work with RSS
  • Ascending sort does not work with RSS

Quick Start πŸš€

git clone https://github.com/irevenko/go-nyaa.git
cd go-nyaa
go get -d ./...
go run _examples/nyaa_search.go

What I Learned 🧠

  • RSS Feed, xml
  • Parsing html in Go

License πŸ“‘

(c) 2021 Ilya Revenko. MIT License

About

πŸˆπŸ“¦ nyaa.si client library for Go

https://nyaa.si

License:MIT License


Languages

Language:Go 100.0%