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
|
import {inspect} from 'node:util';
import {colors} from '#cli';
import {input, V} from '#composite';
import find from '#find';
import Thing from '#thing';
import {isDate, isStringNonEmpty, isURL} from '#validators';
import {parseContributors, parseDate} from '#yaml';
import {exposeConstant, exposeUpdateValueOrContinue}
from '#composite/control-flow';
import {constituteFrom} from '#composite/wiki-data';
import {
contributionList,
dimensions,
directory,
fileExtension,
soupyFind,
soupyReverse,
thing,
urls,
} from '#composite/wiki-properties';
export class MusicVideo extends Thing {
static [Thing.referenceType] = 'music-video';
static [Thing.wikiData] = 'musicVideoData';
static [Thing.getPropertyDescriptors] = ({ArtTag}) => ({
// Update & expose
thing: thing(),
label: {
flags: {update: true, expose: true},
update: {validate: isStringNonEmpty},
expose: {transform: value => value ?? 'Music video'},
},
unqualifiedDirectory: directory({name: 'label'}),
date: [
exposeUpdateValueOrContinue({
validate: input.value(isDate),
}),
constituteFrom('thing', V('date')),
],
url: {
flags: {update: true, expose: true},
update: {validate: isURL},
},
coverArtFileExtension: fileExtension(V('jpg')),
coverArtDimensions: dimensions(),
artistContribs: contributionList({
artistProperty: input.value('musicVideoArtistContributions'),
}),
contributorContribs: contributionList({
artistProperty: input.value('musicVideoContributorContributions'),
}),
// Update only
find: soupyFind(),
});
static [Thing.yamlDocumentSpec] = {
fields: {
'Label': {property: 'label'},
'Directory': {property: 'unqualifiedDirectory'},
'Date': {property: 'date', transform: parseDate},
'URL': {property: 'url'},
'Cover Art File Extension': {property: 'coverArtFileExtension'},
'Cover Art Dimensions': {property: 'coverArtDimensions'},
'Artists': {property: 'artistContribs', transform: parseContributors},
'Contributors': {property: 'contributorContribs', transform: parseContributors},
},
};
static [Thing.reverseSpecs] = {
musicVideoArtistContributionsBy:
soupyReverse.contributionsBy('musicVideoData', 'artistContribs'),
musicVideoContributorContributionsBy:
soupyReverse.contributionsBy('musicVideoData', 'contributorContribs'),
};
get path() {
if (!this.thing) return null;
if (!this.thing.getOwnMusicVideoCoverPath) return null;
return this.thing.getOwnMusicVideoCoverPath(this);
}
[inspect.custom](depth, options, inspect) {
const parts = [];
parts.push(Thing.prototype[inspect.custom].apply(this));
if (this.thing) {
if (depth >= 0) {
const newOptions = {
...options,
depth:
(options.depth === null
? null
: options.depth - 1),
};
parts.push(` for ${inspect(this.thing, newOptions)}`);
} else {
parts.push(` for ${colors.blue(Thing.getReference(this.thing))}`);
}
}
return parts.join('');
}
}
|