-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add "transcode configurations" (#1001)
This adds the notion of creating and maintaining transcode configurations. This is a generalization of the current ffmpeg settings flow. Users can edit various settings relating to transcoding in each config and then assign a configuration to a channel. This allows for more fine-grained customization of transcoding per-channel and also allows for users to test new configurations without affecting the global state of Tunarr.
- Loading branch information
1 parent
891ed29
commit b5a4fdf
Showing
49 changed files
with
2,849 additions
and
1,041 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,25 @@ | ||
import { getMigrator } from '@/db/DBAccess.ts'; | ||
import { isEmpty } from 'lodash-es'; | ||
import { CommandModule } from 'yargs'; | ||
|
||
export const DatabaseListMigrationsCommand: CommandModule = { | ||
command: 'list', | ||
describe: 'Tunarr database migration commands', | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
handler: async () => { | ||
const migrator = getMigrator(); | ||
const migrations = await migrator.getMigrations(); | ||
if (isEmpty(migrations)) { | ||
console.info('No migrations found!'); | ||
return; | ||
} | ||
|
||
console.info( | ||
`Found ${migrations.length} migration${migrations.length > 1 ? 's' : ''}`, | ||
); | ||
|
||
for (const migration of migrations) { | ||
console.log(`${migration.executedAt ? '✓' : ' '} ${migration.name}`); | ||
} | ||
}, | ||
}; |
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,34 @@ | ||
import { getMigrator } from '@/db/DBAccess.ts'; | ||
import { isNonEmptyString } from '@/util/index.ts'; | ||
import { CommandModule } from 'yargs'; | ||
import { isWrongMigrationDirection } from './databaseCommandUtil.ts'; | ||
|
||
interface DatabaseMigrateDownCommandArgs { | ||
migrationName?: string; | ||
} | ||
|
||
export const DatabaseMigrateDownCommand: CommandModule< | ||
DatabaseMigrateDownCommandArgs, | ||
DatabaseMigrateDownCommandArgs | ||
> = { | ||
command: 'down [migrationName]', | ||
describe: 'Undo the last run or specificed migration', | ||
builder: (yargs) => | ||
yargs.positional('migrationName', { demandOption: false, type: 'string' }), | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
handler: async (args) => { | ||
const migrator = getMigrator(); | ||
if (await isWrongMigrationDirection(args.migrationName, 'down', migrator)) { | ||
console.info('No migrations found!'); | ||
return; | ||
} | ||
|
||
console.info('Starting migration down'); | ||
|
||
const resultSet = isNonEmptyString(args.migrationName) | ||
? await migrator.migrateTo(args.migrationName) | ||
: await migrator.migrateDown(); | ||
|
||
console.log(resultSet); | ||
}, | ||
}; |
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 { getMigrator } from '@/db/DBAccess.ts'; | ||
import { isNonEmptyString } from '@/util/index.ts'; | ||
import { CommandModule } from 'yargs'; | ||
import { isWrongMigrationDirection } from './databaseCommandUtil.ts'; | ||
|
||
interface DatabaseMigrateUpCommandArgs { | ||
migrationName?: string; | ||
} | ||
|
||
export const DatabaseMigrateUpCommand: CommandModule< | ||
DatabaseMigrateUpCommandArgs, | ||
DatabaseMigrateUpCommandArgs | ||
> = { | ||
command: 'up [migrationName]', | ||
describe: 'Apply the next run or up to the specificed migration', | ||
builder: (yargs) => | ||
yargs.positional('migrationName', { demandOption: false, type: 'string' }), | ||
handler: async (args) => { | ||
const migrator = getMigrator(); | ||
if (await isWrongMigrationDirection(args.migrationName, 'up', migrator)) { | ||
console.warn( | ||
`Migration skipped: "${args.migrationName}" has already been run`, | ||
); | ||
return; | ||
} | ||
|
||
console.info('Starting migration up'); | ||
|
||
const resultSet = isNonEmptyString(args.migrationName) | ||
? await migrator.migrateTo(args.migrationName) | ||
: await migrator.migrateUp(); | ||
|
||
console.log(resultSet); | ||
}, | ||
}; |
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 { Maybe } from '@/types/util.ts'; | ||
import { isNonEmptyString } from '@/util/index.ts'; | ||
import { Migrator } from 'kysely'; | ||
import { isNil, isUndefined } from 'lodash-es'; | ||
|
||
export async function isWrongMigrationDirection( | ||
name: Maybe<string>, | ||
expectedMigrationDiration: 'up' | 'down', | ||
migrator: Migrator, | ||
) { | ||
if (!isNonEmptyString(name)) { | ||
return false; | ||
} | ||
|
||
const migrations = await migrator.getMigrations(); | ||
|
||
return !isUndefined( | ||
migrations.find( | ||
(migration) => | ||
migration.name === name && | ||
((expectedMigrationDiration === 'up' && !isNil(migration.executedAt)) || | ||
(expectedMigrationDiration === 'down' && | ||
isNil(migration.executedAt))), | ||
), | ||
); | ||
} |
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,23 @@ | ||
import { CommandModule } from 'yargs'; | ||
import { DatabaseListMigrationsCommand } from './DatabaseListMigrationsCommand.ts'; | ||
import { DatabaseMigrateDownCommand } from './DatabaseMigrateDownCommand.ts'; | ||
import { DatabaseMigrateUpCommand } from './DatabaseMigrateUpCommand .ts'; | ||
|
||
export const databaseCommands: CommandModule = { | ||
command: 'db <command>', | ||
describe: 'Database commands', | ||
builder: (yargs) => yargs.command(databaseMigrationCommands), | ||
handler: () => {}, | ||
}; | ||
|
||
const databaseMigrationCommands: CommandModule = { | ||
command: 'migration <command>', | ||
describe: 'Database migration commands', | ||
builder: (yargs) => | ||
yargs.command([ | ||
DatabaseListMigrationsCommand, | ||
DatabaseMigrateDownCommand, | ||
DatabaseMigrateUpCommand, | ||
]), | ||
handler: () => {}, | ||
}; |
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.