| 459 | } |
| 460 | |
| 461 | async getAlbumDate(uri) { |
| 462 | const { getAlbum } = Spicetify.GraphQL.Definitions; |
| 463 | const { errors, data } = await Spicetify.GraphQL.Request(getAlbum, { |
| 464 | uri, |
| 465 | locale: Spicetify.Locale.getLocale(), |
| 466 | offset: 0, |
| 467 | limit: 10, |
| 468 | }); |
| 469 | |
| 470 | if (errors) return null; |
| 471 | |
| 472 | const albumDate = data.albumUnion.date; |
| 473 | |
| 474 | // Avoid false release date (e.g., Jan 1, XXXX) |
| 475 | if (albumDate.precision === "YEAR") { |
| 476 | return albumDate.isoString.split("-")[0]; |
| 477 | } |
| 478 | |
| 479 | const date = new Date(albumDate.isoString); |
| 480 | |
| 481 | return date.toLocaleDateString("default", { |
| 482 | year: "numeric", |
| 483 | month: "short", |
| 484 | day: "numeric", |
| 485 | }); |
| 486 | } |
| 487 | |
| 488 | async fetchInfo() { |
| 489 | const meta = Spicetify.Player.data.item.metadata; |