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