Feature: Get size by api for ptp btn and ggn (#66)

* chore: add package

* feat: get size by api for ptp and btn

* feat: download and parse torrent if not api

* feat: bypass tls check and load meta from file

* fix: no invite command needed for btn

* feat: add ggn api

* feat: imrpove logging

* feat: build request url

* feat: improve err logging
This commit is contained in:
Ludvig Lundgren 2022-01-05 23:52:29 +01:00 committed by GitHub
parent d2aa7c1e7e
commit 2ea2293745
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 2181 additions and 99 deletions

View file

@ -1,6 +1,10 @@
package domain
import "context"
import (
"context"
"github.com/dustin/go-humanize"
)
type IndexerRepo interface {
Store(indexer Indexer) (*Indexer, error)
@ -29,12 +33,22 @@ type IndexerDefinition struct {
Privacy string `json:"privacy"`
Protocol string `json:"protocol"`
URLS []string `json:"urls"`
Supports []string `json:"supports"`
Settings []IndexerSetting `json:"settings"`
SettingsMap map[string]string `json:"-"`
IRC *IndexerIRC `json:"irc"`
Parse IndexerParse `json:"parse"`
}
func (i IndexerDefinition) HasApi() bool {
for _, a := range i.Supports {
if a == "api" {
return true
}
}
return false
}
type IndexerSetting struct {
Name string `json:"name"`
Required bool `json:"required,omitempty"`
@ -74,3 +88,22 @@ type IndexerParseMatch struct {
TorrentURL string `json:"torrenturl"`
Encode []string `json:"encode"`
}
type TorrentBasic struct {
Id string `json:"Id"`
TorrentId string `json:"TorrentId,omitempty"`
InfoHash string `json:"InfoHash"`
Size string `json:"Size"`
}
func (t TorrentBasic) ReleaseSizeBytes() uint64 {
if t.Size == "" {
return 0
}
releaseSizeBytes, err := humanize.ParseBytes(t.Size)
if err != nil {
// log could not parse into bytes
}
return releaseSizeBytes
}