-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.go
125 lines (120 loc) · 3.81 KB
/
release.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
package main
import (
"fmt"
"github.com/hashworks/xRELTerminalClient/src/xrel"
"github.com/hashworks/xRELTerminalClient/src/xrel/types"
"os"
)
func showRelease(dirname string, isP2P bool) {
if isP2P {
release, err := xrel.GetP2PReleaseInfo(dirname, false)
ok(err, "Failed to get information about the p2p release:\n")
fmt.Println(release.Dirname)
fmt.Println("Link: " + release.LinkHref)
fmt.Println("Media: " + release.ExtInfo.LinkHref)
fmt.Println()
fmt.Printf("Size: %d MB\n", release.SizeInMB)
pubTime := release.GetPubTime()
postTime := release.GetPostTime()
if postTime == pubTime {
fmt.Println("Pub- & PostTime: " + pubTime.Format(xRELReleaseTimeFormat))
} else {
fmt.Println("PubTime: " + pubTime.Format(xRELReleaseTimeFormat))
fmt.Println("PostTime: " + postTime.Format(xRELReleaseTimeFormat))
}
fmt.Println()
if release.VideoRating != 0 {
fmt.Printf("Video: %2.1f★\n", release.VideoRating)
fmt.Printf("Audio: %2.1f★\n", release.AudioRating)
} else {
fmt.Println("No rating yet.")
}
fmt.Printf("Release has %d comments.\n", release.Comments)
} else {
release, err := xrel.GetReleaseInfo(dirname, false)
ok(err, "Failed to get information about the scene release:\n")
fmt.Println(release.Dirname)
fmt.Println("Link: " + release.LinkHref)
fmt.Println("Media: " + release.ExtInfo.LinkHref)
fmt.Println()
fmt.Printf("Size: %d %s\n", release.Size.Number, release.Size.Unit)
if release.ProofUrl != "" {
fmt.Println("Proof: " + release.ProofUrl)
}
fmt.Println("PreTime: " + release.GetTime().Format(xRELReleaseTimeFormat))
fmt.Println()
if release.VideoRating != 0 {
fmt.Printf("Video: %2.1f★\n", release.VideoRating)
fmt.Printf("Audio: %2.1f★\n", release.AudioRating)
} else {
fmt.Println("No rating yet.")
}
fmt.Printf("Release has %d comments.\n", release.Comments)
fmt.Println()
if release.NukeReason == "" {
fmt.Println("Release isn't nuked.")
} else {
fmt.Println("Release is nuked for \"" + release.NukeReason + "\"!")
}
}
}
func addComment(dirname string, isP2P bool, addComment string, rateVideo, rateAudio int) {
if (rateVideo != 0 && rateAudio == 0) || (rateVideo == 0 && rateAudio != 0) {
fmt.Println("You need to set either both or none of --rateVideo and --rateAudio.")
os.Exit(1)
}
var id string
if isP2P {
release, err := xrel.GetP2PReleaseInfo(dirname, false)
ok(err, "Failed to get information about the p2p release:\n")
id = release.Id
} else {
release, err := xrel.GetReleaseInfo(dirname, false)
ok(err, "Failed to get information about the scene release:\n")
id = release.Id
}
comment, err := xrel.AddComment(id, isP2P, addComment, rateVideo, rateAudio)
ok(err, "Failed to add comment:\n")
fmt.Println("Sucessfully added comment:")
printComment(comment)
}
func showComments(query string, isP2P bool, perPage, page int) {
var (
id string
err error
)
if isP2P {
var p2pRelease types.P2PRelease
p2pRelease, err = xrel.GetP2PReleaseInfo(query, false)
if err == nil {
id = p2pRelease.Id
}
} else {
var release types.Release
release, err := xrel.GetReleaseInfo(query, false)
if err == nil {
id = release.Id
}
}
ok(err, "Failed to get release:\n")
data, err := xrel.GetComments(id, isP2P, perPage, page)
ok(err, "Failed to get comments:\n")
commentCount := len(data.List)
if commentCount > 0 {
pagination := data.Pagination
if pagination.TotalPages > 1 {
fmt.Printf("Comments %d of %s (Page %d of %d):\n\n", commentCount, data.TotalCount, pagination.CurrentPage, pagination.TotalPages)
} else {
fmt.Println("Comments:\n")
}
for i := 0; i < commentCount; i++ {
if i > 0 {
fmt.Println("----------------------------------------------------------------\n")
}
printComment(data.List[i])
fmt.Print("\n")
}
} else {
fmt.Println("Release has no comments.")
}
}