md
This commit is contained in:
54
backup
54
backup
@ -1,38 +1,18 @@
|
||||
#!/bin/bash
|
||||
tempDir=/tmp/backup
|
||||
mountRemote() {
|
||||
rclone mount schulev: "$tempDir" --daemon
|
||||
}
|
||||
umountRemote() {
|
||||
umount "$tempDir"
|
||||
}
|
||||
case $1 in
|
||||
restore)
|
||||
mountRemote
|
||||
find "$tempDir" -type f | xargs -n 1 tar -xf
|
||||
umountRemote
|
||||
;;
|
||||
backup)
|
||||
mountRemote
|
||||
declare -A hashes
|
||||
while IFS= read -r file; do
|
||||
hash="$(echo -n "$file" | openssl dgst -binary -sha256 | openssl base64 | sed -e 's/\//@/g')"
|
||||
hashes[s]=0
|
||||
file_hash="$tempDir/$hash"
|
||||
hashes[$hash]=0
|
||||
if [[ ! -f "$file_hash" || $(tar -df "$file_hash") ]]; then
|
||||
tar -cf "$file_hash" "$file"
|
||||
fi
|
||||
done < <(find -type f,l; find -type d -empty)
|
||||
cd "$tempDir"
|
||||
for file in *; do
|
||||
if [ ! -v hashes[$file] ]; then
|
||||
rm "$file"
|
||||
fi
|
||||
done
|
||||
umountRemote
|
||||
;;
|
||||
*)
|
||||
echo "use backup or restore as argument"
|
||||
;;
|
||||
esac
|
||||
cd /media/hdd1/data
|
||||
if [[ -d .snapshots/rclone ]]; then
|
||||
echo "last backup not finnished" > /dev/stderr
|
||||
exit 1
|
||||
fi
|
||||
getfacl -R * > mrgeorgen/backup/perms
|
||||
SNAPSHOT="/media/hdd1/data-snapshots/rclone"
|
||||
btrfs su sn /media/hdd1/data "$SNAPSHOT"
|
||||
cd "$SNAPSHOT"
|
||||
rclone sync -l --retries 10 --tpslimit 10 --user-agent "ISV|rclone|rclone/v1.42" . schulev: --exclude "/mrgeorgen/Medien/**" --exclude "/.snapshots/**" --exclude /.snapshots/ --exclude "/mrgeorgen/backup/natur/**" --exclude /mrgeorgen/backup/natur/ --exclude "/mrgeorgen/.cache/minecraft-mod-packager/**" |&
|
||||
grep -v "Can't transfer non file/directory" | (
|
||||
err=`cat`
|
||||
if [[ $(echo "$err" |grep "ERROR : Attempt 10/10 failed with") ]]; then
|
||||
echo "$err" > /dev/stderr
|
||||
fi
|
||||
)
|
||||
btrfs su de "$SNAPSHOT"
|
||||
|
||||
@ -1,4 +1,8 @@
|
||||
#!/bin/sh
|
||||
adb forward tcp:4747 tcp:4747
|
||||
droidcam-cli 127.0.0.1 4747
|
||||
echo $! > ~/.pid/droidcam.pid
|
||||
while true; do
|
||||
droidcam-cli 127.0.0.1 4747 &
|
||||
sleep 240
|
||||
kill $!
|
||||
sleep 3
|
||||
done
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
#!/bin/sh
|
||||
pid=`cat ~/.pid/droidcam.pid`
|
||||
kill -2 $pid
|
||||
kill $pid
|
||||
rm ~/.pid/droidcam.pid
|
||||
|
||||
108
md
108
md
@ -1,50 +1,112 @@
|
||||
#!/bin/sh
|
||||
ending() {
|
||||
echo "$1" |awk -F . '{print $NF}'
|
||||
}
|
||||
|
||||
checkMetadata() {
|
||||
ffprobe "$1" 2>&1 | grep -ie artist -e title
|
||||
while true; do
|
||||
printf "correct metadata? [Y] | [n]: "
|
||||
read -r yn < /dev/tty
|
||||
case "$yn" in
|
||||
[Yy]* ) return 0;;
|
||||
[Nn]* ) return 1;;
|
||||
* ) echo "Please answer yes or no.";;
|
||||
* ) return 0;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
download_dir="$(mktemp -d)"
|
||||
temp_dir="$(mktemp -d)"
|
||||
for song in "$@"; do
|
||||
file_name="$(youtube-dl "ytsearch:$song lyrics" \
|
||||
downloadSong() {
|
||||
filepath="$(youtube-dl "ytsearch:$1 lyrics" \
|
||||
-f bestaudio/best \
|
||||
--output "$download_dir/%(title)s.%(ext)s" \
|
||||
--metadata-from-title "%(artist)s - %(title)s" \
|
||||
--add-metadata \
|
||||
|awk '$1 == "[download]" && $2 == "Destination:" {print substr($0, index($0,$3))}')"
|
||||
case "$(echo "$file_name" | awk -F . '{print $NF}')" in
|
||||
"webm")
|
||||
new_filename="${file_name%.*}".opus
|
||||
mkvextract tracks "$file_name" "0:$new_filename" > /dev/null
|
||||
file_name="$new_filename"
|
||||
case "$filepath" in
|
||||
*.webm)
|
||||
new_filename="${filepath%.*}".opus
|
||||
ffmpeg -i "$filepath" -codec copy "$new_filename" 2> /dev/null
|
||||
filepath="$new_filename"
|
||||
;;
|
||||
"m4a")
|
||||
*.m4a)
|
||||
;;
|
||||
*)
|
||||
echo "unsupported file type"
|
||||
echo "unsupported file type" > /dev/stderr
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
r128gain "$file_name" 2> /dev/null
|
||||
temp_file="$temp_dir/$(basename "$file_name")"
|
||||
cp "$file_name" "$temp_file"
|
||||
idntag "$temp_file"
|
||||
temp_file=$(echo "$temp_dir"/*)
|
||||
if checkMetadata "$temp_file"; then
|
||||
mv "$temp_file" .
|
||||
elif checkMetadata "$file_name"; then
|
||||
mv "$file_name" .
|
||||
else
|
||||
echo "enter it manually"
|
||||
r128gain "$filepath" 2> /dev/null
|
||||
echo "$filepath"
|
||||
}
|
||||
|
||||
changeMetadata() {
|
||||
filepath="$1"
|
||||
artist="$2"
|
||||
title="$3"
|
||||
dir="$4"
|
||||
case "$filepath" in
|
||||
*.opus)
|
||||
metadata_track=":s:a:0"
|
||||
title_tag="TITLE"
|
||||
artist_tag="ARTIST"
|
||||
;;
|
||||
*.m4a)
|
||||
title_tag="title"
|
||||
artist_tag="artist"
|
||||
;;
|
||||
esac
|
||||
metadata="-metadata$metadata_track"
|
||||
output_path="$dir/$artist-$title.$(ending "$filepath")"
|
||||
ffmpeg -i "$filepath" -codec copy "$metadata" "$title_tag=$title" "$metadata" \
|
||||
"$artist_tag=$artist" "$output_path" 2> /dev/null
|
||||
echo "$output_path"
|
||||
}
|
||||
|
||||
while getopts "a:t:mp" c; do
|
||||
case $c in
|
||||
a) artist="$OPTARG";;
|
||||
t) title="$OPTARG";;
|
||||
m)
|
||||
dir="$MUSIC_DIR/$(date +%Y)"
|
||||
mkdir -p "$dir"
|
||||
;;
|
||||
p) print_path=0;;
|
||||
*) echo "invalid flag" > /dev/stderr;;
|
||||
esac
|
||||
done
|
||||
shift $(("$OPTIND" - 1))
|
||||
if [ ! "$dir" ]; then
|
||||
dir="$(pwd)"
|
||||
fi
|
||||
if [ "$artist" ] && [ "$title" ]; then
|
||||
echo 1
|
||||
filepath="$(downloadSong "$artist" "$title")"
|
||||
output_path="$(changeMetadata "$filepath" "$artist" "$title" "$dir")"
|
||||
if [ "$print_path" ]; then
|
||||
echo "$output_path"
|
||||
fi
|
||||
else
|
||||
for song in "$@"; do
|
||||
filepath="$(downloadSong "$song")"
|
||||
filename="$(basename "$filepath")"
|
||||
if checkMetadata "$filepath"; then
|
||||
mv "$filepath" "$dir"
|
||||
if [ "$print_path" ]; then
|
||||
echo "$dir/$filename"
|
||||
fi
|
||||
done
|
||||
else
|
||||
printf "artist: "
|
||||
read -r artist
|
||||
printf "title: "
|
||||
read -r title
|
||||
output_path="$(changeMetadata "$filepath" "$artist" "$title" "$dir")"
|
||||
if [ "$print_path" ]; then
|
||||
echo "$output_path"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
rm -rf "$temp_dir" "$download_dir"
|
||||
mpc update > /dev/null
|
||||
|
||||
@ -2,3 +2,4 @@
|
||||
file=~/Bilder/screenshots/$(date +%m_%d_%y_%T).png
|
||||
import -window root "$file"
|
||||
xclip -sel clip -t image/png "$file"
|
||||
echo "$file"
|
||||
|
||||
Reference in New Issue
Block a user