mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
feat: videos automation
This commit is contained in:
1 parent
b5188331bd
commit
a55c259205
6 files changed
+233
-12
No files matched your search
@@ -24,15 +24,17 @@ import { skillIcons } from './skillIcons';
|
||||
import { tankArmors } from './tankArmors';
|
||||
import { tankIcons } from './tankIcons';
|
||||
import { tankModels } from './tankModels';
|
||||
import { videos } from './videos';
|
||||
|
||||
if (!targets && !allTargets) throw new Error('No target(s) specified');
|
||||
|
||||
const methods = [
|
||||
// definitions,
|
||||
// scratchedFlags,
|
||||
// currencies,
|
||||
// skillIcons,
|
||||
// circleFlags,
|
||||
definitions,
|
||||
videos,
|
||||
scratchedFlags,
|
||||
currencies,
|
||||
skillIcons,
|
||||
circleFlags,
|
||||
shellIcons,
|
||||
moduleIcons,
|
||||
equipmentIcons,
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import { google } from 'googleapis';
|
||||
import { env } from 'process';
|
||||
import { commitAssets } from '../../src/core/blitzkrieg/commitAssets';
|
||||
|
||||
export async function videos(production: boolean) {
|
||||
console.log('Building videos...');
|
||||
|
||||
const auth = await google.auth.getClient({
|
||||
scopes: ['https://www.googleapis.com/auth/spreadsheets.readonly'],
|
||||
});
|
||||
const sheets = google.sheets({ version: 'v4', auth });
|
||||
const response = await sheets.spreadsheets.values.get({
|
||||
spreadsheetId: env.VIDEOS_SHEET,
|
||||
range: 'Sheet1!A:E',
|
||||
});
|
||||
|
||||
if (!response.data.values) {
|
||||
console.warn('Google returned no data; skipping videos...');
|
||||
return;
|
||||
}
|
||||
|
||||
const content = response.data.values
|
||||
.slice(1)
|
||||
.map((row) => {
|
||||
const [idString, ...videosRaw] = row.slice(1);
|
||||
const id = Number(idString);
|
||||
const videos = videosRaw
|
||||
.map((raw) => new URL(raw).searchParams.get('v'))
|
||||
.filter((video) => video !== null);
|
||||
return `${id},${videos.join(',')}`;
|
||||
})
|
||||
.join('\n');
|
||||
|
||||
await commitAssets(
|
||||
'videos',
|
||||
[
|
||||
{
|
||||
content,
|
||||
encoding: 'utf-8',
|
||||
path: 'definitions/videos.csv',
|
||||
},
|
||||
],
|
||||
production,
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user