Skip to content

Commit

Permalink
Fixed VR platform parsing.
Browse files Browse the repository at this point in the history
Added support for Valve Index VR headset type.
  • Loading branch information
Bilge committed Jul 24, 2019
1 parent ee71c85 commit 6b4425e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/Scrape/AppDetailsParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,26 @@ public static function parseStorePage(string $html): array
$crawler->filter('[for=review_type_negative] > .user_reviews_count')->text()
) : 0;

$purchaseArea = $crawler->filter(
'#game_area_purchase .game_area_purchase_game:not(.demo_above_purchase)'
)->first();

// Platforms.
$windows = $crawler->filter('.game_area_purchase_platform')->first()->filter('.win')->count() > 0;
$linux = $crawler->filter('.game_area_purchase_platform')->first()->filter('.linux')->count() > 0;
$mac = $crawler->filter('.game_area_purchase_platform')->first()->filter('.mac')->count() > 0;
$vive = $crawler->filter('.game_area_purchase_platform')->first()->filter('.htcvive')->count() > 0;
$occulus = $crawler->filter('.game_area_purchase_platform')->first()->filter('.oculusrift')->count() > 0;
$wmr = $crawler->filter('.game_area_purchase_platform')->first()->filter('.windowsmr')->count() > 0;
$platforms = $purchaseArea->filter('.game_area_purchase_platform')->first();
$windows = $platforms->filter('.win')->count() > 0;
$linux = $platforms->filter('.linux')->count() > 0;
$mac = $platforms->filter('.mac')->count() > 0;

// VR platforms.
$vrPlatforms = $crawler->filter(
'.block_title.vrsupport ~ .game_area_details_specs > a.name[href*="vrsupport=10"]'
)->each(static function (Crawler $crawler): string {
return preg_replace('[.*vrsupport=(\d+).*]', '$1', $crawler->attr('href'));
});
$vive = in_array('101', $vrPlatforms, true);
$occulus = in_array('102', $vrPlatforms, true);
$wmr = in_array('104', $vrPlatforms, true);
$valve_index = in_array('105', $vrPlatforms, true);

return compact(
'name',
Expand All @@ -61,7 +74,8 @@ public static function parseStorePage(string $html): array
'mac',
'vive',
'occulus',
'wmr'
'wmr',
'valve_index'
);
}

Expand Down
1 change: 1 addition & 0 deletions test/Functional/ScrapeAppDetailsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ public function testVrPlatforms()
self::assertTrue($app['vive']);
self::assertTrue($app['occulus']);
self::assertTrue($app['wmr']);
self::assertTrue($app['valve_index']);
}

/**
Expand Down

0 comments on commit 6b4425e

Please sign in to comment.