-
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
Showing
25 changed files
with
3,111 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,37 @@ | ||
/** | ||
* Just a one time script to generate a video pack. This may be removed in the future. | ||
*/ | ||
|
||
import darmstadt from "../src/data/dojos/aikido-dojo-darmstadt/details.ts"; | ||
import { resolveExamTables } from "$core/resolveExamTables"; | ||
import { buildTechniqueTree } from "$core/buildExamTable/buildExamTable.ts"; | ||
import type { VideoPack } from "$core/model/VideoPack.ts"; | ||
import { coerceToArray } from "$core/utils/coerceToArray.ts"; | ||
|
||
import prettier from "prettier"; | ||
|
||
const allTechniques = resolveExamTables(darmstadt.exams); | ||
|
||
let counter = 0; | ||
for (const technique of allTechniques) { | ||
for (const youtube of coerceToArray(technique.metadata.youtube)) { | ||
youtube.id = String(counter++); | ||
} | ||
} | ||
|
||
const pack: VideoPack = { | ||
name: "Aikido Kompendium", | ||
source: "https://www.aikido-kompendium.de", | ||
videos: buildTechniqueTree(allTechniques, (technique) => coerceToArray(technique.metadata.youtube)), | ||
}; | ||
|
||
// eslint-disable-next-line no-console | ||
console.log( | ||
await prettier.format( | ||
`import type {VideoPack} from "$core/model/VideoPack"; | ||
export default ${JSON.stringify(pack, null, 2)} satisfies VideoPack | ||
`, | ||
{ parser: "typescript" }, | ||
), | ||
); |
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,48 @@ | ||
import { youtubeEnabled } from "$core/store/youtube.ts"; | ||
|
||
export interface YoutubeAdapter { | ||
loadVideoById(videoId: string, startSeconds?: number, endSeconds?: number): Promise<void>; | ||
playVideo(): Promise<void>; | ||
stopVideo(): Promise<void>; | ||
setSize(width: number, height: number): Promise<object>; | ||
waitForStop(): Promise<void>; | ||
getCurrentTime(): Promise<number>; | ||
destroy(): Promise<void>; | ||
} | ||
|
||
export async function loadYoutubeAdapter(container: HTMLDivElement): Promise<YoutubeAdapter> { | ||
if (!youtubeEnabled.get()) { | ||
throw new Error("No youtube consent was given."); | ||
} | ||
const { default: Player } = await import("youtube-player"); | ||
const player = Player(container, { | ||
host: "https://www.youtube-nocookie.com", | ||
playerVars: { | ||
rel: 0, | ||
autoplay: 0, | ||
modestbranding: 1, | ||
controls: 1, | ||
}, | ||
}); | ||
|
||
return { | ||
playVideo: player.playVideo, | ||
loadVideoById(videoId, startSeconds, endSeconds) { | ||
return player.loadVideoById({ videoId, startSeconds, endSeconds }); | ||
}, | ||
stopVideo: player.stopVideo, | ||
setSize: player.setSize, | ||
waitForStop() { | ||
return new Promise<void>((resolve) => { | ||
player.on("stateChange", (event) => { | ||
if (event.data === 0) { | ||
// Video has ended | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
}, | ||
getCurrentTime: player.getCurrentTime, | ||
destroy: player.destroy, | ||
}; | ||
} |
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
Oops, something went wrong.