Skip to content

Commit 325ed18

Browse files
committed
Release 1.0.3
1 parent 1300d85 commit 325ed18

File tree

6 files changed

+64
-40
lines changed

6 files changed

+64
-40
lines changed

assets/SpotifyLoginViewController.bsml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
<text font-size="3.5" text="Client ID"/>
1010
<horizontal>
1111
<text-field id="clientIdTextField_" text="Client ID"/>
12-
<icon-button id="clientIdPasteButton_" on-click="onPasteClientIdButtonClicked" hover-hint="Paste" icon="#Papercut" pref-width="8" pref-height="8"/>
12+
<icon-button id="clientIdPasteButton_" on-click="onPasteClientIdButtonClicked" hover-hint="Paste" pref-width="8" pref-height="8"/>
1313
</horizontal>
1414
</vertical>
1515

1616
<vertical vertical-fit="PreferredSize" horizontal-fit="Unconstrained" spacing="-1">
1717
<text font-size="3.5" text="Client Secret"/>
1818
<horizontal>
1919
<text-field id="clientSecretTextField_" text="Client Secret"/>
20-
<icon-button id="clientSecretPasteButton_" on-click="onPasteClientSecretButtonClicked" hover-hint="Paste" icon="#HorizontalArrowIcon" pref-width="8" pref-height="8"/>
20+
<icon-button id="clientSecretPasteButton_" on-click="onPasteClientSecretButtonClicked" hover-hint="Paste" pref-width="8" pref-height="8"/>
2121
</horizontal>
2222
</vertical>
2323

