forked from muldjord/skyscraper
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a script that parses out the platforms, scrapers, aliases, file…
…masks from the cpp source to generate a platforms.json for use by people using hte JSON modifications from https://github.com/torresflo/skyscraper-enhanced.git which ill be merging into this repo shortly
- Loading branch information
Showing
3 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?php | ||
/** | ||
* Parses the src/platform.cpp file building a list of platforms and the scrapers, | ||
* file masks, and aliases for each. It then writes a platforms.json to replace the | ||
* existing one for the JSON backed list+options instead of CPP hardcoded list+options | ||
*/ | ||
$platforms = []; | ||
preg_match_all('/^(QString|QStringList) Platform::get(?P<list>[^\(]*)\([^\)]*\)(?P<data>.*)^}/msuU', file_get_contents(__DIR__.'/src/platform.cpp'), $matches); | ||
foreach ($matches['list'] as $idx => $list) { | ||
$list = strtolower($list); | ||
$data = $matches['data'][$idx]; | ||
// Platforms Scrapers Formats DefaultScraper Aliases | ||
if ($list == 'Platforms') { | ||
preg_match_all('/^.*\s?\w[^\.]+\.append\("(?P<data>[^"]*)"\);/muU', $data, $listMatches); | ||
foreach ($listMatches['data'] as $platform) | ||
$platforms[$platform] = ['name' => $platform]; | ||
} elseif (in_array($list, ['scrapers', 'formats', 'aliases'])) { | ||
preg_match_all('/platform == "(?P<platform>[^"]*)"\) \{(?P<data>[^\}]*)\}/msu', $data, $listMatches); | ||
foreach ($listMatches['platform'] as $idxPlat => $platform) { | ||
$platforms[$platform][$list] = []; | ||
$platData = $listMatches['data'][$idxPlat]; | ||
preg_match_all('/^.*\s?\w[^\.]+\.append\("(?P<data>[^"]*)"\);/muU', $platData, $platMatches); | ||
foreach ($platMatches['data'] as $idxValue => $value) | ||
$platforms[$platform][$list][] = $value; | ||
} | ||
} else { | ||
// do nothing | ||
} | ||
} | ||
echo json_encode($platforms, JSON_PRETTY_PRINT).PHP_EOL; | ||
file_put_contents('platforms_new.json', json_encode($platforms, JSON_PRETTY_PRINT)); |