-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
95b4c3e
commit 723eaa9
Showing
46 changed files
with
8,295 additions
and
4,290 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
process.env.DISCORD_CLIENT_ID = "mock"; | ||
process.env.DISCORD_BOT_TOKEN = "mock"; | ||
process.env.YOUTUBE_API_KEY = "mock"; | ||
process.env.MINIO_ACCESS_KEY = "mock"; | ||
process.env.MINIO_SECRET_KEY = "mock"; | ||
process.env.CACHE_DATABASE_URL = ":memory:"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"arrowParens": "always", | ||
"endOfLine": "lf", | ||
"printWidth": 100, | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "all" | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import fs from "fs"; | ||
|
||
const [source, destination] = process.argv.slice(2); | ||
console.log({ source, destination }); | ||
|
||
console.log("reading from source..."); | ||
const raw = fs.readFileSync(source).toString(); | ||
const rawQueries = raw.split(/\n{2,}/g); | ||
|
||
console.log("parsing and transforming..."); | ||
const set = new Set(); | ||
const uniques = (inputs?: any[]) => Array.from(new Set(inputs)); | ||
const transformed = rawQueries.map((raw, i) => { | ||
const [header, ...lines] = raw.split("\n"); | ||
const name = header | ||
.replace(/^-- name:\s*/, "") | ||
.replace(/:.*$/, "") | ||
.trim(); | ||
const capitalised = name[0].toUpperCase() + name.slice(1); | ||
|
||
// const execType = header.split(/\s+/g).pop()?.replace(/^:/, ""); | ||
if (set.has(name)) { | ||
throw new Error(`query ${name} was already defined (index: ${i})`); | ||
} | ||
set.add(name); | ||
|
||
const query = lines | ||
.join(" ") | ||
.trim() | ||
.replace(/\s+/g, " ") | ||
.replace(/;$/, "") | ||
.replace(/\(\s+/g, "(") | ||
.replace(/\s+\)/g, ")"); | ||
|
||
const args = uniques( | ||
query.match(/\$[a-z0-9]+/gi)?.map((arg) => arg.slice(1)), | ||
); | ||
const table = uniques( | ||
query | ||
.match(/(FROM|INTO|UPDATE)\s+([a-z0-9]+)/gi) | ||
?.map((match) => match.replace(/(FROM|INTO|UPDATE)\s+/, "")), | ||
); | ||
console.log({ name, args, table, query }); | ||
|
||
const tableComment = `tables: ${table.map((i) => `\`${i}\``).join(", ")}`; | ||
const argComment = `args: ${args.map((i) => `\`${i}\``).join(", ") || "N/A"}`; | ||
const sqlDeclaration = `export const ${name} = \`${query}\`;`; | ||
return [ | ||
"/**", | ||
" * " + tableComment, | ||
" *", | ||
" * " + argComment, | ||
" */", | ||
sqlDeclaration, | ||
].join("\n"); | ||
}); | ||
|
||
console.log("writing to destination..."); | ||
fs.writeFileSync( | ||
destination, | ||
transformed.toSorted((a, b) => a.localeCompare(b)).join("\n\n") + "\n", | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import "dotenv/config"; | ||
import { Youtube } from "../src/lib/Youtube"; | ||
|
||
(async () => { | ||
const video = await Youtube.get("lYxE_whU9ak"); | ||
console.log({ | ||
thumbnail: video.items?.[0].snippet?.thumbnails?.default?.url, | ||
videoId: video.items?.[0].id, | ||
title: video.items?.[0].snippet?.title, | ||
channelId: video.items?.[0].snippet?.channelId, | ||
channelTitle: video.items?.[0].snippet?.channelTitle, | ||
}); | ||
|
||
const playlist = await Youtube.list("PLWIol4T7LuSj4tNt8DvtHBE0c3UUiGGQ7"); | ||
console.log( | ||
playlist.items?.map((item) => ({ | ||
thumbnail: item.snippet?.thumbnails?.default?.url, | ||
videoId: item.snippet?.resourceId?.videoId, | ||
title: item.snippet?.title, | ||
channelId: item.snippet?.channelId, | ||
channelTitle: item.snippet?.channelTitle, | ||
})), | ||
); | ||
|
||
const search = await Youtube.search("deadmau5 xyz", 7); | ||
console.log( | ||
search.items?.map((item) => ({ | ||
thumbnail: search.items?.[0].snippet?.thumbnails?.default?.url, | ||
videoId: item.id?.videoId, | ||
title: item.snippet?.title, | ||
channelId: item.snippet?.channelId, | ||
channelTitle: item.snippet?.channelTitle, | ||
})), | ||
); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import "dotenv/config"; | ||
import "source-map-support/register"; | ||
import { Song, SongDAO, QueueDAO } from "../src/lib/cache"; | ||
import { server } from "../src/server/server"; | ||
import { config } from "../src/config"; | ||
|
||
(async () => { | ||
const songs = [ | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "JUmpYJau5Vg", | ||
title: "deadmau5 - XYZ", | ||
channelId: "UCYEK6xds6eo-3tr4xRdflmQ", | ||
channelTitle: "deadmau5", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "-xng12qdhDw", | ||
title: "deadmau5 - XYZ (NERO Remix)", | ||
channelId: "UCCbpTuRINyfjtwFkjHuII1w", | ||
channelTitle: "mau5trap", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "N22HHpbYE88", | ||
title: "deadmau5 - XYZ", | ||
channelId: "UCeuT6VsBplPygtAgJ2Wpeqw", | ||
channelTitle: "Obsessive Progressive", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "RSeqqi9-LQM", | ||
title: "Deadmau5 XYZ Extended", | ||
channelId: "UCXMF0L-H7_hbhvW6i4eAOBQ", | ||
channelTitle: "Hubie Fix", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "pgZ0Ja5o3hc", | ||
title: "XYZ – deadmau5 (Twitch live vers.) [No Mastering]", | ||
channelId: "UCCpLIH3yIf7JYOwMalcsYRA", | ||
channelTitle: "PotatoBadBoy", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "p_SpHwMsTWU", | ||
title: "deadmau5 - XYZ (NERO Remix)", | ||
channelId: "UC9UTBXS_XpBCUIcOG7fwM8A", | ||
channelTitle: "UKF", | ||
}, | ||
{ | ||
thumbnail: "https://i.ytimg.com/vi/JUmpYJau5Vg/default.jpg", | ||
videoId: "EH0nM5GiK6o", | ||
title: "deadmau5 - XYZ (NERO Remix)", | ||
channelId: "UC3ifTl5zKiCAhHIBQYcaTeg", | ||
channelTitle: "Proximity", | ||
}, | ||
].map( | ||
(raw, i): Song => ({ | ||
artistId: raw.channelId, | ||
artistTitle: raw.channelTitle, | ||
cachedAt: Date.now(), | ||
artistUrl: `https://youtube.com/channel/${raw.channelId}`, | ||
duration: i + 60, | ||
songId: raw.videoId, | ||
songTitle: raw.title, | ||
songUrl: `https://youtube.com/watch?v=${raw.videoId}`, | ||
thumbnail: raw.thumbnail, | ||
}), | ||
); | ||
await SongDAO.put(...songs); | ||
await QueueDAO.enqueue("test", songs[0].songId); | ||
await SongDAO.list(); | ||
server.listen({ port: config.webPort }); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
module.exports = [ | ||
{ | ||
extends: [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended", | ||
"plugin:prettier/recommended", | ||
], | ||
env: { | ||
node: true, | ||
browser: true, | ||
}, | ||
plugins: ["import", "@typescript-eslint", "prettier"], | ||
parser: "@typescript-eslint/parser", | ||
rules: { | ||
"import/order": [ | ||
"warn", | ||
{ | ||
pathGroups: [ | ||
{ | ||
pattern: "~/**", | ||
group: "parent", | ||
position: "before", | ||
}, | ||
], | ||
groups: [ | ||
["builtin", "external"], | ||
["parent", "sibling", "index"], | ||
], | ||
"newlines-between": "always", | ||
alphabetize: { | ||
order: "asc", | ||
caseInsensitive: true, | ||
}, | ||
}, | ||
], | ||
"@typescript-eslint/no-explicit-any": ["off", {}], | ||
"@typescript-eslint/ban-types": [ | ||
"error", | ||
{ | ||
types: { | ||
Function: false, | ||
"extend-defaults": true, | ||
}, | ||
}, | ||
], | ||
"no-unused-vars": ["off"], | ||
"@typescript-eslint/no-unused-vars": [ | ||
"warn", | ||
{ | ||
vars: "all", | ||
args: "after-used", | ||
ignoreRestSiblings: false, | ||
argsIgnorePattern: "^_", | ||
}, | ||
], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ["**/*.test.ts", "**/*.test.tsx"], | ||
plugins: ["jest"], | ||
}, | ||
], | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/** @type {import('ts-jest').JestConfigWithTsJest} */ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node", | ||
setupFiles: ["<rootDir>/.jest/setup.js"], | ||
}; |
Oops, something went wrong.