@@ -158,8 +158,23 @@ class HearingScraper extends EventScraper<HearingListItem, Hearing> {
158
158
const hearing = Hearing . check ( eventData )
159
159
const shouldScrape = withinCutoff ( hearing . startsAt . toDate ( ) )
160
160
161
+ let payload : Hearing = {
162
+ id : `hearing-${ EventId } ` ,
163
+ type : "hearing" ,
164
+ content,
165
+ ...this . timestamps ( content )
166
+ }
167
+ if ( hearing ) {
168
+ payload = {
169
+ ...payload ,
170
+ videoURL : hearing . videoURL ,
171
+ videoFetchedAt : hearing . videoFetchedAt ,
172
+ videoAssemblyId : hearing . videoAssemblyId
173
+ }
174
+ }
161
175
let maybeVideoURL = null
162
176
let transcript = null
177
+
163
178
if ( ! hearing . videoFetchedAt && shouldScrape ) {
164
179
const req = await fetch (
165
180
`https://malegislature.gov/Events/Hearings/Detail/${ EventId } `
@@ -203,19 +218,19 @@ class HearingScraper extends EventScraper<HearingListItem, Hearing> {
203
218
. set ( {
204
219
videoAssemblyWebhookToken : sha256 ( newToken )
205
220
} )
221
+
222
+ payload = {
223
+ ...payload ,
224
+ videoURL : maybeVideoURL ,
225
+ videoFetchedAt : Timestamp . now ( ) ,
226
+ videoAssemblyId : transcript . id
227
+ }
206
228
}
207
229
}
208
230
}
209
231
}
210
- const event : Hearing = {
211
- id : `hearing-${ EventId } ` ,
212
- type : "hearing" ,
213
- content,
214
- videoURL : maybeVideoURL ? maybeVideoURL : undefined ,
215
- videoFetchedAt : maybeVideoURL ? Timestamp . now ( ) : undefined ,
216
- videoAssemblyId : transcript ? transcript . id : undefined ,
217
- ...this . timestamps ( content )
218
- }
232
+
233
+ const event : Hearing = payload
219
234
return event
220
235
}
221
236
}
0 commit comments