Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
B
Backend Server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SpinShare
Backend Server
Commits
e5688436
Commit
e5688436
authored
Feb 23, 2021
by
Laura Heimann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed double paths
parent
3b838e37
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
115 additions
and
15 deletions
+115
-15
.env.example
.env.example
+10
-10
src/Controller/API/APIDiscoveryController.php
src/Controller/API/APIDiscoveryController.php
+100
-0
src/Entity/Card.php
src/Entity/Card.php
+1
-1
src/Entity/Song.php
src/Entity/Song.php
+1
-1
src/Entity/SongPlaylist.php
src/Entity/SongPlaylist.php
+1
-1
src/Entity/User.php
src/Entity/User.php
+1
-1
src/Entity/UserCard.php
src/Entity/UserCard.php
+1
-1
No files found.
.env.example
View file @
e5688436
...
@@ -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
src/Controller/API/APIDiscoveryController.php
View file @
e5688436
...
@@ -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
;
}
}
}
src/Entity/Card.php
View file @
e5688436
...
@@ -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
,
);
);
}
}
}
}
src/Entity/Song.php
View file @
e5688436
...
@@ -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"
);
);
}
}
...
...
src/Entity/SongPlaylist.php
View file @
e5688436
...
@@ -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"
);
);
}
}
...
...
src/Entity/User.php
View file @
e5688436
...
@@ -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
);
);
}
}
...
...
src/Entity/UserCard.php
View file @
e5688436
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment