forked from P3TERX/aria2.conf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 修复 BT下载多级目录时上传不完整的bug * 修复 BT下载多级目录时导致的其它bug
- Loading branch information
P3TERX
committed
Dec 10, 2018
1 parent
3e3fcdb
commit b1998a6
Showing
5 changed files
with
53 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
#!/bin/bash | ||
filepath=$3 #取文件原始路径,如果是单文件则为/Download/a.mp4,如果是文件夹则该值为文件夹内第一个文件比如/Download/a/1.mp4 | ||
path=${3%/*} #取文件根路径,如把/Download/a/1.mp4变成/Download/a | ||
downloadpath='/root/Download' #Aria2下载目录 | ||
name='Onedrive' #配置Rclone时的name | ||
folder='/DRIVEX/Download' #网盘里的文件夹,留空为整个网盘。 | ||
MinSize='10k' #限制最低上传大小,默认10k,BT下载时可防止上传其他无用文件。会删除文件,谨慎设置。 | ||
MaxSize='15G' #限制最高文件大小,默认15G,OneDrive上传限制。 | ||
downloadpath='/root/Download' #Aria2下载目录 | ||
name='Onedrive' #配置Rclone时填写的name | ||
folder='/DRIVEX/Download' #网盘里的文件夹,留空为整个网盘。 | ||
MinSize='10k' #限制最低上传大小,默认10k,BT下载时可防止上传其他无用文件。会删除文件,谨慎设置。 | ||
MaxSize='15G' #限制最高文件大小,默认15G,OneDrive上传限制。 | ||
|
||
filepath=$3 #Aria2传递给脚本的原始路径,如果是单文件则为/root/Download/1.mp4,如果是文件夹则该值为文件夹内第一个文件比如/root/Download/a/b/1.mp4 | ||
rdp=${filepath#${downloadpath}/} #路径转换,去掉开头的下载路径。 | ||
path=${downloadpath}/${rdp%%/*} #文件或文件夹路径。如果是单个文件,应与原始路径一致。 | ||
|
||
if [ $2 -eq 0 ] | ||
then | ||
exit 0 | ||
fi | ||
|
||
while true; do | ||
if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ] #如果下载的是单个文件 | ||
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ] #如果下载的是单个文件 | ||
then | ||
rclone move -v "$filepath" ${name}:${folder} --min-size $MinSize --max-size $MaxSize | ||
rm -vf "$filepath".aria2 #删除残留的.aria.2文件 | ||
rm -vf "$filepath".aria2 #删除残留的.aria.2文件 | ||
exit 0 | ||
elif [ "$path" != "$downloadpath" ] #如果下载的是文件夹 | ||
elif [ "$path" != "$filepath" ] #如果下载的是文件夹 | ||
then | ||
while [[ "`ls -A "$path/"`" != "" ]]; do | ||
rclone move -v "$path" ${name}:/${folder}/"${path##*/}" --min-size $MinSize --max-size $MaxSize --delete-empty-src-dirs | ||
rclone delete -v "$path" --max-size $MinSize #删除多余的文件 | ||
rclone rmdirs -v "$downloadpath" --leave-root #删除空目录,--delete-empty-src-dirs参数已实现,加上无所谓。 | ||
rclone move -v "$path" ${name}:"${folder}"/"${rdp%%/*}" --min-size $MinSize --max-size $MaxSize --delete-empty-src-dirs | ||
rclone delete -v "$path" --max-size $MinSize #删除多余的文件 | ||
rclone rmdirs -v "$downloadpath" --leave-root #删除空目录,--delete-empty-src-dirs参数已实现,加上无所谓。 | ||
done | ||
rm -vf "$path".aria2 #删除残留的.aria2文件 | ||
rm -vf "$path".aria2 #删除残留的.aria2文件 | ||
exit 0 | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
downloadpath='/root/Download' #Aria2下载目录 | ||
filepath=$3 | ||
path=${3%/*} | ||
downloadpath='/root/Download' #Aria2下载目录 | ||
rdp=${filepath#${downloadpath}/} | ||
path=${downloadpath}/${rdp%%/*} | ||
|
||
echo "Aria2 变量显示测试: [$1] [$2] [$3]" | ||
echo -------------------------- 测试 -------------------------- | ||
echo 下载路径:${downloadpath} | ||
echo 文件路径:${filepath} | ||
echo 文件根路径:${path} | ||
echo 最终路径:"${path##*/}" | ||
echo 文件或文件夹路径:${path} | ||
echo 文件或文件夹名称:${rdp%%/*} | ||
echo .aria2 文件:${rdp%%/*}.aria2 | ||
echo -------------------------- 测试 -------------------------- | ||
|
||
echo "Aria2 variable display test: [$1] [$2] [$3]" | ||
echo -------------------------- TEST -------------------------- | ||
echo Download path:${downloadpath} | ||
echo File path: ${filepath} | ||
echo Path: ${path} | ||
echo Final path: "${path##*/}" | ||
echo File or folder path: ${path} | ||
echo File or folder name: ${rdp%%/*} | ||
echo .aria2 file: ${rdp%%/*}.aria2 | ||
echo -------------------------- TEST -------------------------- |