File: README.md

package info (click to toggle)
golang-github-raitonoberu-lyricsapi 0.0~git20250321.2e8c45d-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 108 kB
  • sloc: makefile: 4
file content (368 lines) | stat: -rw-r--r-- 8,172 bytes parent folder | download | duplicates (2)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# lyricsapi
Go package and server app for retrieving time-stamped lyrics from Spotify.

## Usage

### Use as package

```bash
go get github.com/raitonoberu/lyricsapi
```

```go
package main

import (
	"fmt"
	"time"

	"github.com/raitonoberu/lyricsapi/spotify"
)

func main() {
	api := spotify.NewClient(`<YOUR COOKIE>`)
	lyrics, _ := api.GetByName("Rick Astley Never Gonna Give You Up")
	// Alternatively, specify the track id:
	// lyrics, _ := api.GetByID("4uLU6hMCjMI75M1A2tKUQC")
	if lyrics == nil {
		fmt.Println("Not found")
		return
	}
	for _, line := range lyrics {
		t := time.UnixMilli(int64(line.Time)).Format("04:05")
		fmt.Println(t, line.Words)
	}

}
```
<details>

```
00:19 We're no strangers to love
00:23 You know the rules and so do I
00:28 A full commitment's what I'm thinking of
00:32 You wouldn't get this from any other guy
00:36 I just wanna tell you how I'm feeling
00:41 Gotta make you understand
00:44 Never gonna give you up
00:46 Never gonna let you down
00:48 Never gonna run around and desert you
00:52 Never gonna make you cry
00:54 Never gonna say goodbye
00:56 Never gonna tell a lie and hurt you
01:02 We've known each other for so long
01:06 Your heart's been aching but you're too shy to say it
01:10 Inside we both know what's been going on
01:14 We know the game and we're gonna play it
01:18 And if you ask me how I'm feeling
01:23 Don't tell me you're too blind to see
01:26 Never gonna give you up
01:28 Never gonna let you down
01:30 Never gonna run around and desert you
01:34 Never gonna make you cry
01:36 Never gonna say goodbye
01:39 Never gonna tell a lie and hurt you
01:43 Never gonna give you up
01:45 Never gonna let you down
01:47 Never gonna run around and desert you
01:51 Never gonna make you cry
01:53 Never gonna say goodbye
01:56 Never gonna tell a lie and hurt you
02:01
02:03 (Give you up)
02:07 ♪
02:09 (Ooh) Never gonna give, never gonna give
02:11 (Give you up)
02:14 ♪
02:18 We've known each other for so long
02:22 Your heart's been aching but you're too shy to say it
02:26 Inside we both know what's been going on
02:30 We know the game and we're gonna play it
02:34 I just wanna tell you how I'm feeling
02:39 Gotta make you understand
02:42 Never gonna give you up
02:44 Never gonna let you down
02:46 Never gonna run around and desert you
02:51 Never gonna make you cry
02:53 Never gonna say goodbye
02:55 Never gonna tell a lie and hurt you
02:59 Never gonna give you up
03:01 Never gonna let you down
03:03 Never gonna run around and desert you
03:08 Never gonna make you cry
03:10 Never gonna say goodbye
03:12 Never gonna tell a lie and hurt you
03:16 Never gonna give you up
03:18 Never gonna let you down
03:20 Never gonna run around and desert you
03:25 Never gonna make you cry
03:27 Never gonna say goodbye
03:28
```
</details>

### Deploy to Vercel

1. https://vercel.com/docs/get-started
2. Set "COOKIE" environment variable.

```bash
# by name
curl -s "https://yourapp.vercel.app/api/lyrics?name=Rick%20Astley%20Never%20Gonna%20Give%20You%20Up" | jq
# by id
curl -s "https://yourapp.vercel.app/api/lyrics?id=4uLU6hMCjMI75M1A2tKUQC" | jq
```

<details>

```json
[
  {
    "time": 19670,
    "words": "We're no strangers to love"
  },
  {
    "time": 23560,
    "words": "You know the rules and so do I (do I)"
  },
  {
    "time": 27920,
    "words": "A full commitment's what I'm thinking of"
  },
  {
    "time": 32110,
    "words": "You wouldn't get this from any other guy"
  },
  {
    "time": 36050,
    "words": "I just wanna tell you how I'm feeling"
  },
  {
    "time": 41340,
    "words": "Gotta make you understand"
  },
  {
    "time": 43180,
    "words": "Never gonna give you up"
  },
  {
    "time": 45250,
    "words": "Never gonna let you down"
  },
  {
    "time": 47290,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 51520,
    "words": "Never gonna make you cry"
  },
  {
    "time": 53780,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 55730,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 60980,
    "words": "We've known each other for so long"
  },
  {
    "time": 64960,
    "words": "Your heart's been aching, but you're too shy to say it (say it)"
  },
  {
    "time": 69230,
    "words": "Inside, we both know what's been going on (going on)"
  },
  {
    "time": 73670,
    "words": "We know the game and we're gonna play it"
  },
  {
    "time": 77570,
    "words": "And if you ask me how I'm feeling"
  },
  {
    "time": 82450,
    "words": "Don't tell me you're too blind to see"
  },
  {
    "time": 85460,
    "words": "Never gonna give you up"
  },
  {
    "time": 87560,
    "words": "Never gonna let you down"
  },
  {
    "time": 89750,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 93960,
    "words": "Never gonna make you cry"
  },
  {
    "time": 96220,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 98290,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 102330,
    "words": "Never gonna give you up"
  },
  {
    "time": 104450,
    "words": "Never gonna let you down"
  },
  {
    "time": 106640,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 110980,
    "words": "Never gonna make you cry"
  },
  {
    "time": 112830,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 115130,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 119850,
    "words": "(Ooh, give you up)"
  },
  {
    "time": 124010,
    "words": "(Ooh, give you up)"
  },
  {
    "time": 128580,
    "words": "(Ooh) Never gonna give, never gonna give (give you up)"
  },
  {
    "time": 132580,
    "words": "(Ooh) Never gonna give, never gonna give (give you up)"
  },
  {
    "time": 137020,
    "words": "We've known each other for so long"
  },
  {
    "time": 141230,
    "words": "Your heart's been aching, but you're too shy to say it (to say it)"
  },
  {
    "time": 145520,
    "words": "Inside, we both know what's been going on (going on)"
  },
  {
    "time": 149810,
    "words": "We know the game and we're gonna play it"
  },
  {
    "time": 153900,
    "words": "I just wanna tell you how I'm feeling"
  },
  {
    "time": 159110,
    "words": "Gotta make you understand"
  },
  {
    "time": 161730,
    "words": "Never gonna give you up"
  },
  {
    "time": 163970,
    "words": "Never gonna let you down"
  },
  {
    "time": 165950,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 170220,
    "words": "Never gonna make you cry"
  },
  {
    "time": 172220,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 174380,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 178590,
    "words": "Never gonna give you up"
  },
  {
    "time": 180700,
    "words": "Never gonna let you down"
  },
  {
    "time": 182830,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 187260,
    "words": "Never gonna make you cry"
  },
  {
    "time": 189260,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 191390,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 195520,
    "words": "Never gonna give you up"
  },
  {
    "time": 197680,
    "words": "Never gonna let you down"
  },
  {
    "time": 199880,
    "words": "Never gonna run around and desert you"
  },
  {
    "time": 204060,
    "words": "Never gonna make you cry"
  },
  {
    "time": 206230,
    "words": "Never gonna say goodbye"
  },
  {
    "time": 208340,
    "words": "Never gonna tell a lie and hurt you"
  },
  {
    "time": 210980,
    "words": ""
  }
]
```
</details>

In header's `color` field you can find the primary color of the track. Pass `lrc=1` to get lyrics in [.lrc](https://en.wikipedia.org/wiki/LRC_(file_format)) file format.

### Where do I get cookie?

Press F12, open the `Network` tab and go to [open.spotify.com](https://open.spotify.com/). Click on the first request to `open.spotify.com`. Scroll down to the `Request Headers`, right click the `cookie` field and select `Copy value`.

## License

The Unlicense, see [LICENSE](./LICENSE) for additional information.