Install

1
pip3 install quickstart-rhy [--upgrade]

Usage

Command Means
qs -u url open url using default browser
qs -a app [files] open app or open file by app(for MacOS X)
qs -f file open file by default app
qs -trans [words] translate the content of [words] or the content in clipboard
qs -time view current time
qs -http [ip:port] [-bind url] start a simple multithread http server, default ip=LAN:8000
qs -top cpu and memory monitor
qs -cal exp calculate exp
qs -rmbg picture remove image background
qs -stbg picture to [from] Replace color from from to to, default from is transparency
qs -smms picture/*.md upload images to sm.ms (or replace paths in markdown)
qs -alioss -help get aliyun oss api help menu
qs -txcos -help get tencent cos api help menu
qs -qiniu -help get qiniu oss api help menu
qs -weather [address] check weather (of address)
qs -LG image Use Baidu AIPimage to enlarge image
qs -dl [urls] download file from url(in clipboard) with smart strategy
qs -mktar path create gzipped archive for path(dir/file)
qs -untar path extract path.tar.*
qs -mkzip path make a zip for path(dir/file)
qs -unzip path unzip path.zip
qs -v2gif video [sz] [fps] generate gif form video
qs -v2mp4 video format video to mp4
qs -rmaudio video Remove audio in video (return mp4 only)
qs -upload upload your pypi library
qs -upgrade update qs

(By the way, if you are the one of China University Of Petroleum(Beijing), run qs -i to login school network)

Good News!

  • You can search the document of this project on the app uTools!

API

  • QuickStart-Rhy provide apis of some popular online platform, so you can do amazing things with qs!
  • You need to register with the appropriate website in person and fill in the required API keys to ensure that qs is properly invoked
  • Edit ~/.qsrc to set your API keys!

Support API

API Org Pypi Lib Key Value
remove bg link None “rmbg”
smms link None “smms”

Aliyun OSS

link

oss2
“aliyun_oss_acid”
“aliyun_oss_ackey”
“aliyun_oss_df_bucket”
“aliyun_oss_bucket_url”

Qiniu OSS

link

qiniu
“qiniu_ac_key”
“qiniu_sc_key”
“qiniu_bk_name”

Tencent COS

link

cos-python-sdk-v5
“txyun_scid”
“txyun_sckey”
“txyun_df_region”
“txyun_cos_df_bucket”
IPinfo link ipinfo “ipinfo”
Baidu Image
Process

link

aip
“AipImageAPP_ID”
“AipImageAPP_KEY”
“AipImageSECRET_KEY”
Tencent translate link tencentcloud-sdk-python “txyun_scid”
“txyun_sckey”
“txyun_df_region”
  • .qsrc example:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"rmbg": "rmbg_api_key",
"smms": "smms_api_key",
"aliyun_oss_acid": "aliyun_oss_acid",
"aliyun_oss_ackey": "aliyun_oss_ackey",
"aliyun_oss_bucket_url": "oss-cn-beijing.aliyuncs.com",
"aliyun_oss_df_bucket": "default bucket",
"txyun_scid": "txyun_cos_scid",
"txyun_sckey": "txyun_cos_sckey",
"txyun_df_region": "ap-region",
"txyun_cos_df_bucket": "default bucket",
"qiniu_ac_key": "qiniu_ac_key",
"qiniu_sc_key": "qiniu_sc_key",
"qiniu_bk_name": "default bucket"
}

API Usage

rmbg

Raw Processed

smms

  • upload image:
1
2
3
4
5
6
➜ Desktop $ qs -smms IMG_4758.jpeg  
+---------------+--------+---------------------------+
| File | Status | url |
+---------------+--------+---------------------------+
| IMG_4758.jpeg | True | https://*.loli.net/*t.jpg |
+---------------+--------+---------------------------+
  • Upload images in markdown file, and replace the images path to urls.
1
2
3
4
5
6
7
8
➜ Desktop $ qs -smms test.md  
+---------------+--------+---------------------------+
| File | Status | url |
+---------------+--------+---------------------------+
| 1.jpg | True | https://*.loli.net/1.jpg |
| 2.jpg | True | https://*.loli.net/2.jpg |
| 3.jpg | True | https://*.loli.net/3.jpg |
+---------------+--------+---------------------------+

Aliyun OSS

Command Function
qs -alioss -up file [bucket] upload file to bucket/default bucket
qs -alioss -rm file [bucket] remove file in bucket
qs -alioss -dl file [bucket] download file from bucket
qs -alioss -ls [bucket] get file info of bucket
Demo
1
2
3
4
5
6
7
8
Bucket Url: https://***.aliyuncs.com/
+--------------------------------+------------+
| File | Size |
+--------------------------------+------------+
| 单片机原理及应用教程第3版.pdf | 25.156 MB |
| 计算机网络(第7版)-谢希仁.pdf | 70.780 MB |
| 软件工程导论.pdf | 100.819 MB |
+--------------------------------+------------+

Qiniu OSS

Command Function
qs -qiniu -up file [bucket] upload file to bucket/default bucket
qs -qiniu -rm file [bucket] remove file in bucket
qs -qiniu -cp url [bucket] copy file from url to bucket
qs -qiniu -dl file [bucket] download file from bucket
qs -qiniu -ls [bucket] get file info of bucket
Demo
1
2
3
4
5
6
7
8
9
10
11
12
13
➜ hexo $ qs -qiniu -ls
Bucket url: http://***.bkt.clouddn.com/
+----------------------------+------------+
| File | Size |
+----------------------------+------------+
| 591918ca03491.jpg | 522.393 KB |
| BaiduExporter.zip | 64.810 KB |
| BitBar.zip | 6.361 MB |
| cover.png | 342.704 KB |
| ev-cover.png | 483.959 KB |
| google-access-helper-2.zip | 111.958 KB |
| weather.15m.py | 13.386 KB |
+----------------------------+------------+

Tencent COS

Command Function
qs -txcos -up file [bucket] upload file to bucket/default bucket
qs -txcos -rm file [bucket] remove file in bucket
qs -txcos -dl file [bucket] download file from bucket
qs -txcos -ls [bucket] get file info of bucket
Demo
1
2
3
4
5
6
7
8
9
10
11
12
13
➜ hexo $ qs -txcos -ls
Bucket url: http://***.myqcloud.com/
+----------------------------+------------+
| File | Size |
+----------------------------+------------+
| 1.jpg | 522.393 KB |
| BaiduExporter.zip | 64.810 KB |
| BitBar.zip | 6.361 MB |
| ev-cover.png | 483.959 KB |
| gd-cover.png | 342.704 KB |
| google-access-helper-2.zip | 111.958 KB |
| weather.15m.py | 13.386 KB |
+----------------------------+------------+

ipinfo

  • Just provide a function: QuickStart_Rhy.api.ipinfo(ip:str=None), and it will return a dict with the ip information.
Demo
1
2
3
>>> from QuickStart_Rhy.api import ipinfo
>>> ipinfo('114.114.114.114')
{'ip': '114.114.114.114', 'hostname': 'public1.114dns.com', 'city': 'Beijing', 'region': 'Beijing', 'country': 'CN', 'loc': '39.9075,116.3972', 'org': 'AS174 Cogent Communications', 'timezone': 'Asia/Shanghai', 'country_name': 'China', 'latitude': '39.9075', 'longitude': '116.3972'}

Tencent Translate

  • After going through several unstable calling methods, I decided to use Tencent Cloud Machine Translation Service as the translation engine of qs, so you need install some library and set your account information at ~/.qsrc by yourself if you want use translate service.
Demo
1
2
$ qs -trans Looking in indexes
查找索引

Tools for developers

Not content to just use qs on the command line? Qs now provides practical tools to help you develop Python applications faster!

ImageTools

  • ColorTools.py:

    • QuickStart_Rhy.ImageTools.ColorTools.get_color_from_str(str_color): get (R, G, B, A=255) from str_color

      Examples:

call return
get_color_from_str('0,0,0,0') (0, 0, 0, 0)
get_color_from_str('0,0,0') (0, 0, 0, 255)
get_color_from_str('FFFFFF') (255, 255, 255, 255)
  • QuickStart_Rhy.ImageTools.ColorTools.transport_back(src: str, to_color, from_color=(0, 0, 0, 0)): replace the from_color with to_color of the Image.open(src).

    Examples:

call return
transport_back('test.jpg', (0, 0, 0, 255)) Replace the transparent color with white

NetTools

  • QuickStart_Rhy.NetTools.check_one_page(url): Determines whether the url is accessible.

  • QuickStart_Rhy.NetTools.formatUrl(try_url): Try adding https:// or http:// to make the try_url accessible (There is no guarantee that the return value will be accessible)

  • QuickStart_Rhy.NetTools.get_ip(): Gets the IP of the current machine under the LAN

  • QuickStart_Rhy.NetTools.size_format(sz, align=False): Format size. 1000000 -> “1.000 MB” if not align else “ 1.000 MB”

  • QuickStart_Rhy.NetTools.get_ip_info(): return dict

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    {
    'status': 'success',
    'country': 'China',
    'countryCode': 'CN',
    'region': 'Province name abbreviations',
    'regionName': 'Province name',
    'city': 'City',
    'zip': '',
    'lat': latitude,
    'lon': longitude,
    'timezone': 'Asia/Shanghai',
    'isp': 'Network operator',
    'org': 'Network operator + location',
    'as': 'AS4134 Chinanet',
    'query': 'Your public IP'
    }
  • QuickStart_Rhy.NetTools.get_fileinfo(url): Return the downloadable links, file names, and requests.head return values.

ThreadTools

  • QuickStart_Rhy.ThreadTools.ThreadFunctionWrapper(threading.Thread): Opens a new thread to run the function.

    • __init__(self, function, *args, **kwargs)
    • run(self): Start run
    • get_res(self): Get function result
  • QuickStart_Rhy.ThreadTools.FileWriters: Write file thread pool

    • __init__(self, filename, workers, mode): mode example: r+, w, rb+, wb
    • wait(self): wait all thread done
    • new_job(self, content, index): new write job

    filename must have been created and pre-allocated enough space

TuiTools

  • QuickStart_Rhy.TuiTools.get_console_width(): just as its name implies
  • QuickStart_Rhy.TuiTools.Bar.RollBar: Support for scrolling bar charts on the command line, you can run qs -top to see the effect.
  • QuickStart_Rhy.TuiTools.Line.Line: Support for line charts on the command line, you can run qs -weather to see the effect.

Wrappers

  • QuickStart_Rhy.Wrapper.set_timeout(num): function wrapper to make the function to terminate at a specified time num.

    • Examples:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    from QuickStart_Rhy.Wrapper import set_timeout
    import time

    @set_timeout(2)
    def fuck(who):
    time.sleep(3)
    return 'fuck {}'.format(who)
    # run this function and it will return False

    @set_timeout(2)
    def fuck(who):
    return 'fuck {}'.format(who)
    # run this function and it will return 'fuck {}'.format(who)