| 264 | } |
| 265 | |
| 266 | async fetchColors(uri) { |
| 267 | let vibrant = 0; |
| 268 | try { |
| 269 | try { |
| 270 | const { fetchExtractedColorForTrackEntity } = Spicetify.GraphQL.Definitions; |
| 271 | const { data } = await Spicetify.GraphQL.Request(fetchExtractedColorForTrackEntity, { uri }); |
| 272 | const { hex } = data.trackUnion.albumOfTrack.coverArt.extractedColors.colorDark; |
| 273 | vibrant = Number.parseInt(hex.replace("#", ""), 16); |
| 274 | } catch { |
| 275 | const colors = await Spicetify.CosmosAsync.get(`https://spclient.wg.spotify.com/colorextractor/v1/extract-presets?uri=${uri}&format=json`); |
| 276 | vibrant = colors.entries[0].color_swatches.find((color) => color.preset === "VIBRANT_NON_ALARMING").color; |
| 277 | } |
| 278 | } catch { |
| 279 | vibrant = 8747370; |
| 280 | } |
| 281 | |
| 282 | this.setState({ |
| 283 | colors: { |
| 284 | background: Utils.convertIntToRGB(vibrant), |
| 285 | inactive: Utils.convertIntToRGB(vibrant, 3), |
| 286 | }, |
| 287 | }); |
| 288 | } |
| 289 | |
| 290 | async fetchTempo(uri) { |
| 291 | const audio = await Spicetify.CosmosAsync.get( |