Skip to content

Commit

Permalink
[#20] better help info output (pager)
Browse files Browse the repository at this point in the history
  • Loading branch information
sk1418 committed Dec 1, 2015
1 parent 5b0517f commit ba71671
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 36 deletions.
60 changes: 45 additions & 15 deletions zhuaxia/i18n/msg_cn.py
Expand Up @@ -72,45 +72,75 @@

experimental = u'-p 选项为实验性选项. 自动获取代理服务器池解析/下载。因代理服务器稳定性未知,下载可能会慢或不稳定。'
ver_text = u'zhuaxia (抓虾) '
help_info = u""" %(cyan)s
zhuaxia (抓虾) -- 抓取[虾米音乐]和[网易云音乐]的 mp3 音乐%(clear)s
help_info = u"""
zhuaxia (抓虾) -- 抓取[虾米音乐]和[网易云音乐]的 mp3 音乐
[%(uline)sCONFIG FILE:%(clear)s] $HOME/.zhuaxia/zhuaxia.conf
[CONFIG FILE:] $HOME/.zhuaxia/zhuaxia.conf
缺省配置文件会在第一次运行zhuaxia时自动生成
[%(uline)sOPTIONS%(clear)s]
%(bold)s-H%(clear)s : 首选HQ质量(320kbps),
[OPTIONS]
-H : 首选HQ质量(320kbps),
> 虾米音乐 <
- 配置文件中需给出正确登录信箱和密码, 登录用户需拥有VIP身份
- 用户需在xiami vip设置页面设置默认高音质
- 此选项对不满足上两项情况无效,仍下载128kbps资源
> 网易音乐 <
-无需特殊要求,直接下载高音质资源
%(bold)s-p%(clear)s : (实验性选项)使用代理池下载
在下载/解析量大的情况下,目标服务器会对禁止频繁的请求,所以zhuaxia可以自动获取
代理来解析和下载资源。因为获取的代理速度/可靠性不一,下载可能会缓慢或不稳定。
%(bold)s-h%(clear)s :显示帮助
%(bold)s-l%(clear)s :下载歌曲的lrc格式歌词
%(bold)s-f%(clear)s :从文件下载
%(bold)s-v%(clear)s :显示版本信息
-h : 显示帮助
[%(uline)sUSAGE%(clear)s]
-l : 下载歌曲的lrc格式歌词
%(bold)szx [OPTION] <URL>%(clear)s
-f : 从文件下载
-i : 增量下载. zhuaxia依靠历史记录来判定一首歌是否曾被下载
曾经被下载过的歌曲将被略过. 判断一首歌曲是否被下载过靠3个属性:
song_id(虾米或网易的歌曲id), source (虾米/网易), quality (H/L)
-e : 导出当前下载历史记录到文件
如果这个选项被使用, 其它选项将被忽略
-d : 清空当前下载历史记录
如果这个选项被使用, 其它选项将被忽略.
-e 和-d 选项不能同时使用
-v : 显示版本信息
-p : (实验性选项)使用代理池下载
在下载/解析量大的情况下,目标服务器会对禁止频繁的请求,所以zhuaxia可以自动获取 代理来解析和下载资源。因为获取的代理速度/可靠性不一,下载可能会缓慢或不稳定。
[USAGE]
zx [OPTION] <URL>
: 下载指定URL资源, 抓虾自动识别链接, 支持
- [虾] 歌曲,专辑,精选集,用户收藏,艺人TopN
- [易] 歌曲,专辑,歌单,艺人TopN
例子:
zx "http://www.xiami.com/space/lib-song/u/25531126"
zx "http://music.163.com/song?id=27552647"
%(bold)szx [OPTION] -f <file>%(clear)s
zx [OPTION] -f <file>
: 多个URL在一个文件中,每个URL一行。 URLs可以是混合[虾]和[易]的不同类型音乐资源。例子:
>$ cat /tmp/foo.txt
http://music.163.com/artist?id=5345
http://www.xiami.com/song/1772130322
http://music.163.com/album?id=2635059
http://www.xiami.com/album/32449
>$ zx -f /tmp/foo.txt
Other Examples:
下载歌曲和歌词:
zx -l "http://music.163.com/song?id=27552647"
增量下载, 并下载歌词
zx -li "http://music.163.com/song?id=27552647"
导出下载历史记录. 文件会被保存在配置文件设置的"download.dir"目录中
zx -e
清空所有下载历史记录
zx -d
"""
74 changes: 54 additions & 20 deletions zhuaxia/i18n/msg_en.py
Expand Up @@ -71,48 +71,82 @@

experimental = u'-p is an experimental option. Auto fetching proxy from proxy pool. Downloading could be slow or unstable due to the unknown proxy status.'
ver_text = u'zhuaxia '
help_info = u""" %(cyan)s
zhuaxia -- download mp3 music from [xiami.com] and [music.163.com]%(clear)s
help_info = u"""
zhuaxia -- download mp3 music from [xiami.com] and [music.163.com]
[%(uline)sCONFIG FILE:%(clear)s] $HOME/.zhuaxia/zhuaxia.conf
[CONFIG FILE:] $HOME/.zhuaxia/zhuaxia.conf
It will be automatically created when zhuaxia was started first time.
[%(uline)sOPTIONS%(clear)s]
%(bold)s-H%(clear)s : prefer High Quality(320kbps),
[OPTIONS]
-H : prefer High Quality(320kbps),
> xiami <
- xiami vip user email/password should be set in config
- user should set HQ on xiami vip setting page
- if any above requirements was not satisfied, 128kbps will be taken
> 163 <
- no special requirement
%(bold)s-p%(clear)s : auto choose proxy from proxy pool (experimental option)
when frequency of request to target host is high enough, host could ban the client
for some time. zhuaxia will auto take proxy from pool. However this may make
downloading slow or unstable.
-h : show this help
%(bold)s-h%(clear)s :show help
%(bold)s-l%(clear)s :download lyric (lrc format)
%(bold)s-f%(clear)s :download from url file
%(bold)s-v%(clear)s :show version information
-l : download lyric too (lrc format)
[%(uline)sUSAGE%(clear)s]
-f : download from url file (see example in [USAGE])
%(bold)szx [OPTION] <URL>%(clear)s
: auto recognize and download the given url resource, supports:
-i : incremental downloading
zhuaxia will check download history and skip the mp3 if it has been downloaded before.
To identify a downloaded mp3, the combination of these three attributes will be checked:
song_id(id in xiami/netease), source (xiami/netease), quality (H/L)
-e : export history data to file, if this option was given, other options will be ignored.
-d : clear all history data, if this option was given, other options will be ignored.
-e and -d cannot be used together.
-v : show version information
-p : auto choose proxy from proxy pool (experimental option)
when frequency of request to target host is high enough, host could ban the client
for some time. zhuaxia will auto take proxy from pool. However this may make
downloading slow or unstable.
[USAGE]
zx [OPTION] <URL>
auto recognize and download the given url resource, supports:
- [xm] song, album, favorite, collection, artist TopN
- [163]song, album, list, artist topN
example:
Example:
zx "http://www.xiami.com/space/lib-song/u/25531126"
zx "http://music.163.com/song?id = 27552647"
zx "http://music.163.com/song?id=27552647"
%(bold)szx [OPTION] -f <file>%(clear)s
: download from url file. one url per line. The urls could be 163 and xm mixed. Example:
zx [OPTION] -f <file>
download from url file. one url per line. The urls could be 163 and xm mixed. Example:
Example:
$ cat /tmp/foo.txt
http://music.163.com/artist?id=5345
http://www.xiami.com/song/1772130322
http://music.163.com/album?id=2635059
http://www.xiami.com/album/32449
$ zx -f /tmp/foo.txt
Other Examples:
download lyrics with songs:
zx -l "http://music.163.com/song?id=27552647"
incremental download songs with lyrics:
zx -li "http://music.163.com/song?id=27552647"
export zhuaxia download history. File will be save under "download.dir" in config file:
zx -e
clear(delete) all zhuaxia download history:
zx -d
"""

4 changes: 3 additions & 1 deletion zx
Expand Up @@ -31,7 +31,9 @@ help_info = msg.help_info

def usage():
"""print usage information"""
print help_info % log.STYLE
import pydoc
pydoc.pager(help_info)
sys.exit(0)

def version():
"""print version"""
Expand Down

0 comments on commit ba71671

Please sign in to comment.