This repository has been archived by the owner on Apr 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdefs.go
69 lines (56 loc) · 1.81 KB
/
defs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"sync"
)
// Declare Global Variables
const magnetheader string = "magnet:?xt=urn:btih:"
var apistr string = "https://torrent-paradise.ml/api/search?q="
var trackerurl string // tracker list in url
var torrents []Torrent // Array of Torrent
var query string // Query String
var trackerlisturl string // Tracker list URL
var trackerquery string // used in flag assignation
var selid int = -1 // Id of torrent selected
var errorui error // error to be displayed in error ui
var datafilename string // used in flag assignation
var datatype int // used in flag assignation
var waitforme sync.WaitGroup // used in some functions to wait for gentorrents to complete
// Structure of Torrent
type Torrent struct {
Id string `json:"id"`
Text string `json:"text"`
Length float64 `json:"len"`
Seeds int `json:"s"`
Leechs int `json:"l"`
}
type AscTorrents []Torrent
func (t AscTorrents) Len() int {
return len(t)
}
func (t AscTorrents) Less(i, j int) bool {
return t[i].Length < t[j].Length
}
func (t AscTorrents) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
}
type DeTorrents []Torrent
func (t DeTorrents) Len() int {
return len(t)
}
func (t DeTorrents) Less(i, j int) bool {
return t[i].Length > t[j].Length
}
func (t DeTorrents) Swap(i, j int) {
t[i], t[j] = t[j], t[i]
}
// color strings required to color text in terminal
var (
term_red string = "\u001b[0;31m" // Red color
term_green string = "\u001b[0;32m" // Green color
term_cyan string = "\u001b[0;36m" // Cyan color
term_blue string = "\u001b[0;34m" // Blue color
term_purp string = "\u001b[0;35m" // Purple color
term_yell string = "\u001b[0;33m" // Yellow color
term_res string = "\u001b[0;00m" // Color reset
term_grey string = "\u001b[0;37m" // Color Grey
)