@@ -158,8 +158,23 @@ class HearingScraper extends EventScraper<HearingListItem, Hearing> {
158158 const hearing = Hearing . check ( eventData )
159159 const shouldScrape = withinCutoff ( hearing . startsAt . toDate ( ) )
160160
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+ }
161175 let maybeVideoURL = null
162176 let transcript = null
177+
163178 if ( ! hearing . videoFetchedAt && shouldScrape ) {
164179 const req = await fetch (
165180 `https://malegislature.gov/Events/Hearings/Detail/${ EventId } `
@@ -203,19 +218,19 @@ class HearingScraper extends EventScraper<HearingListItem, Hearing> {
203218 . set ( {
204219 videoAssemblyWebhookToken : sha256 ( newToken )
205220 } )
221+
222+ payload = {
223+ ...payload ,
224+ videoURL : maybeVideoURL ,
225+ videoFetchedAt : Timestamp . now ( ) ,
226+ videoAssemblyId : transcript . id
227+ }
206228 }
207229 }
208230 }
209231 }
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
219234 return event
220235 }
221236}
0 commit comments