forked from supermamon/scriptable-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spotify-app.js
41 lines (31 loc) · 991 Bytes
/
spotify-app.js
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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-green; icon-glyph: rss-square;
/*
Script : spotify-app.js
Author : @supermamon
Version: 1.0.0
More Info: https://github.com/supermamon/oauth-proxy
*/
const FM = FileManager.iCloud();
const HOME = FM.documentsDirectory();
const Spotify = importModule('./spotify-api.js')
// new instance of the Spotify client
const app = new Spotify(FM.joinPath(HOME, 'spotify'))
// refresh token if needed
await app.refreshToken()
// get the latest played songs
let songs = await app.getLatestPlayed(25)
// display the list
let table = new UITable()
await songs.forEach( song => {
let row = new UITableRow()
let titleCell = UITableCell.text(song.name);
row.addCell(titleCell);
let countCell = UITableCell.text(song.played_at)
row.addCell(countCell);
row.height = 30
row.cellSpacing = 5
table.addRow(row)
})
QuickLook.present(table)