Skip to content

Commit

Permalink
Update 2019-1-9
Browse files Browse the repository at this point in the history
附加功能脚本:
* 修复 autoupload.sh 在某些情况下文件上传位置不正确的 bug
* 修复 delete.sh 在某些情况下不删除文件的 bug
* 其他优化调整
  • Loading branch information
P3TERX committed Jan 9, 2019
1 parent ebbe4de commit bbdd196
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
### [相关教程](https://p3terx.com/tag/aria2/)

## 更新日志
### 2019-1-9
附加功能脚本:
* 修复 `autoupload.sh` 在某些情况下文件上传位置不正确的 bug
* 修复 `delete.sh` 在某些情况下不删除文件的 bug
* 其他优化调整

### 2018-12-25
配置文件:
* 调整 下载暂停时运行`info.sh`,默认不启用
Expand Down
30 changes: 13 additions & 17 deletions autoupload.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/bin/bash
#Description: Aria2 download completes calling Rclone upload
#Version: 1.1
#Version: 1.2
#Author: P3TERX
#Blog: https://p3terx.com

downloadpath='/root/Download' #Aria2下载目录
name='Onedrive' #配置Rclone时填写的name
folder='/DRIVEX/Download' #网盘里的文件夹,留空为整个网盘。
MinSize='10k' #限制最低上传大小,默认10k,BT下载时可防止上传其他无用文件。会删除文件,谨慎设置
MaxSize='15G' #限制最高文件大小,默认15GOneDrive上传限制。
MinSize='10k' #限制最低上传大小,仅BT下载时有效,用于过滤无用文件。默认10k,低于此大小的文件不会被上传,并删除文件
MaxSize='15G' #限制最高上传大小。默认15GOneDrive上传限制),超过此大小的文件不会被上传,文件会被保留

