Skip to content

Instantly share code, notes, and snippets.

@Deathproof76
Deathproof76 / plex_busydb_checkv3_restart_and_ notify.sh
Last active October 4, 2023 14:02
"Sqlite3: Sleeping for 200ms to retry busy DB" - Plex BusyDB Check, Restart and Notify Script with Apprise Notifications (predefined Telegram) and statistics (currently testing)
#!/bin/bash
# Files and paths
timestamp_file="/tmp/plex_busy_db_timestamp"
log_file="/tmp/plex_events.log"
lock_file="/tmp/plex_script.lock"
restart_grace_file="/tmp/plex_restart_grace"
# Apprise URL for Telegram notifications
APPRIZE_URL="tgram://bot_token/A,B/"
@Deathproof76
Deathproof76 / plexbusycheckv2.sh
Created October 3, 2023 08:06
busy db cron checkv2 tbu
#!/bin/bash
# Timestamp file to keep track of last "busy db" message
timestamp_file="/tmp/plex_busy_db_timestamp"
# Function to check the health of the plex container
check_plex_health() {
# Get the last 10 lines of log output from the plex container
plex_logs=$(docker logs --tail 10 plex)
#!/bin/bash
set -x # Enable debug mode
# Function to check the health of the plex container
check_plex_health() {
# Directly print the logs to the terminal for debugging
docker logs --tail 10 plex
# Get the last 10 lines of log output from the container named plex
plex_logs=$(docker logs --tail 10 plex)
@Deathproof76
Deathproof76 / i_frame_check.py
Last active August 25, 2023 12:13
Check video files with ffprobe if there is only one i-frame in the first 20 seconds of the file
import os
import subprocess
import time
import sys
import select
def rename_defective_file(filepath):
"""Rename the defective file by appending '_(i_frame_defect)' before the file extension."""
root, ext = os.path.splitext(filepath)
new_name = f"{root}_(i_frame_defect){ext}"
@Deathproof76
Deathproof76 / check_videos.py
Last active August 25, 2023 11:53
Find all defective video files (mp4/mkv/avi) with ffprobe in directory and subfoldes with "moov atom not found" in error_output or "Invalid data found when processing input" and print full path to txt file
import os
import subprocess
import time
import sys
import select
# Detailed introductory message
print("DESCRIPTION:")
print("------------")
print("This script will recursively search the current directory and its subdirectories for video files with extensions .mp4, .mkv, and .avi.")
@Deathproof76
Deathproof76 / plexdb_healthcheck.sh
Last active October 10, 2024 04:52
Crontab restart/repair script for Plex "Sqlite3: Sleeping for 200ms to retry busy DB"
#!/bin/bash
# Plex busy DB workaround
# Set the maximum number of allowed occurrences of the Sqlite3: Sleeping for 200ms to retry busy DB string
# about 3 times usually indicates an instance that can't recover by itself
# if your instance restarts your docker logs should reset, or "cover up" the busy DB lines, afaik
MAX_OCCURRENCES=3
# this part "docker logs --tail 10 plex" "--tail 10" means the last ten lines of the container logs
# of the container named "plex", change the name according to your setup
@Deathproof76
Deathproof76 / start.sh
Created June 23, 2023 17:45
Script for Tdarr docker start with ffmpeg6 install
docker compose pull
docker compose up -d
docker exec -it tdarr bash -c "wget https://repo.jellyfin.org/releases/server/ubuntu/versions/jellyfin-ffmpeg/6.0-1/jellyfin-ffmpeg6_6.0-1-focal_amd64.deb && \
apt install -y ./jellyfin-ffmpeg6_6.0-1-focal_amd64.deb && \
rm -rf ./jellyfin-ffmpeg6_6.0-1-focal_amd64.deb && \
ln -sf /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/local/bin/ffmpeg && \
ln -sf /usr/lib/jellyfin-ffmpeg/ffmpeg /usr/local/bin/tdarr-ffmpeg"
@Deathproof76
Deathproof76 / printer.cfg
Last active June 21, 2024 13:16
Tina2S Klipper config
# This file contains pin mappings and other defaults for the Weefun/Weedo
# Tina2s based on the GD32F103. It won't work with the ATMega-bsed
# Tina/Tina wifi/monoprice cadet.
# The biggest issue with this printer is that the USB-serial CH340G's DTR pin
# is tied to reset with a 1k resistor - not a capacitor circuit like most.
# restart_method of 'tina2s' was added to make sure DTR is held high during
# normal operation
# Pins were found in https://github.com/weedo3d/TINA2Sfirmware and confirmed
@Deathproof76
Deathproof76 / ffmpeglibvpl.sh
Last active December 26, 2022 16:34
Cartwheel FFmpeg Quick Sync (qsv) Onevpl enabled
# Cartwheel FFmpeg
mkdir ~/git && cd ~/git
git clone https://github.com/intel-media-ci/cartwheel-ffmpeg --recursive
cd cartwheel-ffmpeg
git submodule update --init --recursive
cd ffmpeg
git am ../patches/*.patch
PKG_CONFIG_PATH=/opt/intel/mediasdk/lib/pkgconfig ./configure \
--prefix=/home/yourname/.local \ ####change to preferred install path
--extra-cflags="-I/opt/intel/mediasdk/include" \ ###location may depend on your env
@Deathproof76
Deathproof76 / ffmpegqsvvpl.sh
Last active January 18, 2023 21:51
Compiles FFmpeg with Cartwheel Patches, Quick Sync and OneVpl support. Careful needs testing, currently Work in Process. Read comments.
#!/bin/bash
# based on: https://gist.github.com/feedsbrain/0191516b5625b577c2b14241cff4fe30#!/bin/bash
#
# update environment
sudo apt update
sudo apt dist-upgrade
# install dependencies for compiling
sudo apt install -y cmake make autoconf automake libtool g++ bison \