文章摘要:
本文描述了Linux下的几种下载小工具;


神器一: transmisstion

命令行工具安装:

# atp-get install transmisstion-cli

下载文件:

$ transmisstion-cli debian-8.6.0-i386-netinst.iso.torrent

支持本地torrent文件,远程(URL)种子文件,magnet(磁力链)格式;

参数说明:

-w: 选项指定下载文件保存的文件夹(默认为当前用户的下载目录);
-d: 指定下载限速(单位KB);
-u: 指定上传限速(单位KB);
-f: 设置当前下载完成后要运行的脚本;

transmission-cli 默认在文件下载完成后继续运行,可以使用以下的脚本完成下载完成后自动关闭。

#!/bin/sh
sleep 10
killall transmission-cli

安装网页版工具(推荐)

# apt-get install transmission-daemon

修改配置文件/etc/transmission-daemon/settings.json

"rpc-enabled": true,      
# 用户名
"rpc-username": "user",   
# 密码
"rpc-password": "123456",   
# 端口配置                               
"rpc-port": 9091,
"rpc-url": "/transmission/",

# 白名单(逗号分隔,支持通配符*)
"rpc-whitelist": "127.0.0.1, 192.168.9.*",
"rpc-whitelist-enabled": true,    

暂时修改这么多,其他的可以稍后用界面修改;

启动服务

# service transmission-daemon start

此时可以通过浏览器访问:http://127.0.0.1:9091 来管理;

特征码下载:

将擦键盘的40位数字前边加上磁力链前缀即为下载地址:

magnet:?xt=urn:btih:

如果数字为43位,则去掉前3前只保留40位即可;


桌面系统可安装transmisstion-gui,一般不需要;



神器二:mldonkey

安装

# apt-get install mldonkey-server

运行

$ mlnet &

至此可通过http://localhost:4080通过网页管理;


配置说明:
配置文件位于用户目录下的.mldonkey目录中;
download.ini

# 允许的IP列表
allowed_ips = [
  "127.0.0.1";
  "192.168.9.133";]

# 控制台网页端口,默认为4080
http_port = 4080

# 上传限速(单位KB)
max_hard_upload_rate = 10
# 下载限速(单位KB)
max_hard_download_rate = 50

# 在此修改下载文件目录
shared_directories = [
  {     dirname = shared
     strategy = all_files
     priority = 0
};
  {     dirname = "incoming/files"
     strategy = incoming_files
     priority = 0
};
  {     dirname = "incoming/directories"
     strategy = incoming_directories
     priority = 0
};]


另一神器:youtube-dl

千万不要被名子所迷惑,虽然叫这个名子,并不代表真的能下载他的视频,除非你能访问他的网站,原因当然是众所周知的;不过国内的各大知名网站一般都是这种格式,其中优酷,乐视,爱奇艺等网站测试正常;


工具地址:
https://github.com/chun912/youtube-dl.git

下载最新工具:

sudo wget https://yt-dl.org/latest/youtube-dl

下载方法:
首先打开播放页面,并复制url地址,比如说http://v.youku.com/v_show/id_XODY1NzIzMDY0.html;

查看支持的格式:

# youtube-dl -F http://v.youku.com/v_show/id_XODY1NzIzMDY0.html

format code  extension  resolution note
h4           flv        480x360    12.73MiB
h5           mp4        480x360    16.29MiB
h3           mp4        720x540    26.20MiB (best)

下载指定格式:

# youtube-dl -f h3 http://v.youku.com/v_show/id_XODY1NzIzMDY0.html

可以通过参数--proxy来指定代理服务器;


批量下载:
将需要下载页面的url写入文本文档(files.list),每个url一行;

新建脚本(down.sh)内容如下:

#!/bin/bash
cat $1 | while read line
do
    echo $line
    youtube-dl -f h3 $line
done

运行脚本:

$ ./down.sh files.list

网易云音乐下载:
在线播放链接:https://music.163.com/#/song?id=474567580
mp3下载链接:http://music.163.com/song/media/outer/url?id=474567580.mp3


you-get: 基于Python的一个下载软件

安装软件:

$ pip3 install you-get -i https://pypi.tuna.tsinghua.edu.cn/simple

查看视频格式列表:

$ you-get -i URL

下载列表中的所有内容:

$ you-get -l URL

-c 参数用于指定cookies信息,主要用于需要用户名和密码的VIP资源下载,可先用网页登陆账号,然后找出cookies.sqlite;
FireFox的cookies文件位于C:\Users\admin\AppData\Roaming\Mozilla\Firefox\Profiles的最后一个目录中;

$ awk '{print $1}' 米奇妙妙屋第一季.txt | xargs you-get -c ~/cookies.sqlite