2022-03-02 18:02:15 +01:00
|
|
|
# /bin/bash
|
|
|
|
|
|
|
|
## Check install des dep.
|
|
|
|
hash mediainfo 2>/dev/null || {
|
|
|
|
echo >&2 "MediaInfo n'est pas installé. Installez-le avant de relancer ce script."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
hash transmission-create 2>/dev/null || {
|
|
|
|
echo >&2 "transmission-create n'est pas installé. Installez-le avant de relancer ce script."
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
|
|
|
# Init Var
|
|
|
|
TORRENT="false"
|
|
|
|
SERIE="false"
|
|
|
|
HELP="false"
|
|
|
|
TENCODE="false"
|
|
|
|
PUBLIC="false"
|
|
|
|
|
2022-03-02 21:52:00 +01:00
|
|
|
|
2022-03-02 18:02:15 +01:00
|
|
|
usage() {
|
|
|
|
echo "Usage: torrent [ -A | --source-Audio ] [ -V | --source-Video ] [ -S | --source-Sub ]
|
|
|
|
[ -t | --torrent ] [ -s | --serie ] [ -e | --team-encode ]
|
|
|
|
[ -h | --help ]"
|
|
|
|
exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
ARGS=$(getopt -a -n "torrent" -o tsheoV:A:S: --long torrent,serie,help,team-encode,public-torrent,Video:,Audio:,Sub: -- "$@")
|
|
|
|
eval set -- "$ARGS"
|
|
|
|
VALID_ARGS=$?
|
|
|
|
if [ "$VALID_ARGS" != "0" ]; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-t | --torrent)
|
|
|
|
TORRENT="true"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-s | --serie)
|
|
|
|
SERIE="true"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-h | --help)
|
|
|
|
HELP="true"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-e | --team-encode)
|
|
|
|
TENCODE="true"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-o | --public-torrent)
|
|
|
|
PUBLIC="true"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
-V | --Video)
|
|
|
|
SOURCE_VIDEO="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-A | --Audio)
|
|
|
|
SOURCE_AUDIO="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
-S | --Sub)
|
|
|
|
SOURCE_SUB="$2"
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown option %s\n" "$1"
|
|
|
|
usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ $HELP == true ]; then
|
|
|
|
echo "---------------------------------------
|
|
|
|
Prérequis :
|
|
|
|
|
|
|
|
Installer les dépendances : transmission-create et mediainfo
|
|
|
|
|
|
|
|
sudo apt install transmission-cli
|
|
|
|
|
|
|
|
sudo apt install mediainfo
|
|
|
|
|
|
|
|
- Se rendre dans le dossier du script
|
|
|
|
- chmod u+x torrent.sh
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
Option disponible :
|
|
|
|
|
|
|
|
-t = Pour créer un torrent en même temps que le NFO
|
|
|
|
-e = Pour préciser que la release a été encodé par vous
|
|
|
|
-A = Source des Audio
|
|
|
|
-V = Source Video
|
|
|
|
-S = Source des Sous-Titres
|
|
|
|
-s = A utiliser si votre release est une série !
|
|
|
|
|
|
|
|
Important : Pour une série, un seul .torrent et un seul NFO sera crée pour le dossier.
|
|
|
|
|
|
|
|
----------------------------------------------------------------
|
|
|
|
|
|
|
|
Utilisation :
|
|
|
|
|
|
|
|
Pour faire le .torrent et le NFO d'un film :
|
|
|
|
|
|
|
|
./torrent.sh -t -e -A Ma.Release.Audio -V Ma.Release.Video -S Ma.Release.Sous_Titres /chemin/absolu/vers/la/release
|
|
|
|
|
|
|
|
Pour faire le .torrent et le NFO d'une série :
|
|
|
|
|
|
|
|
./torrent.sh -t -e -A Ma.Source.Audio -V Ma.Source.Video -S Ma.Source.Sous_Titres -s /chemin/absolu/vers/le/dossier/de/la/release
|
|
|
|
"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "N'oubliez pas de mettre le fichier vidéo ou dossier en argument.\nExemple : ./torrent.sh Gattaca.1997.Multi.Bluray.1080p.x265-KFL.mkv"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
if [ "$2" != "" ]; then
|
|
|
|
echo "Mettez le fichier vidéo ou dossier entre guillemets.\nExemple : ./torrent.sh \"[Gattaca.1997.Multi.Bluray.1080p.x265-KFL.mkv\""
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# S_SUB=$SOURCE_SUB
|
|
|
|
# S_AUDIO=$SOURCE_AUDIO
|
|
|
|
# S_VIDEO=$SOURCE_VIDEO
|
|
|
|
|
2022-03-02 21:52:00 +01:00
|
|
|
PASSKEY="VOTRE_PASSKEY"
|
|
|
|
|
|
|
|
|
2022-03-02 18:02:15 +01:00
|
|
|
fs=$SOURCE_SUB
|
|
|
|
S_SUB=$(echo $fs | sed -E 's/[^a-zA-Z0-9_.)(]/./gm;t;d')
|
|
|
|
echo $S_SUB
|
|
|
|
|
|
|
|
fa=$SOURCE_AUDIO
|
|
|
|
fa2=$(echo $fa | sed -E 's/[^a-zA-Z0-9_./-/)(]/./gm;t;d')
|
|
|
|
S_AUDIO=$(echo $fa2) #| sed -E 's/ //gm;t;d')
|
|
|
|
echo $S_AUDIO
|
|
|
|
|
|
|
|
fv=$SOURCE_VIDEO
|
|
|
|
S_VIDEO=$(echo $fv | sed -E 's/[^a-zA-Z0-9_.)(]/./gm;t;d')
|
|
|
|
echo $S_VIDEO
|
|
|
|
|
|
|
|
script_path=$(pwd)
|
|
|
|
i="${1}"
|
|
|
|
|
|
|
|
if [[ -f "${i}" ]]; then
|
|
|
|
if [ $TORRENT == true ]; then
|
2022-03-02 21:52:00 +01:00
|
|
|
tracker="$PASSKEY"
|
2022-03-02 18:02:15 +01:00
|
|
|
tkpr="$tracker"
|
|
|
|
transmission-create -o "${i%.*}.torrent" -p -t $tkpr -c "Upload par KFL" --include ".*\.\(mpg\|avi\|3g2\|3gp\|asf\|avi\|f4v\|flv\|m2t\|m2ts\|m2v\|m4v\|mjpeg\|mkv\|mov\|mp4\|mpeg\|mts\|mxf\|ogv\|rm\|vob\|webm\|wmv\|m4a\|m4b\|aif\|aac\|ac3\|aiff\|flac\|mp3\|wma\)" "${i}"
|
|
|
|
fi
|
|
|
|
if [ $PUBLIC == true ]; then
|
|
|
|
tkpub=$(curl https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt | sed '/^[ \t\r\n]*$/d' | tail -n5 | tr '\n' ' ')
|
|
|
|
publist="$tkpub"
|
|
|
|
transmission-create -o "${i%.*}.PUBLIC.torrent" -t $publist $ -c "Upload par KFL" --include ".*\.\(mpg\|avi\|3g2\|3gp\|asf\|avi\|f4v\|flv\|m2t\|m2ts\|m2v\|m4v\|mjpeg\|mkv\|mov\|mp4\|mpeg\|mts\|mxf\|ogv\|rm\|vob\|webm\|wmv\|m4a\|m4b\|aif\|aac\|ac3\|aiff\|flac\|mp3\|wma\)" "${i}"
|
|
|
|
fi
|
|
|
|
nfo=$(mediainfo --Inform="file://$script_path/KFL_template.txt" "$i")
|
|
|
|
new_nfo=$(echo "$nfo" | sed '/^$/d')
|
|
|
|
if [ $TENCODE == true ]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Encodage..............: KFL avec Handbrake Linux"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_SUB" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Sous-Titres....: '$S_SUB' "}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_AUDIO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Audio..........: '$S_AUDIO'"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_VIDEO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Video..........: '${S_VIDEO}'"}1'); fi
|
|
|
|
echo "$new_nfo" >"${i%.*}.nfo"
|
|
|
|
|
|
|
|
elif [[ -d "${i}" ]]; then
|
|
|
|
dirpath=$(dirname $i)/$(basename $i)
|
|
|
|
if [ $SERIE == false ]; then
|
|
|
|
for f in $(find $dirpath -name "*.mkv" -or -name "*.mp4" -or -name "*.avi" -type f); do
|
|
|
|
if [ $TORRENT == true ]; then
|
2022-03-02 21:52:00 +01:00
|
|
|
tracker="$PASSKEY"
|
2022-03-02 18:02:15 +01:00
|
|
|
tkpr="$tracker"
|
|
|
|
transmission-create -o "${f%.*}.torrent" -p -t $tkpr -c "Upload par KFL" --include ".*\.\(mpg\|avi\|3g2\|3gp\|asf\|avi\|f4v\|flv\|m2t\|m2ts\|m2v\|m4v\|mjpeg\|mkv\|mov\|mp4\|mpeg\|mts\|mxf\|ogv\|rm\|vob\|webm\|wmv\|m4a\|m4b\|aif\|aac\|ac3\|aiff\|flac\|mp3\|wma\)" "${f}"
|
|
|
|
fi
|
|
|
|
if [ $PUBLIC == true ]; then
|
|
|
|
tkpub=$(curl https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt | sed '/^[ \t\r\n]*$/d' | tail -n5 | tr '\n' ' ')
|
|
|
|
publist="$tkpub"
|
|
|
|
transmission-create -o "${f%.*}.PUBLIC.torrent" -a $publist $ -c "Upload par KFL" --include ".*\.\(mpg\|avi\|3g2\|3gp\|asf\|avi\|f4v\|flv\|m2t\|m2ts\|m2v\|m4v\|mjpeg\|mkv\|mov\|mp4\|mpeg\|mts\|mxf\|ogv\|rm\|vob\|webm\|wmv\|m4a\|m4b\|aif\|aac\|ac3\|aiff\|flac\|mp3\|wma\)" "${f}"
|
|
|
|
fi
|
|
|
|
nfo=$(mediainfo --Inform="file://$script_path/KFL_template.txt" "$f")
|
|
|
|
new_nfo=$(echo "$nfo" | sed '/^$/d')
|
|
|
|
if [ $TENCODE == true ]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Encodage..............: KFL avec Handbrake Linux"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_SUB" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Sous-Titres....: '$S_SUB'"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_AUDIO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Audio..........: '$S_AUDIO'"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_VIDEO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Video..........: '$S_VIDEO'"}1'); fi
|
|
|
|
echo "$new_nfo" >"${f%.*}.nfo"
|
|
|
|
done
|
|
|
|
elif [ $SERIE == true ]; then
|
|
|
|
f=$(find $dirpath -name "*.mkv" -or -name "*.mp4" -or -name "*.avi" -type f | sed -n "1p")
|
|
|
|
cnt=$(find $dirpath -name "*.mkv" -or -name "*.mp4" -or -name "*.avi" -type f | wc -l)
|
|
|
|
if [ $TORRENT == true ]; then
|
2022-03-02 21:52:00 +01:00
|
|
|
tracker="$PASSKEY"
|
2022-03-02 18:02:15 +01:00
|
|
|
tkpr="$tracker"
|
|
|
|
transmission-create -o "$dirpath/$(basename $i).torrent" -p -t $tkpr -c "Upload par KFL" --include ".*\.mkv" "$dirpath"
|
|
|
|
fi
|
|
|
|
if [ $PUBLIC == true ]; then
|
|
|
|
tkpub=$(curl https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt | sed '/^[ \t\r\n]*$/d' | tail -n5 | tr '\n' ' ')
|
|
|
|
publist="$tkpub"
|
|
|
|
transmission-create -o "$dirpath/$(basename $i).PUBLIC.torrent" -a $publist -c "Upload par KFL" --include ".*\.mkv" "$dirpath"
|
|
|
|
fi
|
|
|
|
nfo=$(mediainfo --Inform="file://$script_path/KFL_template.txt" "$f")
|
|
|
|
new_nfo=$(echo "$nfo" | sed '/^$/d')
|
|
|
|
new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Poids Total...........: "}1')
|
|
|
|
new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Nombre Episodes.......: '$(printf $cnt)'"}1')
|
|
|
|
if [ $TENCODE == true ]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Encodage..............: KFL avec Handbrake Linux\n"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_SUB" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Sous-Titres....: '$S_SUB'"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_AUDIO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Audio..........: '$S_AUDIO'"}1'); fi
|
|
|
|
if [[ ! -z "$SOURCE_VIDEO" ]]; then new_nfo=$(echo "$new_nfo" | awk 'NR==20{print "Source Video..........: '$S_VIDEO'"}1'); fi
|
|
|
|
echo "$new_nfo" >"$dirpath/$(basename $i).nfo"
|
|
|
|
mv "$dirpath/$(basename $i).nfo" "$dirpath/$(basename $i).torrent" ./
|
|
|
|
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "${i} is not valid"
|
|
|
|
exit 1
|
|
|
|
fi
|