@@ -14,7 +14,7 @@ import {log} from '../lib/logger';
14
14
import { cats , rootCategories } from '../lib/const' ;
15
15
import welcome from '../lib/welcome' ;
16
16
import { SimulationsList } from '../lib/classes' ;
17
- import { barOptions , getIdAndLanguage } from '../lib/common' ;
17
+ import { barOptions } from '../lib/common' ;
18
18
import type { Category , LanguageDescriptor , LanguageItemPair , Meta , Simulation } from '../lib/types' ;
19
19
import { exit } from 'yargs' ;
20
20
@@ -187,7 +187,6 @@ const getItemCategories = (lang: string, slug: string): Category[] => {
187
187
188
188
189
189
const fetchSims = async ( ) : Promise < void > => {
190
- // console.log(simsTree);
191
190
log . info ( `Gathering sim links...` ) ;
192
191
const bar = new SingleBar ( barOptions , Presets . shades_classic ) ;
193
192
bar . start ( meta . count , 0 ) ;
@@ -220,23 +219,21 @@ const fetchSims = async (): Promise<void> => {
220
219
fallback = true ;
221
220
url = `en/simulation/${ ( sim . name ) } ` ;
222
221
response = await got ( url , { ...options } ) ;
223
- status = response . statusCode ;
224
222
}
225
223
}
226
224
if ( ! response ) throw new Error ( `Got no response from ${ options . prefixUrl } ${ url } ` ) ;
227
225
const { body} = response ;
228
226
if ( ! body ) throw new Error ( `Got no data (status = ${ status } ) from ${ options . prefixUrl } ${ url } ` ) ;
229
227
const $ = cheerio . load ( body ) ;
230
- const link = $ ( '.sim-download' ) . attr ( 'href' ) ;
231
- const [ realId ] = getIdAndLanguage ( link ) ;
228
+ const realId = sim . name ;
232
229
233
230
catalogs [ lang ] . add ( {
234
231
categories : getItemCategories ( lang , realId ) ,
235
232
id : realId ,
236
233
language : lang ,
237
- title : title || $ ( '.simulation-main- title' ) . text ( ) . trim ( ) ,
238
- topics : $ ( '.sim-page-content ul' ) . first ( ) . text ( ) . split ( '\n' ) . map ( t => t . trim ( ) ) . filter ( a => a ) ,
239
- description : $ ( '.simulation-panel-indent[itemprop ]' ) . text ( )
234
+ title : title || $ ( 'meta[name="og: title"] ' ) . attr ( 'content' ) ,
235
+ topics : [ ] , // See https://github.com/openzim/phet/issues/155 for more details
236
+ description : $ ( 'meta[name="description" ]' ) . attr ( 'content' )
240
237
} as Simulation ) ;
241
238
242
239
urlsToGet . push ( `https://phet.colorado.edu/sims/html/${ realId } /latest/${ realId } _${ lang } .html` ) ;
0 commit comments