This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
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
21 changed files
with
4,081 additions
and
0 deletions.
There are no files selected for viewing
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,15 @@ | ||
{ | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"extends": ["plugin:@typescript-eslint/recommended", "prettier"], | ||
"plugins": ["prettier"], | ||
"rules": { | ||
"prettier/prettier": ["error"] | ||
}, | ||
"env": { | ||
"node": true | ||
} | ||
} |
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,39 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/.next/ | ||
/out/ | ||
/build | ||
/dist | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo | ||
next-env.d.ts |
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,7 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"semi": false, | ||
"singleQuote": true, | ||
"printWidth": 150, | ||
"bracketSameLine": true | ||
} |
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,3 @@ | ||
{ | ||
"recommendations": ["esbenp.prettier-vscode"] | ||
} |
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,4 @@ | ||
{ | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "esbenp.prettier-vscode" | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,76 @@ | ||
{ | ||
"name": "media-tools", | ||
"description": "Tools to manage our events' media, streaming, recording and archiving ", | ||
"version": "0.1.0", | ||
"license": "MIT", | ||
"scripts": { | ||
"build": "tsc", | ||
"start": "NODE_PATH=./dist node ./dist/index", | ||
"dev": "nodemon ./src/index.ts", | ||
"test": "NODE_ENV=test jest --detectOpenHandles --watchAll --no-cache", | ||
"test:coverage": "NODE_ENV=test jest --coverage --detectOpenHandles --no-cache", | ||
"lint": "eslint --fix", | ||
"prettier": "prettier './src' --write", | ||
"run:mp3": "nodemon ./src/mp3.ts", | ||
"run:mp3-opening": "nodemon ./src/mp3-opening.ts" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"./src": [ | ||
"lint", | ||
"prettier" | ||
] | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"testEnvironment": "node", | ||
"rootDir": "./src", | ||
"coverageDirectory": "../coverage", | ||
"moduleDirectories": [ | ||
"node_modules", | ||
"src" | ||
], | ||
"moduleFileExtensions": [ | ||
"js", | ||
"ts" | ||
] | ||
}, | ||
"dependencies": { | ||
"@ethersproject/providers": "^5.7.1", | ||
"@types/fluent-ffmpeg": "^2.1.20", | ||
"cross-fetch": "^3.1.5", | ||
"dayjs": "^1.11.7", | ||
"dotenv": "^16.0.3", | ||
"ethereum-blockies-base64": "^1.0.2", | ||
"fluent-ffmpeg": "^2.1.2", | ||
"gray-matter": "^4.0.3", | ||
"markdown-it": "^13.0.1", | ||
"slugify": "^1.6.5", | ||
"ytdl-core": "^4.11.2" | ||
}, | ||
"devDependencies": { | ||
"@tsconfig/recommended": "^1.0.2", | ||
"@types/dotenv": "^8.2.0", | ||
"@types/jest": "^29.2.5", | ||
"@types/markdown-it": "^12.2.3", | ||
"@types/node": "^18.11.18", | ||
"@typescript-eslint/eslint-plugin": "^5.48.2", | ||
"@typescript-eslint/parser": "^5.48.2", | ||
"eslint": "8.23.1", | ||
"eslint-config-prettier": "^8.6.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"husky": "^8.0.3", | ||
"jest": "^29.3.1", | ||
"lint-staged": "^13.1.0", | ||
"nodemon": "^2.0.20", | ||
"prettier": "^2.8.3", | ||
"ts-jest": "^29.0.5", | ||
"ts-node": "^10.9.1", | ||
"tsconfig-paths": "^4.1.2", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
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,13 @@ | ||
import ffmpeg from 'fluent-ffmpeg' | ||
import { Readable } from 'stream' | ||
import { CONFIG } from 'utils/config' | ||
|
||
export async function ToMp3(id: string, stream: Readable, bitrate = CONFIG.BITRATE) { | ||
console.log('Convert to mp3', id) | ||
|
||
try { | ||
ffmpeg(stream).audioBitrate(bitrate).format('mp3').save(`${CONFIG.OUTPUT_FOLDER}/mp3/${id}.mp3`).on('error', console.error) | ||
} catch (error) { | ||
console.log('Unable to convert to mp3', id, error) | ||
} | ||
} |
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,26 @@ | ||
import ytdl from 'ytdl-core' | ||
|
||
export async function GetVideoInfo(id: string) { | ||
console.log('Get YouTube video info', id) | ||
return await ytdl.getInfo(id) | ||
} | ||
|
||
export async function GetVideoStream(id: string, quality: 'highestvideo' | 'highestaudio' = 'highestvideo') { | ||
console.log('Get YouTube video stream', id) | ||
|
||
try { | ||
return ytdl(id, { | ||
quality: quality, | ||
}) | ||
} catch (e) { | ||
console.log('Unable to fetch video stream', id, e) | ||
} | ||
} | ||
|
||
export async function UpdateMetadata(id: string, session: any) { | ||
console.log('Update YouTube metadata for', id) | ||
} | ||
|
||
export async function UploadThumbnail(id: string, thumbnail: string) { | ||
console.log('Upload YouTube thumbnail for', id) | ||
} |
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 @@ | ||
import { CONFIG } from 'utils/config' | ||
|
||
console.log('Running in', CONFIG.NODE_ENV, 'mode') | ||
|
||
Run() | ||
|
||
async function Run() { | ||
process.exit(0) | ||
} |
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,25 @@ | ||
import { ToMp3 } from 'actions/ffmpeg' | ||
import { GetVideoStream } from 'actions/youtube' | ||
import { GetSessions } from 'sources/api' | ||
import { CONFIG } from 'utils/config' | ||
|
||
console.log('Running in', CONFIG.NODE_ENV, 'mode') | ||
|
||
Run() | ||
|
||
async function Run() { | ||
const sessions = await GetSessions() | ||
const opening = ['UihMqcj-cqc', 'noXPewi5qOk', 'GGXveC7dn7o', 'iF6_JMf6CDM', 'ql082HLTndA', 'xUAbw3QhP5c', '1C5W7iCLDPY'] | ||
|
||
opening.forEach(async (s) => { | ||
const session = sessions.find((i: any) => i.sources_youtubeId === s) | ||
if (!session) return | ||
// if (session.sources_youtubeId === 'xjEK8PrH9kQ' || session.sources_youtubeId === 'FS9PPDSK6wc' || session.sources_youtubeId === 'okaoDabqt_E') return | ||
|
||
const stream = await GetVideoStream(s, 'highestaudio') | ||
if (!stream) return | ||
|
||
await ToMp3(session.id, stream) | ||
await new Promise((r) => setTimeout(r, 1000)) | ||
}) | ||
} |
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,8 @@ | ||
import fetch from 'cross-fetch' | ||
|
||
export async function GetSessions() { | ||
console.log('Fetching sessions from Devcon API') | ||
const response = await fetch('https://devcon-api.onrender.com/sessions/') | ||
const result = await response.json() | ||
return result.data | ||
} |
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,13 @@ | ||
import { join } from 'path' | ||
import dotenv from 'dotenv' | ||
|
||
dotenv.config() | ||
|
||
export const CONFIG = { | ||
NODE_ENV: process.env.NODE_ENV || 'development', | ||
|
||
OUTPUT_FOLDER: process.env.OUTPUT_FOLDER || join(process.cwd(), 'output'), | ||
BITRATE: process.env.BITRATE || 128, | ||
|
||
GITHUB_TOKEN: process.env.GITHUB_TOKEN, | ||
} |
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,15 @@ | ||
{ | ||
"extends": "@tsconfig/recommended/tsconfig.json", | ||
"compilerOptions": { | ||
"target": "ES2017", | ||
"resolveJsonModule": true, | ||
"isolatedModules": false, | ||
"outDir": "dist", | ||
"baseUrl": "./src" | ||
}, | ||
"ts-node": { | ||
"require": ["tsconfig-paths/register"] | ||
}, | ||
"include": ["./src"], | ||
"exclude": ["node_modules", "./src/**/*.test.ts", "./src/**/*.spec.ts"] | ||
} |
Oops, something went wrong.