@@ -8,10 +8,12 @@ import { RecipeListUpdater } from '../helpers/RecipeListUpdater';
88import { RecipeMarkdownListUpdater } from '../helpers/RecipeMarkdownListUpdater' ;
99import { RecipeMarker } from '../helpers/RecipeMarker' ;
1010import { HanayamaHuzzle } from './HanayamaHuzzle' ;
11+ import { HanayamaHuzzlesRecipeSettings } from './settings/HanayamaHuzzlesRecipeSettings' ;
1112
1213export class HanayamaHuzzlesRecipe implements Recipe {
1314 static readonly NAME = 'Hanayama Huzzles' ;
1415 static readonly WEBPAGE = 'https://hanayama-toys.com/product-category/puzzles/huzzle' ;
16+ static readonly CHESS_PUZZLES_WEBPAGE = 'https://hanayama-toys.com/product-category/puzzles/huzzle/chess-puzzle' ;
1517
1618 static readonly #HEADERS: readonly string [ ] = [ 'Level' , 'Index' , 'Name' , 'Picture' , 'Status' ] ;
1719 static readonly #SCRAPE_URLS: readonly string [ ] = [
@@ -20,16 +22,16 @@ export class HanayamaHuzzlesRecipe implements Recipe {
2022 'https://hanayama-toys.com/product-category/puzzles/huzzle/level-3-normal' ,
2123 'https://hanayama-toys.com/product-category/puzzles/huzzle/level-4-hard' ,
2224 'https://hanayama-toys.com/product-category/puzzles/huzzle/level-5-expert' ,
23- 'https://hanayama-toys.com/product-category/puzzles/huzzle/level-6-grand-master' ,
24- 'https://hanayama-toys.com/product-category/puzzles/huzzle/chess-puzzle'
25+ 'https://hanayama-toys.com/product-category/puzzles/huzzle/level-6-grand-master'
2526 ] ;
2627
2728 #marker = new RecipeMarker ( HanayamaHuzzlesRecipe . NAME ) ;
2829
2930 constructor (
3031 private markdownTableFactory : MarkdownTableFactory ,
3132 private markdownTableConverter : MarkdownTableConverter ,
32- private trackablesUpdater : TrackablesUpdater
33+ private trackablesUpdater : TrackablesUpdater ,
34+ private settings : HanayamaHuzzlesRecipeSettings
3335 ) { }
3436
3537 async updatedListInContent ( content : string ) : Promise < string > {
@@ -51,7 +53,12 @@ export class HanayamaHuzzlesRecipe implements Recipe {
5153
5254 async #scrapeHuzzles( ) : Promise < HanayamaHuzzle [ ] > {
5355 const metadataRegex = new RegExp ( / \w + [ ] (?< level > \d + ) - (?< index > \d + ) [ ] (?< name > .+ ) / ) ; // https://regex101.com/r/1vGzHd/2
54- const scraper = new WebsiteScraper ( HanayamaHuzzlesRecipe . #SCRAPE_URLS) ;
56+
57+ const urls = [ ...HanayamaHuzzlesRecipe . #SCRAPE_URLS] ;
58+ if ( this . settings . includeChessPuzzles ) {
59+ urls . push ( HanayamaHuzzlesRecipe . CHESS_PUZZLES_WEBPAGE ) ;
60+ }
61+ const scraper = new WebsiteScraper ( urls ) ;
5562
5663 return await scraper . scrape (
5764 content => {
0 commit comments