Skip to content

Commit

Permalink
Fix space converting problem
Browse files Browse the repository at this point in the history
  • Loading branch information
CloneWith committed Feb 12, 2024
1 parent 2189ef6 commit a3c6a89
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>itdelatrisu</groupId>
<artifactId>opsu</artifactId>
<version>0.17.1</version>
<version>0.17.2</version>
<properties>
<version>${project.version}</version>
<timestamp>${maven.build.timestamp}</timestamp>
Expand Down
37 changes: 20 additions & 17 deletions src/itdelatrisu/opsu/downloads/servers/SayobotServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,21 @@ public class SayobotServer extends DownloadServer {
/** Formatted download URL: {@code beatmapSetID} */
private static final String DOWNLOAD_URL = "https://txy1.sayobot.cn/beatmaps/download/full/%d";

/** Formatted search URL: {@code query,rankedOnly,page} */
private static final String SEARCH_URL = "https://api.sayobot.cn/beatmaplist?0=%d&1=%d&2=%d&3=%s&5=%d&6=%d";
/*
* Format:
* 0=%d: Page size
* 1=%d: Page index
* 2=%d: Beatmap list type
* 3=%s: Query
* 5=%d: Modes
* 6=%d: Ranked state
*/
/**
* Format:
* {@params}:
* 0=%d: Page size
* 1=%d: Page index from 0
* 2=%d: Beatmap list type:
* *
* *
* * 4: search
*
* 3=%s: Query
* 5=%d: Modes -> 1
* 6=%d: Ranked state
*/
private static final String SEARCH_URL = "https://api.sayobot.cn/beatmaplist?0=%d&1=%d&2=%d&3=%s&5=%d&6=";

/** TODO: Preview audio URL, for future use */
private static final String PREVIEW_URL = "https://cdnx.sayobot.cn:25225/preview/%d";
Expand Down Expand Up @@ -87,15 +91,14 @@ public DownloadNode[] resultList(String query, int page, boolean rankedOnly) thr
DownloadNode[] nodes = null;
try {
// read JSON
String search = String.format(
SEARCH_URL,
String search = String.format(SEARCH_URL,
PAGE_LIMIT,
page,
page - 1,
4,
URLEncoder.encode(query, "UTF-8"),
1,
rankedOnly ? 1 : null
(URLEncoder.encode(query, "UTF-8")).replace("+", "%20"),
1
);
if (rankedOnly) search += "1";
String s = Utils.readDataFromUrl(new URL(search));
JSONObject body = new JSONObject(s);
int stat = body.getInt("status");
Expand Down
2 changes: 1 addition & 1 deletion src/itdelatrisu/opsu/states/DownloadsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ else if (lastPageDir == Page.RESET)
focusResult = -1;
startResultPos.setPosition(0);
if (nodes == null)
searchResultString = "An error occurred. See log for details.";
searchResultString = "No results found or an internal error occurred. See log for details.";
else {
if (query.isEmpty())
searchResultString = "Type to search!";
Expand Down

0 comments on commit a3c6a89

Please sign in to comment.