#=================下面不需要修改===================
filepath=$3 #Aria2传递给脚本的原始路径,如果是单文件为/root/Download/1.mp4,如果是文件夹则该值为文件夹内第一个文件,如/root/Download/a/b/1.mp4
filepath=$3 #Aria2传递给脚本的文件路径。BT下载有多个文件时该值为文件夹内第一个文件,如/root/Download/a/b/1.mp4
rdp=${filepath#${downloadpath}/} #路径转换,去掉开头的下载路径。
path=${downloadpath}/${rdp%%/*} #下载文件夹时为顶层文件夹路径。下载单个文件时为文件路径
path=${downloadpath}/${rdp%%/*} #路径转换,下载文件夹时为顶层文件夹路径。普通单文件下载时与文件路径相同

echo
echo -e " \033[1;33m前方高能!!!上传脚本开始执行!!!\033[0m"
Expand All @@ -23,26 +23,22 @@ echo
echo -e " \033[1;35m前方高能!!!上传脚本开始执行!!!\033[0m"
echo

if [ $2 -eq 0 ]
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ] #普通单文件下载
then
rclone move -v "$filepath" ${name}:${folder} --max-size $MaxSize #移动文件到设定的网盘文件夹
rm -vf "$filepath".aria2 #删除.aria.2文件(在下载目录中)
exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ] #如果下载的是单个文件
elif [ "$path" != "$filepath" ] && [ -e "$filepath".aria2 ] #子文件夹或多级目录等情况下的单文件下载
then
rclone move -v "$filepath" ${name}:${folder} --min-size $MinSize --max-size $MaxSize #移动文件到设定的网盘文件夹
rm -vf "$filepath".aria2 #删除残留的.aria.2文件(.aria2 文件在下载目录)
exit 0
elif [ "$path" != "$filepath" ] && [ -e "$filepath".aria2 ] #如果下载的是文件夹,且 .aria2 文件在文件夹中。
then
rclone move -v "$filepath" ${name}:"${folder}"/"${rdp%%/*}" --min-size $MinSize --max-size $MaxSize #移动文件到设定的网盘文件夹下的同名文件夹
rm -vf "$filepath".aria2 #删除残留的.aria2文件(.aria2 文件在文件夹中)
rclone delete -v "$path" --max-size $MinSize #删除多余的文件
rclone move -v "$filepath" ${name}:"${folder}"/"${rdp%/*}" --max-size $MaxSize #移动文件到设定的网盘文件夹下的相同路径文件夹
rm -vf "$filepath".aria2 #删除.aria2文件(在文件夹中)
rclone rmdirs -v "$downloadpath" --leave-root #删除空目录
exit 0
elif [ "$path" != "$filepath" ] && [ -e "$path".aria2 ] #如果下载的是文件夹,且 .aria2 文件在下载目录中。(BT下载)
elif [ "$path" != "$filepath" ] && [ -e "$path".aria2 ] #文件夹下载(BT下载)
then
rclone move -v "$path" ${name}:"${folder}"/"${rdp%%/*}" --min-size $MinSize --max-size $MaxSize #移动整个文件夹到设定的网盘文件夹
rclone delete -v "$path" --max-size $MinSize #删除多余的文件
rclone rmdirs -v "$downloadpath" --leave-root #删除空目录
rm -vf "$path".aria2 #删除残留的.aria2文件(.aria2 文件在下载目录中
rm -vf "$path".aria2 #删除.aria2文件(在下载目录中
exit 0
fi
8 changes: 3 additions & 5 deletions delete.aria2.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
#!/bin/bash
#Description: Delete .aria2 file after Aria2 download is complete
#Version: 1.0
#Version: 1.1
#Author: P3TERX
#Blog: https://p3terx.com

downloadpath='/root/Download' #Aria2下载目录

filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
then
exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
rm -vf "$filepath".aria2
exit 0
Expand Down
13 changes: 6 additions & 7 deletions delete.sh
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
#!/bin/bash
#Description: Delete files after Aria2 download error
#Version: 1.0
#Version: 1.1
#Author: P3TERX
#Blog: https://p3terx.com

downloadpath='/root/Download' #Aria2下载目录

filepath=$3
rdp=${filepath#${downloadpath}/}
path=${downloadpath}/${rdp%%/*}

if [ $2 -eq 0 ]
then
exit 0
elif [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
if [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
rm -vf "$filepath".aria2
rm -vrf "$filepath"
rm -vf "$filepath"
exit 0
elif [ "$path" != "$filepath" ] && [ -e "$filepath".aria2 ]
then
rm -vf "$filepath".aria2
rmdir "$path"
rm -vf "$filepath"
rmdir -v "${filepath%/*}"
exit 0
elif [ "$path" != "$filepath" ] && [ -e "$path".aria2 ]
then
Expand Down
13 changes: 7 additions & 6 deletions info.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#Description: Display Aria2 download information when paused
#Version: 1.1
#Version: 1.2
#Author: P3TERX
#Blog: https://p3terx.com

Expand All @@ -12,12 +12,15 @@ path=${downloadpath}/${rdp%%/*}

if [ "$path" = "$filepath" ] && [ $2 -eq 1 ]
then
uploadpath=$filepath
aria2file="$filepath".aria2
elif [ "$path" != "$filepath" ] && [ -e "$filepath".aria2 ]
then
uploadpath=$filepath
aria2file="$filepath".aria2
elif [ "$path" != "$filepath" ] && [ -e "$path".aria2 ]
then
uploadpath=$path
aria2file="$path".aria2
fi

Expand All @@ -28,19 +31,17 @@ echo -e "-------------------------- [\033[1;33m信息\033[0m] ------------------
echo -e "\033[1;35m文件数:\033[0m$2"
echo -e "\033[1;35m下载路径:\033[0m${downloadpath}"
echo -e "\033[1;35m文件路径:\033[0m${filepath}"
echo -e "\033[1;35m文件或文件夹路径:\033[0m${path}"
echo -e "\033[1;35m文件或文件夹名称:\033[0m${rdp%%/*}"
echo -e "\033[1;35m上传路径:\033[0m${uploadpath}"
echo -e "\033[1;35m.aria2 文件路径:\033[0m${aria2file}"
echo -e "-------------------------- [\033[1;33m信息\033[0m] --------------------------"
echo
echo
echo -e "[\033[1;32mPAUSE\033[0m] Download task information:"
echo -e "-------------------------- [\033[1;33mINFO\033[0m] --------------------------"
echo -e "\033[1;35mNumber of files: \033[0m$2"
echo -e "\033[1;35mownload path:\033[0m${downloadpath}"
echo -e "\033[1;35mDownload path:\033[0m${downloadpath}"
echo -e "\033[1;35mFile path: \033[0m${filepath}"
echo -e "\033[1;35mFile or folder path: \033[0m${path}"
echo -e "\033[1;35mFile or folder name: \033[0m${rdp%%/*}"
echo -e "\033[1;35mUpload path: \033[0m${uploadpath}"
echo -e "\033[1;35m.aria2 file path: \033[0m${aria2file}"
echo -e "-------------------------- [\033[1;33mINFO\033[0m] --------------------------"
echo
Expand Down

0 comments on commit bbdd196

Please sign in to comment.