Skip to content

cehbz/whatapi

 
 

Repository files navigation

whatapi

A Go wrapper for the What.CD JSON API

Install

go get "github.com/kdvh/whatapi"

Example

	wcd, err := whatapi.NewClient("https://what.cd/")
	if err != nil {
		log.Fatal(err)
	}
	
	err = wcd.Login("username", "password")
	if err != nil {
		log.Fatal(err)
	}
	
	mailboxParams := url.Values{}
	mailboxParams.Set("type", "sentbox")
	mailbox, err := wcd.GetMailbox(mailboxParams)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(mailbox)

	conversation, err := wcd.GetConversation(mailbox.Messages[0].ConvID)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(conversation.Messages[0].Body)

	torrentSearchParams := url.Values{}
	torrentSearchParams.Set("year", "2021") // https://github.com/OPSnet/Gazelle/blob/master/docs/07-API.md#torrent-search
	torrentSearch, err := wcd.SearchTorrents("foobar", torrentSearchParams)
	if err != nil {
		log.Fatal(err)
	}
	log.Println(torrentSearch.Results)

	downloadURL, err := wcd.CreateDownloadURL(torrentSearch.Results[0].Torrents[0].TorrentID)
	if err != nil {
		log.Fatal(downloadURL)
	}
	log.Println(downloadURL)

About

A Go wrapper for the What.CD JSON API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%