Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New bin 4 #91

Merged
merged 5 commits into from
Jan 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 22 additions & 13 deletions .github/scripts/append-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const invalid_chars = [
];

function filterFilename(name) {
if (!name) {
return ""
}
invalid_chars.forEach((c) => {
name = name.split("").filter((i) => i !== c).join("");
});
Expand Down Expand Up @@ -43,31 +46,32 @@ async function run() {
const preview_extensions = ["wav", "mp3"];
for (i = 0; i < response_files.data.length; i++) {
const f = response_files.data[i];
console.log(f)
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
bin_file = f.filename;
} else if (extension == "mid") {
midi_file = f.filename;
} else if (preview_extensions.includes(extension)) {
preview_file = f.filename;
preview_extension = extension;
if (f.filename) {
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
bin_file = f.filename;
} else if (extension == "mid") {
midi_file = f.filename;
} else if (preview_extensions.includes(extension)) {
preview_file = f.filename;
preview_extension = extension;
}
}
}
console.log(bin_file, midi_file, preview_file, preview_extension)

// Extract the PR message
const prMessage = response.data.body;
const rawPRData = prMessage.split("\r\n")
const rawPRData = prMessage ? prMessage.split("\r\n") : []
const REQ_STRING = "IS SONG - DO NOT DELETE THIS LINE"
if (rawPRData[0] != REQ_STRING) {
console.log("Skipping Pull Request, missing key line.");
return;
}
let json_output = {}
rawPRData.forEach((item, index) => {
if (index > 0) {
if ((index > 0) && (item)) {
if (item.split("").includes(":")) {
spl = item.split(/:(.*)/s)
json_output[spl[0].trim()] = spl[1].trim()
Expand All @@ -86,7 +90,9 @@ async function run() {
const arr_vars = ["Categories"]
arr_vars.forEach((v) => {
if (Object.keys(json_output).includes(v)) {
if (json_output[v]) {
json_output[v] = json_output[v].split(",").map((item) => item.trim())
}
}
})
json_output["Verified"] = true;
Expand Down Expand Up @@ -192,7 +198,10 @@ async function run() {
}
let desc = desc_strings.join("\n")
const binary_dl_link = binary_link ? binary_link : "???";
const has_audio_file = preview_file_bytes != null;
let has_audio_file = preview_file_bytes != null;
if (has_audio_file) {
has_audio_file = Buffer.from(preview_file_bytes, "binary").length < (25 * 1024 * 1024);
}
let audio_string = "No Preview";
if (has_audio_file) {
audio_string = "*(Attached)*";
Expand Down
33 changes: 20 additions & 13 deletions .github/scripts/pr-analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const invalid_chars = [
];

function filterFilename(name) {
if (!name) {
return ""
}
invalid_chars.forEach((c) => {
name = name.split("").filter((i) => i !== c).join("");
});
Expand Down Expand Up @@ -107,29 +110,31 @@ async function run() {
const preview_extensions = ["wav", "mp3"];
for (i = 0; i < response_files.data.length; i++) {
const f = response_files.data[i];
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
bin_file = f.filename;
} else if (extension == "mid") {
midi_file = f.filename;
} else if (preview_extensions.includes(extension)) {
preview_file = f.filename;
preview_extension = extension;
if (f.filename) {
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
bin_file = f.filename;
} else if (extension == "mid") {
midi_file = f.filename;
} else if (preview_extensions.includes(extension)) {
preview_file = f.filename;
preview_extension = extension;
}
}
}
const octokit = new Octokit({auth: token})

// Extract the PR message
const prMessage = response.data.body;
const rawPRData = prMessage.split("\r\n")
const rawPRData = prMessage ? prMessage.split("\r\n") : []
const REQ_STRING = "IS SONG - DO NOT DELETE THIS LINE"
if (rawPRData[0] == REQ_STRING) {
song_upload = true;
}
let json_output = {}
rawPRData.forEach((item, index) => {
if (index > 0) {
if ((index > 0) && (item)) {
spl = item.split(/:(.*)/s)
if (item.split("").includes(":")) {
key = spl[0].trim()
Expand All @@ -155,7 +160,9 @@ async function run() {
})
arr_vars.forEach(v => {
if (Object.keys(json_output).includes(v)) {
json_output[v] = json_output[v].split(",").map(item => item.trim())
if (json_output[v]) {
json_output[v] = json_output[v].split(",").map(item => item.trim())
}
}
})
json_output["Verified"] = true;
Expand Down Expand Up @@ -188,7 +195,7 @@ async function run() {
json_output["Audio"] = encodeURI(`https://github.com/theballaam96/candys-shop/raw/main/previews/${sub_file}.${preview_extension}`)
}
if (bin_file) {
json_output["Binary"] = `previews/${sub_file}.bin`
json_output["Binary"] = `binaries/${sub_file}.bin`
}

if (song_upload) {
Expand Down
18 changes: 10 additions & 8 deletions .github/scripts/pr-poster.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,30 @@ async function run() {
const preview_extensions = ["wav", "mp3"];
for (i = 0; i < response_files.data.length; i++) {
const f = response_files.data[i];
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
if (f.filename) {
const extension_sep = f.filename.split(".");
const extension = extension_sep[extension_sep.length - 1];
if (extension == "bin") {
bin_file = f.raw_url;
} else if (extension == "mid") {
} else if (extension == "mid") {
midi_file = f.raw_url;
} else if (preview_extensions.includes(extension)) {
} else if (preview_extensions.includes(extension)) {
preview_file = f.raw_url;
preview_extension = extension;
}
}
}

// Extract the PR message
const prMessage = response.data.body;
const rawPRData = prMessage.split("\r\n")
const rawPRData = prMessage ? prMessage.split("\r\n") : []
const REQ_STRING = "IS SONG - DO NOT DELETE THIS LINE"
if (rawPRData[0] == REQ_STRING) {
song_upload = true;
}
let json_output = {}
rawPRData.forEach((item, index) => {
if (index > 0) {
if ((index > 0) && (item)) {
spl = item.split(/:(.*)/s)
if (item.split("").includes(":")) {
key = spl[0].trim()
Expand Down Expand Up @@ -115,8 +117,8 @@ async function run() {
user = response.data.user.login;
}
let embeds_arr = [];
let content = "";
if (song_upload) {
let content = "";
const information = {
"Game": Object.keys(json_output).includes("Game") ? json_output["Game"] : "Not Provided",
"Song Name": Object.keys(json_output).includes("Song") ? json_output["Song"] : "Not Provided",
Expand Down
Loading