Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // (2016-02-24, morning utc+1)
- // SO, this new version brings: repo info, "repo" and "packages" fields in the json, and is fully compatible with the bigger one
- // (2016-02-24, 02:30 AM utc+1)
- // this even newer versions changes the keys all by itself, depending on the "fields" array. change the array as you change your scrapper!
- // I wouldn't really care about the increased RAM usage of making another array at then if I were you, it's most probably negligeable.
- // change these as you like! they are what define your repo for installMii. Could even read them from a settings/config file
- $repoInfo = array();
- $repoInfo["name"] = "ChaosJester's Repo";
- $repoInfo["author"] = "ChaosJesterrrr";
- $repoInfo["website"] = "http://3dsrepo.chaosjester.net";
- // comment out/in the fields as you adapt your scraper!
- $fields = array(); // dont comment that one out, will break everything else
- $fields[] = "name";
- $fields[] = "short_description";
- $fields[] = "author";
- // those are commented out because your scraper doesnt put them in the master.list yet
- // $fields[] = "category";
- // $fields[] = "website";
- // $fields[] = "type";
- // $fields[] = "version";
- // $fields[] = "dl_path";
- // $fields[] = "info_path";
- $lines = array();
- $file = fopen("master.list", "r");
- if($file) {
- while(!feof($file)){
- $line = substr(fgets($file),0,-1);
- $lines[] = $line;
- }
- }
- fclose($file);
- array_pop($lines);
- $list = array_chunk($lines, sizeof($fields)); // cut the array that contained the lines into pieces to separate each app
- $i = 0;
- for($i;$i <= sizeof($list)-1;$i++) { // change the name of keys in the array to make the json compatible with installMii
- $j = 0;
- for($j;$j <= sizeof($fields)-1;$j++) {
- $list[$i][$fields[$j]] = substr($list[$i][$j],strlen($fields[$j])+3); // remove the "name = ", and things like that to only have the value ("3dscraft", or anything)
- unset($list[$i][$j]);// remove the old key that is not needed anymore and only take space (and would mess with json_encode)
- }
- }
- // create a new array before encoding to get the "repo" and "packages" part correctly
- $formattedjson = json_encode(array("repo"=>$repoInfo, "packages"=>$list));
- echo $formattedjson;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment