1

第041期 用命令行高速下载百度网盘文件!单线程24.8MB/S,跑满200兆宽带

 2 years ago
source link: https://www.126126.xyz/post/041/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

本期视频内容

百度云高速下载的方法不新鲜了,地球人都知道,但是有些设备只有命令行界面,不太方便使用下载工具,本期视频给大家带来一个Shell脚本,可以在这些设备上高速下载百度网盘文件。

#/bin/bash

url=$1
# url是直链地址,默认从第一个参数中获取
# 在命令行长度有限制的设备上(比如OpenWrt)
# 也可以直接把url设置成直链地址后运行脚本(不需要参数)
# 例如: url="http://allall02.baidupcs.com/file/......"

#fn=$(echo $url | grep -P 'fin=.*?&' -o)
fn=$(echo $url | sed 's/&/\n/g' | grep 'fin=')
fn=$(echo $fn | sed "s/fin=//g" | sed "s/&//g")
fn=$(printf $(echo -n "$fn" | sed 's/\\/\\\\/g;s/\(%\)\([0-9a-fA-F][0-9a-fA-F]\)/\\x\2/g')"\n")

agent="netdisk;7.0.3.2;PC;PC-Windows;10.0.17763"

if aria2c --help >/dev/null 2>&1; then
  aria2c --user-agent="$agent" -x 4 -s 4 -o "$fn" "$url"
else
  if curl --help >/dev/null 2>&1; then
    curl --user-agent "$agent" -o "$fn" "$url"
  else
    if wget --help >/dev/null 2>&1; then
      wget --user-agent "$agent" -O "$fn" "$url"
    else
      echo "需要安装以下软件之一: aria2c, curl, wget"
    fi
  fi
fi

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK