commit 0d358fcccecc9f3b250576cbae924ddacb924aaa Author: Alexandre Blanco Gomez Date: Fri Sep 12 11:13:14 2025 +0200 Migrate from gitea diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f4f8e27 --- /dev/null +++ b/.gitignore @@ -0,0 +1,164 @@ +# ---> Python +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# vscode +.vscode \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d5a8bc3 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# scripts_video + +Useful commands +``` +ffmpeg -i Millennium.Mambo.2001.UHD.BluRay.2160p.DTS-HD.MA.5.1.DV.HEVC.HYBRID.REMUX-FraMeSToR.mkv -c:v copy -bsf:v hevc_mp4toannexb -f hevc - | dovi_tool -m 2 convert --discard - + +ffmpeg -i My.Darling.Clementine.1946.1080p.BluRay.REMUX.AVC.DTS-HD.MA.1.0-EPSiLON\ \(1\).mkv -map 0 -codec copy -map 0:1 -c:a:0 pcm_s32le Darling_out.mkv + +ffmpeg -i Yi.Yi.2000.1080p.CC.Blu-ray.REMUX.AVC.DTS-HD.MA2.0-HDH.mkv -map 0 -codec copy -c:a aac -b:a 320k Yi.Yi.2000.1080p.CC.Blu-ray.REMUX.AVC.DTS-HD.MA2.0.AAC-HDH.mkv + +tdarr-ffmpeg -i /Data/Pelis/My.Darling.Clementine.1946.1080p.BluRay.REMUX.AVC.DTS-HD.MA.PCM.1.0-EPSiLON.mkv -map 0 -c:v copy -c:a copy -map 0:4 -c:a:0 libfdk_aac -vbr 5 -ac 2 -metadata:s:a:0 'title="2.0 tdarr"' -strict -2 -c:s copy -metadata 'comment="2.0 tdarr"' -max_muxing_queue_size 9999 "/Data/cache tdarr/tdarr-workDir2-9uw7bakt1/My.Darling.Clementine.1946.1080p.BluRay.REMUX.AVC.DTS-HD.MA.PCM.1.0-EPSiLON-TdarrCacheFile-uiqLfj6uf.mkv" + +ffmpeg -i /Data/Pelis/My.Darling.Clementine.1946.1080p.BluRay.REMUX.AVC.DTS-HD.MA.PCM.1.0-EPSiLON.mkv -map 0 -c:v copy -c:a copy -map 0:1 -c:a:0 libfdk_aac -vbr 5 -ac 2 -c:s copy output.mkv" + +ffmpeg -i "$file" -map 0 -codec copy -c:s mov_text -movflags +faststart -strict experimental "$output" + +D:\Documentos\Descargas\ffmpeg.exe -i E:\Okja.2017.UHD.BluRay.2160p.TrueHD.Atmos.7.1.DV.HEVC.REMUX-FraMeSToR.mkv -c:a libfdk_aac -vbr 5 -ac 2 okja.aac + +ffmpeg -i /Data/Pelis/My.Darling.Clementine.1946.1080p.BluRay.REMUX.AVC.DTS-HD.MA.PCM.1.0-EPSiLON.mkv -c:a:0 libfdk_aac -vbr 5 -af "volume=1.66,pan=stereo|c0=0.5*c2+0.707*c0+0.707*c4+0.5*c3|c1=0.5*c2+0.707*c1+0.707*c5+0.5*c3" "outputstereo.aac" + +``` \ No newline at end of file diff --git a/plugins_tdarr/Tdarr_Plugin_Alex_DownmixStereo.js b/plugins_tdarr/Tdarr_Plugin_Alex_DownmixStereo.js new file mode 100644 index 0000000..ddac828 --- /dev/null +++ b/plugins_tdarr/Tdarr_Plugin_Alex_DownmixStereo.js @@ -0,0 +1,106 @@ +/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */ +const details = () => ({ + id: 'Tdarr_Plugin_Alex_DownmixStereo', + Stage: 'Pre-processing', + Name: 'Alex-DownmixStereo', + Type: 'Audio', + Operation: 'Transcode', + Description: 'Todos los streams de audio que no sean 2.0, les hago downmix \n\n', + Version: '2.4', + Tags: 'pre-processing,ffmpeg,audio only,configurable', + Inputs: [], +}); + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + const response = { + processFile: false, + container: `.${file.container}`, + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '', + }; + + // Check if file is a video. If it isn't then exit plugin. + if (file.fileMedium !== 'video') { + // eslint-disable-next-line no-console + console.log('File is not video'); + response.infoLog += '☒File is not video. \n'; + response.processFile = false; + return response; + } + + // Set up required variables. + let ffmpegCommandInsert = ''; + let audioIdx = 0; + let convert = false; + let already_converted = false; + let only_convert_dts = false; + + //if (file.video_resolution.includes("1080p")){ + // only_convert_dts = true; + //} + only_convert_dts = true; + // Go through each stream in the file. + if ("comment" in file.ffProbeData.format.tags){ + if (file.ffProbeData.format.tags.comment.includes("2.0 tdarr")){ + already_converted = true; + } + } + if ("COMMENT" in file.ffProbeData.format.tags){ + if (file.ffProbeData.format.tags.COMMENT.includes("2.0 tdarr")){ + already_converted = true; + } + } + + // for (let i = 0; i < file.ffProbeData.streams.length; i++) { + // try { + // // Go through all audio streams and check if 2 is already converted. + // if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') { + // if (file.ffProbeData.streams[i].channels === 2 && file.ffProbeData.streams[i].tags.title.includes("2.0 tdarr")) { + // already_converted = true; + // } + // } + // } catch (err) { + // // Error + // } + // } + + // Go through each stream in the file. + for (let i = 0; i < file.ffProbeData.streams.length; i++) { + // Check if stream is audio. + if (file.ffProbeData.streams[i].codec_type.toLowerCase() === 'audio') { + if (only_convert_dts === true){ + //si la pista no es dts: continue; + if (!file.ffProbeData.streams[i].codec_long_name.includes("DCA")){ + continue; + } + } + if (file.ffProbeData.streams[i].channels !== 2) { + //ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} libmp3lame -q:a 2 -ac 2 -metadata:s:a:${audioIdx} title="2.0 tdarr" `; + ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} libfdk_aac -vbr 5 -af "volume=1.66,pan=stereo|c0=0.5*c2+0.707*c0+0.707*c4+0.5*c3|c1=0.5*c2+0.707*c1+0.707*c5+0.5*c3" -metadata:s:a:${audioIdx} title="2.0 tdarr" `; + //ffmpegCommandInsert += `-map 0:${i} -c:a:${audioIdx} aac -ac 2 -metadata:s:a:${audioIdx} title="2.0 tdarr" `; + response.infoLog += `Creating 2 channel from audio stream ${audioIdx}. \n`; + convert = true; + } + audioIdx += 1; + } + } + + // Convert file if convert variable is set to true. + if (convert === false || already_converted === true) { + response.infoLog += '☑File contains all required audio formats. \n'; + response.processFile = false; + } else { + response.processFile = true; + response.preset = `, -map 0 -c:v copy -c:a copy ${ffmpegCommandInsert} ` + + '-strict -2 -c:s copy -metadata comment="2.0 tdarr" -max_muxing_queue_size 9999 '; + } + return response; +}; +module.exports.details = details; +module.exports.plugin = plugin; diff --git a/plugins_tdarr/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_Docker.js b/plugins_tdarr/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_Docker.js new file mode 100644 index 0000000..8e84b16 --- /dev/null +++ b/plugins_tdarr/Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_Docker.js @@ -0,0 +1,56 @@ +/* eslint-disable */ + + +// tdarrSkipTest +const details = () => { + return { + id: "Tdarr_Plugin_O8O0dCTlb_Set_File_Permissions_For_Docker", + Stage: 'Pre-processing', + Name: "Set file permissions for Docker", + Type: "Video", + Operation: "Transcode", + Description: "Sets file permissions using chmod 777. Use at end of stack. ", + Version: "", + Tags: "post-processing", + Inputs:[], + } +} + +// eslint-disable-next-line no-unused-vars +const plugin = (file, librarySettings, inputs, otherArguments) => { + + const lib = require('../methods/lib')(); + // eslint-disable-next-line no-unused-vars,no-param-reassign + inputs = lib.loadDefaultValues(inputs, details); + + //Must return this object at some point + var response = { + processFile: false, + preset: '', + container: '.mkv', + handBrakeMode: false, + FFmpegMode: true, + reQueueAfter: true, + infoLog: '', + + } + + response.infoLog += "" + + if ((true) || file.forceProcessing === true) { + + require("child_process").execSync(`chmod 777 "${file._id}"`) + response.preset = '' + response.container = '.mkv' + response.handBrakeMode = false + response.FFmpegMode = true + response.reQueueAfter = true; + response.processFile = false + response.infoLog += "File permissions set \n" + return response + } +} + + +module.exports.details = details; +module.exports.plugin = plugin; \ No newline at end of file diff --git a/renombrar_subs/renombrar.py b/renombrar_subs/renombrar.py new file mode 100644 index 0000000..3fbb0c0 --- /dev/null +++ b/renombrar_subs/renombrar.py @@ -0,0 +1,19 @@ +import sys +import os +import shutil + + +ruta_base = sys.argv [1] + +nombre_carpeta_subs = "Subs" +ruta_subs = os.path.join(ruta_base,nombre_carpeta_subs) + +for nombre in (subcarpeta for subcarpeta in os.listdir(ruta_subs) if not os.path.isfile(subcarpeta) ): + ruta_subcarpeta = os.path.join(ruta_subs,nombre) + nombre_fichero_sub = [x for x in os.listdir(ruta_subcarpeta) if "English" in x][0] + + origen = os.path.join(ruta_subcarpeta,nombre_fichero_sub) + destino = os.path.join(ruta_base,nombre+".en.srt") + #print("oringe: "+origen) + #print("destino: "+destino) + shutil.copyfile(origen, destino) \ No newline at end of file