Compare commits

...

5 Commits

Author SHA1 Message Date
7bdc01bdb9 1.42.0 2023-10-29 01:40:56 +02:00
b13403cf59 Use uupApiGetPacks in get.php 2023-10-29 00:07:48 +02:00
5777ff09b6 listeditions.php cleanup 2023-10-28 23:17:34 +02:00
954547ea84 listlangs.php cleanup 2023-10-28 23:03:40 +02:00
db1e155c8d uupGetGenPacks -> uupApiGetPacks 2023-10-28 23:02:43 +02:00
5 changed files with 51 additions and 90 deletions

View File

@ -77,7 +77,7 @@ function uupGetFiles(
}
if($usePack) {
$genPack = uupGetGenPacks($build, $info['arch'], $updateId);
$genPack = uupApiGetPacks($updateId);
if(empty($genPack)) return array('error' => 'UNSUPPORTED_COMBINATION');
if(!isset($genPack[$usePack])) {

View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2022 UUP dump API authors
Copyright 2023 UUP dump API authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -17,60 +17,35 @@ limitations under the License.
require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/packs.php';
require_once dirname(__FILE__).'/updateinfo.php';
function uupListEditions($lang = 'en-us', $updateId = 0) {
if($updateId) {
$info = uupUpdateInfo($updateId, false, true);
}
if(!$lang) {
return array('error' => 'UNSUPPORTED_LANG');
}
if(isset($info['info'])) $info = $info['info'];
if(isset($info['build'])) {
$build = explode('.', $info['build']);
$build = $build[0];
} else {
$build = 15063;
}
if(!isset($info['arch'])) {
$info['arch'] = null;
}
$genPack = uupGetGenPacks($build, $info['arch'], $updateId);
$fancyTexts = uupGetInfoTexts();
$fancyEditionNames = $fancyTexts['fancyEditionNames'];
if($lang) {
$lang = strtolower($lang);
$genPack = uupApiGetPacks($updateId);
$fancyEditionNames = uupGetInfoTexts()['fancyEditionNames'];
if(!isset($genPack[$lang])) {
return array('error' => 'UNSUPPORTED_LANG');
}
}
$editionList = array();
$editionListFancy = array();
$editionList = [];
$editionListFancy = [];
foreach(array_keys($genPack[$lang]) as $edition) {
if($edition == 'LXP') continue;
if($edition == 'FOD') continue;
if(in_array($edition, ['LXP', 'FOD'])) continue;
if(isset($fancyEditionNames[$edition])) {
$fancyName = $fancyEditionNames[$edition];
} else {
$fancyName = $edition;
}
$fancyName = isset($fancyEditionNames[$edition]) ? $fancyEditionNames[$edition] : $edition;
$editionList[] = $edition;
$editionListFancy[$edition] = $fancyName;
}
return array(
return [
'apiVersion' => uupApiVersion(),
'editionList' => $editionList,
'editionFancyNames' => $editionListFancy,
);
];
}

View File

@ -1,6 +1,6 @@
<?php
/*
Copyright 2022 UUP dump API authors
Copyright 2023 UUP dump API authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -19,63 +19,45 @@ require_once dirname(__FILE__).'/shared/main.php';
require_once dirname(__FILE__).'/shared/packs.php';
require_once dirname(__FILE__).'/updateinfo.php';
function uupListLangs($updateId = 0) {
if($updateId) {
$info = uupUpdateInfo($updateId, false, true);
}
function uupListLangsInternal($updateId) {
$genPack = uupApiGetPacks($updateId);
$fancyLangNames = uupGetInfoTexts()['fancyLangNames'];
if(isset($info['info'])) {
$info = $info['info'];
unset($info['files']);
}
$langList = [];
$langListFancy = [];
if(isset($info['build'])) {
$build = explode('.', $info['build']);
$build = $build[0];
} else {
$build = 15063;
}
if(!isset($info['arch'])) {
$info['arch'] = null;
}
$genPack = uupGetGenPacks($build, $info['arch'], $updateId);
$fancyTexts = uupGetInfoTexts();
$fancyLangNames = $fancyTexts['fancyLangNames'];
$langList = array();
$langListFancy = array();
foreach($genPack as $key => $val) {
if(!count(array_diff(array_keys($val), array('LXP')))) {
continue;
}
if(!count(array_diff(array_keys($val), array('FOD')))) {
if(!count(array_diff(array_keys($val), ['LXP', 'FOD']))) {
continue;
}
if(isset($fancyLangNames[$key])) {
$fancyName = $fancyLangNames[$key];
} else {
$fancyName = $key;
}
$fancyName = isset($fancyLangNames[$key]) ? $fancyLangNames[$key] : $key;
$langList[] = $key;
$langListFancy[$key] = $fancyName;
}
if(isset($info)) {
return array(
'apiVersion' => uupApiVersion(),
return [
'langList' => $langList,
'langFancyNames' => $langListFancy,
'updateInfo' => $info
);
} else {
return array(
'apiVersion' => uupApiVersion(),
'langList' => $langList,
'langFancyNames' => $langListFancy
);
}
];
}
function uupListLangs($updateId = 0, $returnInfo = true) {
if($returnInfo) {
$info = uupUpdateInfo($updateId, ignoreFiles: true);
$info = isset($info['info']) ? $info['info'] : false;
}
$langList = uupListLangsInternal($updateId);
$response = [
'apiVersion' => uupApiVersion(),
'langList' => $langList['langList'],
'langFancyNames' => $langList['langFancyNames'],
];
if($returnInfo) $response['updateInfo'] = $info;
return $response;
}

View File

@ -16,7 +16,7 @@ limitations under the License.
*/
function uupApiVersion() {
return '1.41.1';
return '1.42.0';
}
require_once dirname(__FILE__).'/auths.php';

View File

@ -202,7 +202,7 @@ function uupGetInfoTexts() {
);
}
function uupGetGenPacks($build = 15063, $arch = null, $updateId = null) {
function uupApiGetPacks($updateId) {
if(empty($updateId)) return [];
if(!file_exists('packs/'.$updateId.'.json.gz')) return [];
@ -212,3 +212,7 @@ function uupGetGenPacks($build = 15063, $arch = null, $updateId = null) {
$genPack = json_decode($genPack, 1);
return $genPack;
}
function uupGetGenPacks($build = 15063, $arch = null, $updateId = null) {
return uupApiGetPacks($updateId);
}