mp3 mx beta working
This commit is contained in:
parent
6a92553e75
commit
46bf05225e
@ -341,7 +341,7 @@ class ManiaControl implements CommandListener, TimerListener {
|
|||||||
// Yield for next tick
|
// Yield for next tick
|
||||||
$loopEnd = microtime(true);
|
$loopEnd = microtime(true);
|
||||||
|
|
||||||
$sleepTime = (int) (5000 - ($loopEnd - $loopStart) * 1000000);
|
$sleepTime = (int) (2000 - ($loopEnd - $loopStart) * 1000000);
|
||||||
if ($sleepTime > 0) {
|
if ($sleepTime > 0) {
|
||||||
usleep($sleepTime);
|
usleep($sleepTime);
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ class MXMapInfo {
|
|||||||
public $titlepack, $style, $envir, $mood, $dispcost, $lightmap, $modname, $exever;
|
public $titlepack, $style, $envir, $mood, $dispcost, $lightmap, $modname, $exever;
|
||||||
public $exebld, $routes, $length, $unlimiter, $laps, $difficulty, $lbrating, $trkvalue;
|
public $exebld, $routes, $length, $unlimiter, $laps, $difficulty, $lbrating, $trkvalue;
|
||||||
public $replaytyp, $replayid, $replaycnt, $acomment, $awards, $comments, $rating;
|
public $replaytyp, $replayid, $replaycnt, $acomment, $awards, $comments, $rating;
|
||||||
public $ratingex, $ratingcnt, $pageurl, $replayurl, $imageurl, $thumburl, $downloadurl;
|
public $ratingex, $ratingcnt, $pageurl, $replayurl, $imageurl, $thumburl, $downloadurl, $dir;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns map object with all available data from MX map data
|
* Returns map object with all available data from MX map data
|
||||||
@ -30,11 +30,11 @@ class MXMapInfo {
|
|||||||
if ($mx) {
|
if ($mx) {
|
||||||
|
|
||||||
if ($this->prefix == 'tm') {
|
if ($this->prefix == 'tm') {
|
||||||
$dir = 'tracks';
|
$this->dir = 'tracks';
|
||||||
$this->id = $mx->TrackID;
|
$this->id = $mx->TrackID;
|
||||||
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
|
$this->uid = isset($mx->TrackUID) ? $mx->TrackUID : '';
|
||||||
} else {
|
} else {
|
||||||
$dir = 'maps';
|
$this->dir = 'maps';
|
||||||
$this->id = $mx->MapID;
|
$this->id = $mx->MapID;
|
||||||
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
$this->uid = isset($mx->MapUID) ? $mx->MapUID : '';
|
||||||
}
|
}
|
||||||
@ -88,10 +88,10 @@ class MXMapInfo {
|
|||||||
$this->acomment = str_ireplace($search, $replace, $this->acomment);
|
$this->acomment = str_ireplace($search, $replace, $this->acomment);
|
||||||
$this->acomment = preg_replace('/\[url=.*\]/', '<i>', $this->acomment);
|
$this->acomment = preg_replace('/\[url=.*\]/', '<i>', $this->acomment);
|
||||||
|
|
||||||
$this->pageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $dir . '/view/' . $this->id;
|
$this->pageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/view/' . $this->id;
|
||||||
$this->imageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $dir . '/screenshot/normal/' . $this->id;
|
$this->imageurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/normal/' . $this->id;
|
||||||
$this->thumburl = 'http://' . $this->prefix . '.mania-exchange.com/' . $dir . '/screenshot/small/' . $this->id;
|
$this->thumburl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/screenshot/small/' . $this->id;
|
||||||
$this->downloadurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $dir . '/download/' . $this->id;
|
$this->downloadurl = 'http://' . $this->prefix . '.mania-exchange.com/' . $this->dir . '/download/' . $this->id;
|
||||||
|
|
||||||
if ($this->prefix == 'tm' && $this->replayid > 0) {
|
if ($this->prefix == 'tm' && $this->replayid > 0) {
|
||||||
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
|
$this->replayurl = 'http://' . $this->prefix . '.mania-exchange.com/replays/download/' . $this->replayid;
|
||||||
|
@ -12,7 +12,7 @@ use Maniaplanet\DedicatedServer\Xmlrpc\Exception;
|
|||||||
*
|
*
|
||||||
* @author steeffeen & kremsy
|
* @author steeffeen & kremsy
|
||||||
*/
|
*/
|
||||||
class ManiaExchangeManager {
|
class ManiaExchangeManager{
|
||||||
/**
|
/**
|
||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
@ -38,6 +38,9 @@ class ManiaExchangeManager {
|
|||||||
//Maximum Maps per request
|
//Maximum Maps per request
|
||||||
const MAPS_PER_MX_FETCH = 50;
|
const MAPS_PER_MX_FETCH = 50;
|
||||||
|
|
||||||
|
//Beta Testing Activated
|
||||||
|
const SETTING_MP3_BETA_TESTING = 'Activate MP3 Beta Testing';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Private Propertieswc
|
* Private Propertieswc
|
||||||
*/
|
*/
|
||||||
@ -51,6 +54,8 @@ class ManiaExchangeManager {
|
|||||||
*/
|
*/
|
||||||
public function __construct(ManiaControl $maniaControl) {
|
public function __construct(ManiaControl $maniaControl) {
|
||||||
$this->maniaControl = $maniaControl;
|
$this->maniaControl = $maniaControl;
|
||||||
|
|
||||||
|
$this->maniaControl->settingManager->initSetting($this, self::SETTING_MP3_BETA_TESTING, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -187,6 +192,9 @@ class ManiaExchangeManager {
|
|||||||
|
|
||||||
// compile search URL
|
// compile search URL
|
||||||
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $id;
|
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $id;
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MP3_BETA_TESTING)){
|
||||||
|
$url .= '&key=t42kEMjzH7xpAjBFHAvEkC7rqAlw';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
return $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use (&$function, $titlePrefix, $url) {
|
||||||
$mxMapInfo = null;
|
$mxMapInfo = null;
|
||||||
@ -217,6 +225,9 @@ class ManiaExchangeManager {
|
|||||||
|
|
||||||
// compile search URL
|
// compile search URL
|
||||||
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $string;
|
$url = 'http://api.mania-exchange.com/' . $titlePrefix . '/maps/?ids=' . $string;
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MP3_BETA_TESTING)){
|
||||||
|
$url .= '&key=t42kEMjzH7xpAjBFHAvEkC7rqAlw';
|
||||||
|
}
|
||||||
|
|
||||||
$thisRef = $this;
|
$thisRef = $this;
|
||||||
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use ($thisRef, $titlePrefix, $url) {
|
$success = $this->maniaControl->fileReader->loadFile($url, function ($mapInfo, $error) use ($thisRef, $titlePrefix, $url) {
|
||||||
@ -274,7 +285,7 @@ class ManiaExchangeManager {
|
|||||||
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
$titlePrefix = $this->maniaControl->mapManager->getCurrentMap()->getGame();
|
||||||
|
|
||||||
// compile search URL
|
// compile search URL
|
||||||
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch?api=on';
|
$url = 'http://' . $titlePrefix . '.mania-exchange.com/tracksearch2/search?api=on';
|
||||||
|
|
||||||
$game = explode('@', $titleId);
|
$game = explode('@', $titleId);
|
||||||
$envNumber = $this->getEnvironment($game[0]);
|
$envNumber = $this->getEnvironment($game[0]);
|
||||||
@ -291,6 +302,10 @@ class ManiaExchangeManager {
|
|||||||
$url .= '&priord=' . $searchOrder;
|
$url .= '&priord=' . $searchOrder;
|
||||||
$url .= '&limit=' . $maxMapsReturned;
|
$url .= '&limit=' . $maxMapsReturned;
|
||||||
|
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this, self::SETTING_MP3_BETA_TESTING)){
|
||||||
|
$url .= '&key=t42kEMjzH7xpAjBFHAvEkC7rqAlw';
|
||||||
|
$url .= '&mapgroup=1';
|
||||||
|
}
|
||||||
|
|
||||||
// Get MapTypes
|
// Get MapTypes
|
||||||
try {
|
try {
|
||||||
@ -311,6 +326,14 @@ class ManiaExchangeManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$mxMapList = json_decode($mapInfo);
|
$mxMapList = json_decode($mapInfo);
|
||||||
|
|
||||||
|
if (!isset($mxMapList->results)) {
|
||||||
|
trigger_error('Cannot decode searched JSON data');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mxMapList = $mxMapList->results;
|
||||||
|
|
||||||
if ($mxMapList === null) {
|
if ($mxMapList === null) {
|
||||||
trigger_error('Cannot decode searched JSON data');
|
trigger_error('Cannot decode searched JSON data');
|
||||||
return null;
|
return null;
|
||||||
|
@ -569,8 +569,15 @@ class MapManager implements CallbackListener {
|
|||||||
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
|
$this->maniaControl->chat->sendError('Invalid MX-Id!', $login);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO hardcoded whiel beta, later take just $mapInfo->url again
|
||||||
|
$url = 'http://' . $mapInfo->prefix . '.mania-exchange.com/' . $mapInfo->dir . '/download/' . $mapInfo->id;
|
||||||
|
if($this->maniaControl->settingManager->getSetting($this->mxManager, ManiaExchangeManager::SETTING_MP3_BETA_TESTING)){
|
||||||
|
$url .= '?key=t42kEMjzH7xpAjBFHAvEkC7rqAlw';
|
||||||
|
}
|
||||||
|
|
||||||
//Download the file
|
//Download the file
|
||||||
$this->maniaControl->fileReader->loadFile($mapInfo->downloadurl, function ($file, $error) use (&$login, &$mapInfo, &$update) {
|
$this->maniaControl->fileReader->loadFile($url, function ($file, $error) use (&$login, &$mapInfo, &$update) {
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
// Download error
|
// Download error
|
||||||
$this->maniaControl->chat->sendError('Download failed!', $login);
|
$this->maniaControl->chat->sendError('Download failed!', $login);
|
||||||
|
Loading…
Reference in New Issue
Block a user