summary refs log tree commit diff stats
path: root/cmd/cetus-bing
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/cetus-bing')
-rw-r--r--cmd/cetus-bing/cetus-bing.go127
1 files changed, 0 insertions, 127 deletions
diff --git a/cmd/cetus-bing/cetus-bing.go b/cmd/cetus-bing/cetus-bing.go
deleted file mode 100644
index 29ef6f4..0000000
--- a/cmd/cetus-bing/cetus-bing.go
+++ /dev/null
@@ -1,127 +0,0 @@
-package main
-
-import (
-	"encoding/json"
-	"flag"
-	"fmt"
-	"math/rand"
-	"time"
-
-	"framagit.org/andinus/cetus/pkg/background"
-	"framagit.org/andinus/cetus/pkg/bing"
-	"framagit.org/andinus/cetus/pkg/cetus"
-)
-
-type photo struct {
-	StartDate     string `json:"startdate"`
-	FullStartDate string `json:"fullstartdate"`
-	EndDate       string `json:"enddate"`
-	Url           string `json:"url"`
-	UrlBase       string `json:"urlbase"`
-	Copyright     string `json:"copyright"`
-	CopyrightLink string `json:"copyrightlink"`
-	Title         string `json:"title"`
-	Hsh           string `json:"hsh"`
-}
-
-type bpod struct {
-	Photos []photo `json:"images"`
-}
-
-var (
-	t         time.Duration
-	api       string
-	dump      bool
-	quiet     bool
-	random    bool
-	version   bool
-	pathOnly  bool
-	fetchOnly bool
-)
-
-func main() {
-	parseFlags()
-
-	if version {
-		cetus.Version()
-		return
-	}
-	rand.Seed(time.Now().Unix())
-
-	// Convert timeout to seconds
-	t = t * time.Second
-
-	body, err := bpodBody()
-	if dump {
-		fmt.Println(body)
-		return
-	}
-
-	bpod := bpod{}
-	err = json.Unmarshal([]byte(body), &bpod)
-	cetus.ErrChk("body unmarshal failed", err)
-
-	// if random was set then bpodRes holds list of multiple
-	// responses, choose a random response from the list
-	var i int = rand.Intn(len(bpod.Photos))
-	bpodPhoto := bpod.Photos[i]
-
-	// correct image path
-	bpodPhoto.Url = fmt.Sprintf("%s%s", "https://www.bing.com", bpodPhoto.Url)
-
-	// correct date format
-	dt, err := time.Parse("20060102", bpodPhoto.StartDate)
-	cetus.ErrChk("bpodPhoto.startDate parse failed", err)
-	bpodPhoto.StartDate = dt.Format("2006-01-02")
-
-	printDetails(bpodPhoto)
-
-	// if fetchOnly is true then don't set background
-	if fetchOnly {
-		return
-	}
-
-	err = background.Set(bpodPhoto.Url)
-	cetus.ErrChk("setting background failed", err)
-}
-
-func parseFlags() {
-	flag.BoolVar(&quiet, "quiet", false, "No output")
-	flag.BoolVar(&version, "version", false, "Cetus version")
-	flag.BoolVar(&fetchOnly, "fetch-only", false, "Don't set background, only fetch info")
-	flag.BoolVar(&dump, "dump", false, "Only dump received response")
-	flag.BoolVar(&random, "random", false, "Choose a random image (from 7 images)")
-	flag.BoolVar(&pathOnly, "path-only", false, "Print only path of the image")
-
-	flag.StringVar(&api, "api", "https://www.bing.com/HPImageArchive.aspx", "BPOD API URL")
-
-	flag.DurationVar(&t, "timeout", 32*time.Second, "Timeout for http client in seconds")
-	flag.Parse()
-
-}
-
-func printDetails(bpodPhoto photo) {
-	if quiet {
-		return
-	}
-	if pathOnly {
-		cetus.PrintPath(bpodPhoto.Url)
-		return
-	}
-	fmt.Printf("Title: %s\n\n", bpodPhoto.Title)
-	fmt.Printf("Copyright: %s\n", bpodPhoto.Copyright)
-	fmt.Printf("Copyright Link: %s\n", bpodPhoto.CopyrightLink)
-	fmt.Printf("Date: %s\n\n", bpodPhoto.StartDate)
-	fmt.Printf("URL: %s\n", bpodPhoto.Url)
-}
-
-func bpodBody() (string, error) {
-	reqInfo := make(map[string]string)
-	reqInfo["api"] = api
-	if random {
-		reqInfo["random"] = "true"
-	}
-
-	body, err := bing.GetBpodJson(reqInfo, t)
-	return body, err
-}
evision' href='/akkartik/mu/blame/SubX-addressing-modes.md?h=hlt&id=a7088a2fff34a9c76205536fa651207f2299169a'>^
e2e0f5cc ^
01013f2a ^









16f2bd11 ^
01013f2a ^


























3b81d748 ^


01013f2a ^






3b81d748 ^

01013f2a ^





9a524793 ^



3b81d748 ^

9a524793 ^
7817fdb2 ^

3b81d748 ^






dff67029 ^
7817fdb2 ^

3b81d748 ^
7817fdb2 ^





16f2bd11 ^

7817fdb2 ^



9a524793 ^


7817fdb2 ^
16f2bd11 ^
3b81d748 ^
7817fdb2 ^


9a524793 ^



2c64c52e ^
9a524793 ^


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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176