2023-03-22 00:42:07 +01:00
|
|
|
# Dynamic folders
|
|
|
|
|
2023-03-21 19:06:21 +01:00
|
|
|
Collection of Bash scripts that execute functionalities in folders.
|
2023-04-04 09:13:39 +02:00
|
|
|
|
2023-04-18 12:56:23 +02:00
|
|
|
## Video optmizer
|
|
|
|
|
2023-04-18 15:27:40 +02:00
|
|
|
Folder that watches when new videos are added and optimizes them.
|
|
|
|
|
2023-04-18 12:56:23 +02:00
|
|
|
### Requirements
|
|
|
|
|
|
|
|
- `inotify-tools`
|
|
|
|
- `ffmpeg`
|
|
|
|
|
|
|
|
Example in Debian.
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
sudo apt install inotify-tools ffmpeg
|
|
|
|
```
|
2023-04-04 09:13:39 +02:00
|
|
|
|
|
|
|
### Install
|
|
|
|
|
|
|
|
|
2023-04-18 12:56:23 +02:00
|
|
|
``` sh
|
2023-04-18 14:11:54 +02:00
|
|
|
curl -o dynamic-folders-video-optimizer https://raw.githubusercontent.com/tanrax/dynamic-folders/main/dynamic-folders-video-optimizer.sh && chmod +x dynamic-folders-video-optimizer && sudo mv dynamic-folders-video-optimizer /usr/local/bin && echo "🎉 Successfully installed! 🎉"
|
|
|
|
```
|
|
|
|
|
|
|
|
Test
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
dynamic-folders-video-optimizer --help
|
2023-04-18 12:56:23 +02:00
|
|
|
```
|
2023-04-04 09:13:39 +02:00
|
|
|
|
2023-04-18 12:56:23 +02:00
|
|
|
### Run
|
|
|
|
|
|
|
|
``` sh
|
2023-04-18 14:11:54 +02:00
|
|
|
dynamic-folders-video-optimizer --folder [folder to watch]
|
|
|
|
```
|
|
|
|
|
|
|
|
Example.
|
|
|
|
|
|
|
|
``` sh
|
2023-04-18 16:48:54 +02:00
|
|
|
mkdir optimizer
|
2023-04-18 14:11:54 +02:00
|
|
|
dynamic-folders-video-optimizer --folder optimizer
|
2023-04-18 12:38:12 +02:00
|
|
|
```
|
|
|
|
|
2023-04-18 14:11:54 +02:00
|
|
|
And leave a video that you want to optimize in the folder `optimizer`.
|
|
|
|
|
2023-04-18 16:43:18 +02:00
|
|
|
### Start at operating system startup
|
|
|
|
|
|
|
|
#### Option 1: Service
|
2023-04-18 12:56:23 +02:00
|
|
|
|
2023-04-18 14:11:54 +02:00
|
|
|
Create a file in `/etc/systemd/system/dynamic-folders-video-optimizer.service` with the following content.
|
|
|
|
|
|
|
|
|
2023-04-18 12:38:12 +02:00
|
|
|
```ini
|
|
|
|
[Unit]
|
2023-04-18 15:27:40 +02:00
|
|
|
Description=Folder that watches when new videos are added and optimizes them.
|
2023-04-18 12:38:12 +02:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Restart=always
|
|
|
|
RestartSec=5
|
2023-04-18 12:56:23 +02:00
|
|
|
User=[user]
|
2023-04-18 14:11:54 +02:00
|
|
|
ExecStart=dynamic-folders-video-optimizer --folder [folder to watch]
|
2023-04-18 12:38:12 +02:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
```
|
|
|
|
|
2023-04-18 14:11:54 +02:00
|
|
|
Edit it to your needs.
|
|
|
|
|
|
|
|
Recharge services.
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
sudo systemctl daemon-reload
|
|
|
|
```
|
|
|
|
|
|
|
|
And activate it.
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
sudo systemctl enable dynamic-folders-video-optimizer
|
|
|
|
sudo systemctl start dynamic-folders-video-optimizer
|
|
|
|
```
|
|
|
|
|
2023-04-18 16:43:18 +02:00
|
|
|
#### Option 2: Cron
|
2023-04-18 14:11:54 +02:00
|
|
|
|
|
|
|
Open.
|
|
|
|
|
|
|
|
``` sh
|
|
|
|
crontab -e
|
|
|
|
```
|
|
|
|
|
|
|
|
Add to document.
|
|
|
|
|
|
|
|
``` sh
|
2023-04-18 16:44:17 +02:00
|
|
|
@reboot dynamic-folders-video-optimizer --folder [folder to watch] >/dev/null 2>&1 &
|
2023-04-18 14:11:54 +02:00
|
|
|
```
|
|
|
|
|
2023-04-04 09:13:39 +02:00
|
|
|
## Development
|
|
|
|
|
|
|
|
### Check syntax
|
|
|
|
|
|
|
|
```sh
|
|
|
|
shellcheck [script]
|
|
|
|
```
|