✨ add back year to album detailed
This commit is contained in:
parent
5c93e58da4
commit
149fc48a00
|
|
@ -9,6 +9,7 @@
|
||||||
| `playlistId` | `string` | Playlist ID for Album |
|
| `playlistId` | `string` | Playlist ID for Album |
|
||||||
| `name` | `string` | Name |
|
| `name` | `string` | Name |
|
||||||
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
||||||
|
| `year` | `number \| null` | Year of release |
|
||||||
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
||||||
|
|
||||||
## TypeScript Source Code
|
## TypeScript Source Code
|
||||||
|
|
@ -20,6 +21,7 @@ interface AlbumDetailed {
|
||||||
playlistId: string
|
playlistId: string
|
||||||
name: string
|
name: string
|
||||||
artists: ArtistBasic[]
|
artists: ArtistBasic[]
|
||||||
|
year: number | null
|
||||||
thumbnails: ThumbnailFull[]
|
thumbnails: ThumbnailFull[]
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
| `playlistId` | `string` | Playlist ID for Album |
|
| `playlistId` | `string` | Playlist ID for Album |
|
||||||
| `name` | `string` | Name |
|
| `name` | `string` | Name |
|
||||||
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
| `artists` | [ArtistBasic](./ArtistBasic.html)`[]` | Creators of the Album |
|
||||||
|
| `year` | `number \| null` | Year of release |
|
||||||
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
| `thumbnails` | [ThumbnailFull](./ThumbnailFull.html)`[]` | Thumbnails |
|
||||||
| `description` | `string` | Description |
|
| `description` | `string` | Description |
|
||||||
| `songs` | [SongDetailed](./SongDetailed.html)`[]` | Songs in the Album |
|
| `songs` | [SongDetailed](./SongDetailed.html)`[]` | Songs in the Album |
|
||||||
|
|
@ -22,6 +23,7 @@ interface AlbumFull {
|
||||||
playlistId: string
|
playlistId: string
|
||||||
name: string
|
name: string
|
||||||
artists: ArtistBasic[]
|
artists: ArtistBasic[]
|
||||||
|
year: number | null
|
||||||
thumbnails: ThumbnailFull[]
|
thumbnails: ThumbnailFull[]
|
||||||
description: string
|
description: string
|
||||||
songs: SongDetailed[]
|
songs: SongDetailed[]
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ export interface AlbumDetailed extends AlbumBasic {
|
||||||
type: "ALBUM"
|
type: "ALBUM"
|
||||||
playlistId: string
|
playlistId: string
|
||||||
artists: ArtistBasic[]
|
artists: ArtistBasic[]
|
||||||
|
year: number | null
|
||||||
thumbnails: ThumbnailFull[]
|
thumbnails: ThumbnailFull[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { BOOLEAN, LIST, NUMBER, OBJECT, STRING } from "validate-any"
|
import { BOOLEAN, LIST, NULL, NUMBER, OBJECT, OR, STRING } from "validate-any"
|
||||||
import ObjectValidator from "validate-any/dist/validators/ObjectValidator"
|
import ObjectValidator from "validate-any/dist/validators/ObjectValidator"
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|
@ -54,6 +54,7 @@ export const ALBUM_DETAILED: ObjectValidator<AlbumDetailed> = OBJECT({
|
||||||
playlistId: STRING(),
|
playlistId: STRING(),
|
||||||
name: STRING(),
|
name: STRING(),
|
||||||
artists: LIST(ARTIST_BASIC),
|
artists: LIST(ARTIST_BASIC),
|
||||||
|
year: OR(NUMBER(), NULL()),
|
||||||
thumbnails: LIST(THUMBNAIL_FULL)
|
thumbnails: LIST(THUMBNAIL_FULL)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -108,6 +109,7 @@ export const ALBUM_FULL: ObjectValidator<AlbumFull> = OBJECT({
|
||||||
playlistId: STRING(),
|
playlistId: STRING(),
|
||||||
name: STRING(),
|
name: STRING(),
|
||||||
artists: LIST(ARTIST_BASIC),
|
artists: LIST(ARTIST_BASIC),
|
||||||
|
year: OR(NUMBER(), NULL()),
|
||||||
thumbnails: LIST(THUMBNAIL_FULL),
|
thumbnails: LIST(THUMBNAIL_FULL),
|
||||||
description: STRING(),
|
description: STRING(),
|
||||||
songs: LIST(SONG_DETAILED)
|
songs: LIST(SONG_DETAILED)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ export default class AlbumParser {
|
||||||
...albumBasic,
|
...albumBasic,
|
||||||
playlistId: traverseString(data, "buttonRenderer", "playlistId")(),
|
playlistId: traverseString(data, "buttonRenderer", "playlistId")(),
|
||||||
artists,
|
artists,
|
||||||
|
year: AlbumParser.processYear(
|
||||||
|
traverseString(data, "header", "subtitle", "text")(-1)
|
||||||
|
),
|
||||||
thumbnails,
|
thumbnails,
|
||||||
description: traverseString(data, "description", "text")(),
|
description: traverseString(data, "description", "text")(),
|
||||||
songs: traverseList(data, "musicResponsiveListItemRenderer").map(item =>
|
songs: traverseList(data, "musicResponsiveListItemRenderer").map(item =>
|
||||||
|
|
@ -49,6 +52,7 @@ export default class AlbumParser {
|
||||||
artistId: traverseString(run, "browseId")(),
|
artistId: traverseString(run, "browseId")(),
|
||||||
name: traverseString(run, "text")()
|
name: traverseString(run, "text")()
|
||||||
})),
|
})),
|
||||||
|
year: AlbumParser.processYear(traverseString(flexColumns[1], "runs", "text")(-1)),
|
||||||
name: traverseString(flexColumns[0], "runs", "text")(),
|
name: traverseString(flexColumns[0], "runs", "text")(),
|
||||||
thumbnails: traverseList(item, "thumbnails")
|
thumbnails: traverseList(item, "thumbnails")
|
||||||
},
|
},
|
||||||
|
|
@ -64,6 +68,7 @@ export default class AlbumParser {
|
||||||
playlistId: traverseString(item, "thumbnailOverlay", "playlistId")(),
|
playlistId: traverseString(item, "thumbnailOverlay", "playlistId")(),
|
||||||
name: traverseString(item, "title", "text")(),
|
name: traverseString(item, "title", "text")(),
|
||||||
artists: [artistBasic],
|
artists: [artistBasic],
|
||||||
|
year: AlbumParser.processYear(traverseString(item, "subtitle", "text")(-1)),
|
||||||
thumbnails: traverseList(item, "thumbnails")
|
thumbnails: traverseList(item, "thumbnails")
|
||||||
},
|
},
|
||||||
ALBUM_DETAILED
|
ALBUM_DETAILED
|
||||||
|
|
@ -78,9 +83,14 @@ export default class AlbumParser {
|
||||||
playlistId: traverseString(item, "musicPlayButtonRenderer", "playlistId")(),
|
playlistId: traverseString(item, "musicPlayButtonRenderer", "playlistId")(),
|
||||||
name: traverseString(item, "title", "text")(),
|
name: traverseString(item, "title", "text")(),
|
||||||
artists: [artistBasic],
|
artists: [artistBasic],
|
||||||
|
year: AlbumParser.processYear(traverseString(item, "subtitle", "text")(-1)),
|
||||||
thumbnails: traverseList(item, "thumbnails")
|
thumbnails: traverseList(item, "thumbnails")
|
||||||
},
|
},
|
||||||
ALBUM_DETAILED
|
ALBUM_DETAILED
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static processYear(year: string) {
|
||||||
|
return year.match(/^\d{4}$/) ? +year : null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue