Skip to content

Commit

Permalink
Merge branch 'master' into pr/294
Browse files Browse the repository at this point in the history
  • Loading branch information
HaveAGitGat committed May 8, 2024
2 parents d287888 + 8472813 commit ef60e38
Show file tree
Hide file tree
Showing 416 changed files with 32,993 additions and 1,672 deletions.
108 changes: 82 additions & 26 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,87 @@
{
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": [
"airbnb-base"
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
}
},
"env": {
"commonjs": true,
"es6": true,
"node": true
},
"extends": [
"airbnb-base",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"plugins": [
"prefer-arrow-functions"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"project": [
"./tsconfig.eslint.json"
]
},
"rules": {
"func-style": [
"error",
"expression"
],
"prefer-arrow-functions/prefer-arrow-functions": [
"warn",
{
"classPropertiesAllowed": false,
"disallowPrototype": false,
"returnStyle": "unchanged",
"singleReturnOnly": false
}
],
"require-await":["error"],
"global-require": 0,
"no-void": 0,
"@typescript-eslint/no-floating-promises": [
"error"
],
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"global-require":0,
"class-methods-use-this": 0,
"no-case-declarations": 0,
"camelcase": 0,
"jsx-a11y/click-events-have-key-events": 0,
"no-underscore-dangle": ["error", { "allow": ["_id"] }],
"max-len": [
"error",
{
"code": 120
}
"@typescript-eslint/no-var-requires": 0,
"class-methods-use-this": 0,
"no-case-declarations": 0,
"camelcase": 0,
"jsx-a11y/click-events-have-key-events": 0,
"no-underscore-dangle": [
"error",
{
"allow": [
"_id"
]
}
],
"max-len": [
"error",
{
"code": 120
}
],
"import/extensions": [
"error",
"ignorePackages",
{
"js": "never",
"jsx": "never",
"ts": "never",
"tsx": "never"
}
]
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
43 changes: 39 additions & 4 deletions .github/workflows/lint_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ on:
branches: ['**']

jobs:
build:
test:
strategy:
matrix:
node-version: [16.x]
node-version: [18.x]
os:
[
["ubuntu-20.04"],
Expand All @@ -23,12 +23,47 @@ jobs:
git config --global core.autocrlf false
git config --global core.eol lf
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm i
- run: npm i -g typescript && tsc
- run: npm run checkPlugins
- run: npm run lint
- run: npm run test

auto_compile_and_push:
if: github.ref != 'refs/heads/master'
needs: [
test
]
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the changed files back to the repository.
contents: write

steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- uses: actions/setup-node@v3
with:
node-version: '18.x'

- run: npm i && npm i -g typescript && rm -rdf ./FlowPlugins && tsc -v && tsc

- uses: stefanzweifel/git-auto-commit-action@v5
if: ${{ github.event.pull_request.head.repo.full_name == 'org/repo' }}
with:
commit_message: Apply auto-build changes

- run: |
(git diff --quiet HEAD -- 2>/dev/null && echo "No uncommitted changes" \
|| (echo "Error - Uncommitted changes found." && git --no-pager diff HEAD && exit 1))
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@

### VS Code ###
.vscode/

/Local
/FlowPluginsTs/LocalFlowPlugins
/FlowPlugins/LocalFlowPlugins
4 changes: 2 additions & 2 deletions Community/Tdarr_Plugin_00td_action_add_audio_stream_codec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ const details = () => ({
],
});

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
Expand Down
4 changes: 2 additions & 2 deletions Community/Tdarr_Plugin_00td_action_handbrake_basic_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,10 @@ const details = () => ({
],
});

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
Expand Down
4 changes: 2 additions & 2 deletions Community/Tdarr_Plugin_00td_action_handbrake_ffmpeg_custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ HandBrake examples:
],
});

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
Expand Down
4 changes: 2 additions & 2 deletions Community/Tdarr_Plugin_00td_action_keep_one_audio_stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ If no specified language track exists, the best untagged/undefined stream will b
],
});

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
Expand Down
16 changes: 14 additions & 2 deletions Community/Tdarr_Plugin_00td_action_re_order_all_streams_v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ The default order is suitable for most people.
],
});

// eslint-disable-next-line no-unused-vars
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
Expand All @@ -102,6 +102,18 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
+ 'This may be due to a corrupt file or permissions issue when scanning the file.');
}

if (file.container === 'mp4' && file.fileMedium === 'video') {
if (file.ffProbeData.streams[0].codec_type === 'video') {
response.infoLog += 'File is mp4 and already has the video stream in the correct order!'
+ ' Due to FFmpeg issues when reordering streams in mp4 files, other stream ordering will be skipped';
return response;
}
response.processFile = true;
response.infoLog += 'File is mp4 and contains video but video is not first stream, remuxing';
response.preset = ',-map 0:v? -map 0:a? -map 0:s? -map 0:d? -map 0:t? -c copy';
return response;
}

let { streams } = JSON.parse(JSON.stringify(file.ffProbeData));

streams.forEach((stream, index) => {
Expand Down
100 changes: 100 additions & 0 deletions Community/Tdarr_Plugin_00td_action_remove_audio_by_channel_count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
const details = () => ({
id: 'Tdarr_Plugin_00td_action_remove_audio_by_channel_count',
Stage: 'Pre-processing',
Name: 'Remove audio streams by channel count',
Type: 'Video',
Operation: 'Transcode',
Description: `
This plugin removes audio streams based on channel count. The output container is the same as the original.
If the file only has one audio stream, the plugin will be skipped. If the number of audio streams to remove
equals the total number of audio streams, the plugin will be skipped. This ensures there is always at least
one audio stream in the file.
`,
Version: '1.00',
Tags: 'action',
Inputs: [
{
name: 'channelCounts',
type: 'string',
defaultValue: '',
inputUI: {
type: 'text',
},
tooltip:
`Enter the the channel counts to remove.
\\nExample:\\n
8,6
`,
},
],
});

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line @typescript-eslint/no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
const response = {
processFile: false,
preset: '',
container: `.${file.container}`,
handBrakeMode: false,
FFmpegMode: true,
reQueueAfter: false,
infoLog: '',
};

if (inputs.channelCounts.trim() === '') {
response.infoLog += 'No input entered in plugin, skipping';
return response;
}

const audioStreams = file.ffProbeData.streams.filter((row) => row.codec_type === 'audio');

if (audioStreams.length === 0) {
response.infoLog += 'File has no audio streams, skipping plugin';
return response;
}

if (audioStreams.length === 1) {
response.infoLog += 'File only has 1 audio stream, skipping plugin';
return response;
}

response.preset += ', -map 0 -c copy -max_muxing_queue_size 9999';

const audioToRemove = [];
const channelCounts = inputs.channelCounts.trim().split(',');

for (let i = 0; i < channelCounts.length; i += 1) {
const channelCount = parseInt(channelCounts[i], 10);
for (let j = 0; j < audioStreams.length; j += 1) {
if (channelCount === audioStreams[j].channels) {
audioToRemove.push(audioStreams[j]);
}
}
}

if (audioToRemove.length === 0) {
response.infoLog += 'No audio streams to remove!';
return response;
}

if (audioToRemove.length === audioStreams.length) {
response.infoLog += 'The number of audio streams to remove equals '
+ 'the total number of audio streams, skipping plugin';
return response;
}

audioToRemove.forEach((row) => {
response.preset += ` -map -0:${row.index} `;
response.infoLog += ` Removing stream ${row.index} which has ${row.channels} channels.`;
});

response.processFile = true;
return response;
};

module.exports.details = details;
module.exports.plugin = plugin;
Loading

0 comments on commit ef60e38

Please sign in to comment.