From 38612f4bc0fecd5009477cb1aeb5bc271ffd1c95 Mon Sep 17 00:00:00 2001 From: rouggy Date: Wed, 28 Aug 2024 12:51:23 +0700 Subject: [PATCH] update --- RaceNotifier.go | 104 +++++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 40 deletions(-) diff --git a/RaceNotifier.go b/RaceNotifier.go index db5f204..b36fd97 100644 --- a/RaceNotifier.go +++ b/RaceNotifier.go @@ -2,27 +2,38 @@ package main import ( "encoding/json" - "fmt" "log" "net" "os" ) type Race struct { - Id int `json:"id"` - Hash string `json:"hash"` - Name string `json:"name"` - Category string `json:"category"` - Content_Path string `json:"content_path"` - Root_Path string `json:"root_path"` - Save_Path string `json:"save_path"` - Size string `json:"size"` - Files string `json:"files"` + Id int `json:"id"` + Hash string `json:"hash"` + Name string `json:"name"` + Category string `json:"category"` + Indexer string `json:"indexer"` + Type string `json:"type"` + Title string `json:"title"` + Size string `json:"size"` + Files string `json:"files"` } type PreRace struct { - Name string `json:"name"` - Indexer string `json:"indexer"` + Id int `json:"id"` + Hash string `json:"hash"` + Name string `json:"name"` + Category string `json:"category"` + Indexer string `json:"indexer"` + Type string `json:"type"` + Title string `json:"title"` + Season string `json:"season"` + Episode string `json:"episode"` + Year string `json:"year"` + Resolution string `json:"resolution"` + Source string `json:"source"` + HDR string `json:"hdr"` + TorrentURL string `json:"torrenturl"` } func main() { @@ -40,9 +51,22 @@ func main() { // This is a pre race, need to find all the details of the release log.Printf("[PreRace] Prerace launched with details %v, %v, %v", os.Args[1], os.Args[2], os.Args[3]) - r := PreRace{Name: os.Args[2], Indexer: os.Args[3]} + r, _ := json.Marshal(PreRace{Hash: os.Args[2], + Name: os.Args[3], + Category: os.Args[4], + Indexer: os.Args[5], + Type: os.Args[6], + Title: os.Args[7], + Season: os.Args[8], + Episode: os.Args[9], + Year: os.Args[10], + Resolution: os.Args[11], + Source: os.Args[12], + HDR: os.Args[13], + TorrentURL: os.Args[14], + }) - tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000") + tcpAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:3000") if err != nil { log.Fatal("Could not parse IP address:", err) } @@ -53,7 +77,7 @@ func main() { defer conn.Close() - _, err = conn.Write([]byte(r.Indexer + " " + r.Name)) + _, err = conn.Write([]byte(r)) if err != nil { log.Fatal("Could not send message: ", err) } @@ -66,37 +90,37 @@ func main() { log.Println("Arg", n, "->", args) } - } else { - // This is the race thus the torrent has finished downloading. - r := Race{Name: os.Args[1], Category: os.Args[2], Content_Path: os.Args[3], Root_Path: os.Args[4], Save_Path: os.Args[5], Hash: os.Args[6], Size: os.Args[7], Files: os.Args[8]} - data, err := json.Marshal(r) + // } else { + // // This is the race thus the torrent has finished downloading. + // r := Race{Name: os.Args[1], Category: os.Args[2], Content_Path: os.Args[3], Root_Path: os.Args[4], Save_Path: os.Args[5], Hash: os.Args[6], Size: os.Args[7], Files: os.Args[8]} + // data, err := json.Marshal(r) - if err != nil { - fmt.Println(err) - } + // if err != nil { + // fmt.Println(err) + // } - err = os.WriteFile("test.json", data, 0644) - if err != nil { - log.Fatal(err) - } + // err = os.WriteFile("test.json", data, 0644) + // if err != nil { + // log.Fatal(err) + // } - tcpAddr, err := net.ResolveTCPAddr("tcp", "212.7.203.107:3000") - if err != nil { - log.Fatal("Could not parse IP address:", err) - } - conn, err := net.DialTCP("tcp", nil, tcpAddr) - if err != nil { - log.Fatal("Could not connect:", err) - } + // tcpAddr, err := net.ResolveTCPAddr("tcp", "127.0.0.1:3000") + // if err != nil { + // log.Fatal("Could not parse IP address:", err) + // } + // conn, err := net.DialTCP("tcp", nil, tcpAddr) + // if err != nil { + // log.Fatal("Could not connect:", err) + // } - defer conn.Close() + // defer conn.Close() - _, err = conn.Write([]byte(data)) - if err != nil { - log.Fatal("Could not send message: ", err) - } + // _, err = conn.Write([]byte(data)) + // if err != nil { + // log.Fatal("Could not send message: ", err) + // } - os.Exit(0) + // os.Exit(0) } }