Commit e5688436 authored by Laura Heimann's avatar Laura Heimann

fixed double paths

parent 3b838e37
...@@ -38,14 +38,14 @@ TWITCH_API_CLIENT_SECRET=clientSecret ...@@ -38,14 +38,14 @@ TWITCH_API_CLIENT_SECRET=clientSecret
###< Twitch API ### ###< Twitch API ###
###> Paths ### ###> Paths ###
ASSET_BASE_URL=https://spinsha.re/uploads/ ASSET_BASE_URL=https://spinsha.re/uploads
ASSET_SRTB_FOLDER=srtb/ ASSET_SRTB_FOLDER=srtb
ASSET_COVER_FOLDER=cover/ ASSET_COVER_FOLDER=cover
ASSET_AUDIO_FOLDER=audio/ ASSET_AUDIO_FOLDER=audio
ASSET_AVATAR_FOLDER=avatar/ ASSET_AVATAR_FOLDER=avatar
ASSET_PROMO_FOLDER=promo/ ASSET_PROMO_FOLDER=promo
ASSET_CLIENT_FOLDER=client/ ASSET_CLIENT_FOLDER=client
ASSET_CARD_FOLDER=card/ ASSET_CARD_FOLDER=card
ASSET_THUMBNAIL_FOLDER=thumbnail/ ASSET_THUMBNAIL_FOLDER=thumbnail
ASSET_TEMP_FOLDER=temp/ ASSET_TEMP_FOLDER=temp
###< Paths ### ###< Paths ###
\ No newline at end of file
...@@ -447,4 +447,104 @@ class APIDiscoveryController extends AbstractController ...@@ -447,4 +447,104 @@ class APIDiscoveryController extends AbstractController
$response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 200, 'data' => $data]); $response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 200, 'data' => $data]);
return $response; return $response;
} }
/**
* @Route("/api/searchCharts", name="api.searchCharts")
* @Route("/api/searchCharts/")
*/
public function searchCharts(Request $request)
{
$em = $this->getDoctrine()->getManager();
$jsonBody = json_decode($request->getContent(), true);
if($jsonBody == NULL) {
$response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 404, 'data' => []]);
return $response;
}
$searchQuery = $jsonBody['searchQuery'];
$data = [];
// Songs
$resultsSongs = $em->getRepository(Song::class)->createQueryBuilder('o');
if($searchQuery != "") {
$resultsSongs->where('o.title LIKE :query');
$resultsSongs->orWhere('o.subtitle LIKE :query');
$resultsSongs->orWhere('o.tags LIKE :query');
$resultsSongs->orWhere('o.artist LIKE :query');
$resultsSongs->orWhere('o.charter LIKE :query');
}
// Add Filters for difficulty
$filterEasy = isset($jsonBody['diffEasy']) ? $jsonBody['diffEasy'] : true;
$filterNormal = isset($jsonBody['diffNormal']) ? $jsonBody['diffNormal'] : true;
$filterHard = isset($jsonBody['diffHard']) ? $jsonBody['diffHard'] : true;
$filterExpert = isset($jsonBody['diffExpert']) ? $jsonBody['diffExpert'] : true;
$filterXD = isset($jsonBody['diffXD']) ? $jsonBody['diffXD'] : true;
// Add Filters for Explicit Content
$filterExplicit = isset($jsonBody['showExplicit']) ? $jsonBody['showExplicit'] : false;
// Add Filters for difficulty ratings
$filterMinDifficulty = intval(isset($jsonBody['diffRatingFrom']) ? $jsonBody['diffRatingFrom'] : 0);
$filterMaxDifficulty = intval(isset($jsonBody['diffRatingTo']) ? $jsonBody['diffRatingTo'] : 99);
if($filterMinDifficulty == null) { $filterMinDifficulty = 0; }
if($filterMaxDifficulty == null) { $filterMaxDifficulty = 99; }
if($searchQuery != "") {
$resultsSongs->setParameter('query', "%".$searchQuery."%");
}
$resultsSongs->andWhere('o.publicationStatus IN (0, 1)');
$resultsSongs->orderBy('o.id', 'DESC');
$resultsSongs = $resultsSongs->getQuery()->getResult();
// Filter Song Results
$filteredResultsSongs = [];
foreach($resultsSongs as $resultSong) {
// Has the required difficulty
if($filterEasy && $resultSong->getHasEasyDifficulty() ||
$filterNormal && $resultSong->getHasNormalDifficulty() ||
$filterHard && $resultSong->getHasHardDifficulty() ||
$filterExpert && $resultSong->getHasExtremeDifficulty() ||
$filterXD && $resultSong->getHasXDDifficulty()) {
// Has the minimum difficulty rating
if($resultSong->getHasEasyDifficulty() && $resultSong->getEasyDifficulty() >= $filterMinDifficulty ||
$resultSong->getHasNormalDifficulty() && $resultSong->getNormalDifficulty() >= $filterMinDifficulty ||
$resultSong->getHasHardDifficulty() && $resultSong->getHardDifficulty() >= $filterMinDifficulty ||
$resultSong->getHasExtremeDifficulty() && $resultSong->getExpertDifficulty() >= $filterMinDifficulty ||
$resultSong->getHasXDDifficulty() && $resultSong->getXDDifficulty() >= $filterMinDifficulty) {
// Has the maximum difficulty rating
if($resultSong->getHasEasyDifficulty() && $resultSong->getEasyDifficulty() <= $filterMaxDifficulty ||
$resultSong->getHasNormalDifficulty() && $resultSong->getNormalDifficulty() <= $filterMaxDifficulty ||
$resultSong->getHasHardDifficulty() && $resultSong->getHardDifficulty() <= $filterMaxDifficulty ||
$resultSong->getHasExtremeDifficulty() && $resultSong->getExpertDifficulty() <= $filterMaxDifficulty ||
$resultSong->getHasXDDifficulty() && $resultSong->getXDDifficulty() <= $filterMaxDifficulty) {
if($filterExplicit || $resultSong->getIsExplicit() == $filterExplicit) {
$filteredResultsSongs[] = $resultSong;
}
}
}
}
}
foreach($filteredResultsSongs as $result) {
$oneResult = [];
$oneResult = $result->getJSON();
$oneResult['zip'] = $this->generateUrl('api.songs.download', array('id' => $result->getId()), UrlGeneratorInterface::ABSOLUTE_URL);
$data[] = $oneResult;
}
$response = new JsonResponse(['version' => $this->getParameter('api_version'), 'status' => 200, 'data' => $data]);
return $response;
}
} }
...@@ -120,7 +120,7 @@ class Card ...@@ -120,7 +120,7 @@ class Card
'id' => $this->id, 'id' => $this->id,
'title' => $this->title, 'title' => $this->title,
'description' => $this->description, 'description' => $this->description,
'icon' => $_ENV['ASSET_BASE_URL'].DIRECTORY_SEPARATOR.$_ENV['ASSET_CARD_FOLDER'].DIRECTORY_SEPARATOR.$this->icon, 'icon' => $_ENV['ASSET_BASE_URL']."/".$_ENV['ASSET_CARD_FOLDER']."/".$this->icon,
); );
} }
} }
...@@ -574,7 +574,7 @@ class Song ...@@ -574,7 +574,7 @@ class Song
'updateDate' => $this->updateDate, 'updateDate' => $this->updateDate,
'updateHash' => $this->updateHash, 'updateHash' => $this->updateHash,
'description' => $this->description, 'description' => $this->description,
'cover' => $_ENV['ASSET_BASE_URL'].DIRECTORY_SEPARATOR.$_ENV['ASSET_COVER_FOLDER'].DIRECTORY_SEPARATOR.$this->getFileReference().".png" 'cover' => $_ENV['ASSET_BASE_URL']."/".$_ENV['ASSET_COVER_FOLDER']."/".$this->getFileReference().".png"
); );
} }
......
...@@ -148,7 +148,7 @@ class SongPlaylist ...@@ -148,7 +148,7 @@ class SongPlaylist
'user' => $this->user->getJSON(), 'user' => $this->user->getJSON(),
'songs' => $songs, 'songs' => $songs,
'isOfficial' => $this->isOfficial, 'isOfficial' => $this->isOfficial,
'cover' => $_ENV['ASSET_BASE_URL'].DIRECTORY_SEPARATOR.$_ENV['ASSET_COVER_FOLDER'].DIRECTORY_SEPARATOR.$this->fileReference.".png" 'cover' => $_ENV['ASSET_BASE_URL']."/".$_ENV['ASSET_COVER_FOLDER']."/".$this->fileReference.".png"
); );
} }
......
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
'isVerified' => $this->isVerified, 'isVerified' => $this->isVerified,
'isPatreon' => $this->isPatreon, 'isPatreon' => $this->isPatreon,
'pronouns' => $this->pronouns, 'pronouns' => $this->pronouns,
'avatar' => $_ENV['ASSET_BASE_URL'].DIRECTORY_SEPARATOR.$_ENV['ASSET_AVATAR_FOLDER'].DIRECTORY_SEPARATOR.$this->coverReference 'avatar' => $_ENV['ASSET_BASE_URL']."/".$_ENV['ASSET_AVATAR_FOLDER']."/".$this->coverReference
); );
} }
......
...@@ -76,7 +76,7 @@ class UserCard ...@@ -76,7 +76,7 @@ class UserCard
public function getJSON() { public function getJSON() {
return array( return array(
'id' => $this->id, 'id' => $this->id,
'icon' => $_ENV['ASSET_BASE_URL'].DIRECTORY_SEPARATOR.$_ENV['ASSET_CARD_FOLDER'].DIRECTORY_SEPARATOR.$this->getCard()->getIcon(), 'icon' => $_ENV['ASSET_BASE_URL']."/".$_ENV['ASSET_CARD_FOLDER']."/".$this->getCard()->getIcon(),
'title' => $this->getCard()->getTitle(), 'title' => $this->getCard()->getTitle(),
'givenDate' => $this->getGivenDate(), 'givenDate' => $this->getGivenDate(),
'description' => $this->getCard()->getDescription() 'description' => $this->getCard()->getDescription()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment