Mega share
About
This script searches for video and image files, downsizes and uploads them to mega.nz. It will then check if the number of files is correct and if not, it will retry.
Dependencies
- bash
- gnu coreutils
- megatools: https://megatools.megous.com/
- ffmpeg
- imagemagick
Usage
- Change the username and password in the script
- Run the script in the folder you want to share. Use the gallery name as sole parameter
Problems
- password and username in plaintext in script
- not tested recently
Use at your own risk, no warranties.
#!/bin/bash
#http://megatools.megous.com/
if [ ! -z $1 ]; then
echo $1
suffix="m"
suffix2=$suffix
export suffix=$suffix2
create_date=`exiftool -d %Y_%m_ -p '$CreateDate' ./ 2>/dev/null |grep -v 0000 |sort |head -n1`
name=$create_date"$1"
name2=$name
export name=$name2
username='username'
password='passwort'
mkdir -p $name
find . -maxdepth 1 -iname '*.mov' -o -iname '*.mkv' -o -iname '*.mp4' -o -iname '.avi' |time parallel -j 1 --eta 'ffmpeg -threads 10 -i {} -codec:v libx264 -crf 23 -preset medium -codec:a copy -movflags faststart -vf scale=-1:720,format=yuv420p $name/{.}_$suffix.mp4'
#bilder:
find . -maxdepth 1 -iname '*.jpg' |time parallel -j+0 --eta 'convert {} -quality 85 -resize "2048x2048 >" $name/{.}_$suffix.jpg'
#upload:
megamkdir --ignore-config-file -u $username -p $password --reload /Root/$name
n_target=`megals --ignore-config-file -u $username -p $password -e /Root/$name |wc -l`
n_target=$(($n_target - 1))
n_source=`ls $name |wc -l`
while [ $n_target -lt $n_source ]
do
megacopy --ignore-config-file -u $username -p $password --local $name --remote /Root/$name
n_target=`megals --ignore-config-file -u $username -p $password -e /Root/$name |wc -l`
n_target=$(($n_target - 1))
echo "n target: " $n_target
n_source=`ls $name |wc -l`
echo "n source: " $n_source
done
megals --ignore-config-file -u $username -p $password -e /Root/$name
else echo "no name given"
fi