Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
* 修复 BT下载多级目录时上传不完整的bug
* 修复 BT下载多级目录时导致的其它bug
  • Loading branch information
P3TERX committed Dec 10, 2018
1 parent 3e3fcdb commit b1998a6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,22 @@

`dht.dat` DHT(IPv4)文件

`dht6.dat` DHT(IPv6)文件
`dht6.dat` DHT(IPv6)文件,待添加

`test.sh` 测试脚本时 debug 用的,可能永远用不到了。
`test.sh` 测试脚本时 debug 用的,~~可能永远用不到了。~~

### [相关教程](https://p3terx.com/tag/aria2/)
### [相关教程](https://p3terx.com/tag/aria2/)

## 更新日志

### 2018-12-11
* 修复 BT下载多级目录时上传不完整的bug
* 修复 BT下载多级目录时导致的其它bug

### 2018-12-07
* 添加 DHT(IPv4)文件
* 调整配置文件
* 整合到 [Aria2 一键安装管理脚本](https://github.com/P3TERX/aria2.sh)

### 2018-11-10
* 首次提交
30 changes: 16 additions & 14 deletions autoupload.sh
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
9 changes: 5 additions & 4 deletions delete.aria2.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#!/bin/bash
downloadpath='/root/Download' #Aria2下载目录
filepath=$3
path=${3%/*}
downloadpath='/root/Download' #Aria2下载目录
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
then
exit 0
fi

if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ]
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
rm -vf "$filepath".aria2
exit 0
elif [ "$path" != "$downloadpath" ]
elif [ "$path" != "$filepath" ]
then
rm -vf "$path".aria2
exit 0
Expand Down
9 changes: 5 additions & 4 deletions delete.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
#!/bin/bash
downloadpath='/root/Download' #Aria2下载目录
filepath=$3
path=${3%/*}
downloadpath='/root/Download' #Aria2下载目录
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
then
exit 0
fi

if [ "$path" = "$downloadpath" ] && [ $2 -eq 1 ]
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
rm -vf "$filepath".aria2
rm -vrf "$filepath"
exit 0
elif [ "$path" != "$downloadpath" ]
elif [ "$path" != "$filepath" ]
then
rm -vf "$path".aria2
rm -vrf "$path"
Expand Down
17 changes: 10 additions & 7 deletions test.sh
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 --------------------------

0 comments on commit b1998a6

Please sign in to comment.