qpm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"info": {
77
"name": "Spotify Search",
88
"id": "spotify-search",
9-
"version": "1.0.2",
9+
"version": "1.0.3",
1010
"url": "https://github.com/TychoTheTaco/Beat-Saber-Spotify-Search",
1111
"additionalData": {
1212
"overrideSoName": "libspotify-search.so",

qpm_defines.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# YOU SHOULD NOT MANUALLY EDIT THIS FILE, QPM WILL VOID ALL CHANGES
22
# Version defines, pretty useful
3-
set(MOD_VERSION "1.0.1")
3+
set(MOD_VERSION "1.0.3")
44
# take the mod name and just remove spaces, that will be MOD_ID, if you don't like it change it after the include of this file
55
set(MOD_ID "SpotifySearch")
66

src/UI/ViewControllers/SpotifyLoginViewController.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ void SpotifyLoginViewController::PostParse() {
5353
button->GetComponent<BSML::ButtonIconImage*>()->SetIcon(sprite);
5454
static constexpr float scale = 1.5f;
5555
button->get_transform()->Find("Content/Icon")->set_localScale({scale, scale, scale});
56+
Utils::removeRaycastFromButtonIcon(button);
5657
}
5758

5859
// Set the redirect URI text field
@@ -61,6 +62,8 @@ void SpotifyLoginViewController::PostParse() {
6162
}
6263

6364
bool generateSelfSignedCert(const std::string& certFile, const std::string& keyFile) {
65+
SpotifySearch::Log.info("Generating SSL certificate. certFile = {} keyFile = {}", certFile, keyFile);
66+
6467
// Generate RSA key pair
6568
EVP_PKEY* pkey = EVP_PKEY_new();
6669
RSA* rsa = RSA_new();
@@ -91,11 +94,21 @@ bool generateSelfSignedCert(const std::string& certFile, const std::string& keyF
9194

9295
// Write certificate to file
9396
FILE* certFp = fopen(certFile.c_str(), "wb");
97+
if (!certFp) {
98+
const auto reason = strerror(errno);
99+
SpotifySearch::Log.info("Failed to open certFile! error = {} reason = {} path = {}", errno, reason, certFile);
100+
return false;
101+
}
94102
PEM_write_X509(certFp, x509);
95103
fclose(certFp);
96104

97105
// Write private key to file
98106
FILE* keyFp = fopen(keyFile.c_str(), "wb");
107+
if (!keyFp) {
108+
const auto reason = strerror(errno);
109+
SpotifySearch::Log.info("Failed to open keyFile! error = {} reason = {} path = {}", errno, reason, keyFile);
110+
return false;
111+
}
99112
PEM_write_PrivateKey(keyFp, pkey, nullptr, nullptr, 0, nullptr, nullptr);
100113
fclose(keyFp);
101114

@@ -224,15 +237,14 @@ void SpotifyLoginViewController::onLoginButtonClicked() {
224237
// Check we got the authorization code
225238
std::string authorizationCode;
226239
for (const auto& item : request.params) {
227-
SpotifySearch::Log.debug("PARAM: {}, {}", item.first, item.second);
228240
if (item.first == "code") {
229241
authorizationCode = item.second;
230242
break;
231243
}
232244
}
233245
if (!authorizationCode.empty()) {
234246
response.status = 200;
235-
response.set_content("Login successful. You can now close this window.", "text/plain");
247+
response.set_content("Login successful. You can now close this window and return to Beat Saber.", "text/plain");
236248
BSML::MainThreadScheduler::Schedule([this, authorizationCode](){
237249
onAuthorizationCodeReceived(authorizationCode);
238250
});

src/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ MOD_EXTERN_FUNC void setup(CModInfo* info) noexcept {
3232
// Initialize logging. This enables saving logs to disk.
3333
Paper::Logger::RegisterFileContextId("spotify-search");
3434

35+
SpotifySearch::Log.info("Version: {}", info->version);
36+
3537
// Capture fatal logs from logcat to get crash stacks
3638
std::thread([](){
3739
SpotifySearch::Log.info("Logcat thread started");
@@ -129,7 +131,13 @@ MOD_EXTERN_FUNC void late_load() noexcept {
129131
// Install hooks
130132
INSTALL_HOOK(SpotifySearch::Log, onDismissFlowCoordinator);
131133

132-
SpotifySearch::dataDir_ = getDataDir(modInfo);
134+
// Set up the data directory
135+
const std::string dataDirectoryString = getDataDir(modInfo);
136+
const std::filesystem::path dataDirectory {dataDirectoryString};
137+
if (!std::filesystem::exists(dataDirectory)) {
138+
std::filesystem::create_directory(dataDirectory);
139+
}
140+
SpotifySearch::dataDir_ = dataDirectory;
133141

134142
// Initialize the Spotify client
135143
SpotifySearch::spotifyClient = std::make_shared<spotify::Client>();

tools/decode.py

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import subprocess
33
from os import environ
44
from pathlib import Path
5-
from typing import List
5+
from typing import List, Optional
66

77
from ansi import Color
88

@@ -11,33 +11,54 @@ def main():
1111
# Parse arguments
1212
parser = argparse.ArgumentParser()
1313
parser.add_argument('--input', '-i', required=True)
14+
parser.add_argument('--symbols', '-s')
1415
args = parser.parse_args()
1516

1617
input_arg: str = args.input
18+
symbols_arg: Optional[str] = args.symbols
1719

1820
temp_dir = Path('./temp')
1921
temp_dir.mkdir(exist_ok=True)
2022

2123
# Pull the debug library from the device
22-
process = subprocess.run([
23-
'adb',
24-
'pull',
25-
'/sdcard/ModData/com.beatgames.beatsaber/Modloader/mods/libspotify-search.so',
26-
], cwd=temp_dir, stderr=subprocess.STDOUT)
27-
28-
# Pull the logs from the device
29-
log_file_dir = Path('/sdcard/ModData/com.beatgames.beatsaber/logs2')
30-
log_file_paths = [
31-
log_file_dir / 'spotify-search.log',
32-
log_file_dir / 'spotify-search.1.log'
33-
]
34-
for path in log_file_paths:
24+
if not symbols_arg:
25+
print(Color.CYAN('Pulling libraries from device...'))
3526
process = subprocess.run([
3627
'adb',
3728
'pull',
38-
path.as_posix(),
29+
'/sdcard/ModData/com.beatgames.beatsaber/Modloader/mods/libspotify-search.so',
3930
], cwd=temp_dir, stderr=subprocess.STDOUT)
4031

32+
total_paths: List[Path] = []
33+
34+
match input_arg:
35+
case 'logs':
36+
# Pull the logs from the device
37+
log_file_dir = Path('/sdcard/ModData/com.beatgames.beatsaber/logs2')
38+
log_file_paths = [
39+
log_file_dir / 'spotify-search.log',
40+
log_file_dir / 'spotify-search.1.log'
41+
]
42+
for path in log_file_paths:
43+
process = subprocess.run([
44+
'adb',
45+
'pull',
46+
path.as_posix(),
47+
], cwd=temp_dir, stderr=subprocess.STDOUT)
48+
total_paths.append(temp_dir / path.name)
49+
case 'logcat':
50+
# Get logcat output
51+
logcat_output_path = temp_dir / 'logcat.txt'
52+
with open(logcat_output_path, 'w') as file:
53+
process = subprocess.run([
54+
'adb',
55+
'shell',
56+
'logcat -d *:F'
57+
], cwd=temp_dir, stdout=file)
58+
total_paths.append(logcat_output_path)
59+
case _:
60+
total_paths.append(Path(input_arg))
61+
4162
ndk_path = Path(environ.get('ANDROID_NDK_HOME'))
4263
ndk_stack_exe = ndk_path / 'ndk-stack.cmd'
4364

@@ -47,24 +68,7 @@ def main():
4768
symbol_dir = temp_dir
4869
print(ndk_stack_exe)
4970

50-
# Get logcat output
51-
logcat_output_path = temp_dir / 'logcat.txt'
52-
with open(logcat_output_path, 'w') as file:
53-
process = subprocess.run([
54-
'adb',
55-
'shell',
56-
'logcat -d *:F'
57-
], cwd=temp_dir, stdout=file)
58-
59-
input_paths: List[Path] = [
60-
*[
61-
temp_dir / p.name for p in log_file_paths
62-
],
63-
Path(input_arg),
64-
logcat_output_path
65-
]
66-
67-
for path in input_paths:
71+
for path in total_paths:
6872
print(Color.CYAN(f'Decoding: {path}'))
6973
process = subprocess.run([
7074
str(ndk_stack_exe.absolute()),

0 commit comments

Comments
 (0)