E:\UnusualSoftwares\qshell-v2.3.4>qshell.exe Qiniu commandline tool for managing your bucket and CDN
Usage: qshell [command]
Available Commands: account Get/Set AccessKey and SecretKey alilistbucket List all the file in the bucket of aliyun oss by prefix b64decode Base64 Decode, default nor url safe b64encode Base64 Encode, default not url safe batchchgm Batch change the mime type of files in bucket batchchtype Batch change the file type of files in bucket batchcopy Batch copy files from bucket to bucket batchdelete Batch delete files in bucket batchexpire Batch set the deleteAfterDays of the files in bucket batchfetch Batch fetch remoteUrls and save them in qiniu Bucket batchmove Batch move files from bucket to bucket batchrename Batch rename files in the bucket batchsign Batch create the private url from the public url list file batchstat Batch stat files in bucket buckets Get all buckets of the account cdnprefetch Batch prefetch the urls in the url list file cdnrefresh Batch refresh the cdn cache by the url list file chgm Change the mime type of a file chtype Change the file type of a file completion generate autocompletion script for bash copy Make a copy of a file and save in bucket d2ts Create a timestamp in seconds using seconds to now delete Delete a remote file in the bucket dircache Cache the directory structure of a file path domains Get all domains of the bucket expire Set the deleteAfterDays of a file fetch Fetch a remote resource by url and save in bucket fput Form upload a local file get Download a single file from bucket help Help about any command ip Query the ip information listbucket List all the files in the bucket listbucket2 List all the files in the bucket using v2/list interface m3u8delete Delete m3u8 playlist and the slices it references m3u8replace Replace m3u8 domain in the playlist mirrorupdate Fetch and update the file in bucket using mirror storage move Move/Rename a file and save in bucket pfop issue a request to process file in bucket prefop Query the pfop status privateurl Create private resource access url qdownload Batch download files from the qiniu bucket qetag Calculate the hash of local file using the algorithm of qiniu qetag qupload Batch upload files to the qiniu bucket qupload2 Batch upload files to the qiniu bucket reqid Decode qiniu reqid rpcdecode rpcdecode of qiniu rpcencode rpcencode of qiniu rput Resumable upload a local file saveas Create a resource access url with fop and saveas stat Get the basic info of a remote file sync Sync big file to qiniu bucket tms2d Convert timestamp in milliseconds to a date (TZ: Local) tns2d Convert timestamp in Nanoseconds to a date (TZ: Local) ts2d Convert timestamp in seconds to a date (TZ: Local) unzip Unzip the archive file created by the qiniu mkzip API urldecode Url Decode urlencode Url Encode user Manage users version show version
Flags: -C, --config string config file (default is $HOME/.qshell.json) -d, --debug debug mode -h, --help help for qshell -L, --local use current directory as config file path -v, --version show version
Use "qshell [command] --help" for more information about a command.
defdeal_with_file(file_in, file_out): with open(file_in, 'r') as fin: with open(file_out, 'w+') ad fout: for line in fin: line = line.split('\t') fout.write(line[0] + '\n')
deffind_image_file(md_file): # 这个函数主要是将markdown中对应的url中的img移动到对应的目录下 img_patten = r'!\[.*?\]\((.*?)\)|<img.*?src=[\'\"](.*?)[\'\"].*?>' if os.path.splitext(md_file)[1] != '.md': print('{}不是Markdown文件,不做处理。'.format(md_file)) return cnt_replace = 0 with open(md_file, 'r', encoding='utf-8') as f: post = f.read() matches = re.compile(img_patten).findall(post) if matches and len(matches) > 0: for match in list(chain(*matches)): if match and len(match) > 0: match_l = match.split('/') sub_dir_name = match_l[-2] file_name = match_l[-1] url_base = match_l[-3] if url_base == 'p6um59a45.bkt.clouddn.com': full_path = os.path.join('E:\\UnusualSoftwares\\qshell-v2.3.4\\blog_images', sub_dir_name, file_name) dir_path = 'F:\\blog\\blog_imgs\\computerVersion\\' output_name = os.path.join(dir_path, file_name) ifnot os.path.exists(output_name): ifnot os.path.exists(full_path): print('path {} not exists'.format(full_path)) else: shutil.move(full_path, dir_path) cnt_replace = cnt_replace + 1 print('move {}'.format(full_path)) else: print('{} is not in qiniuyun'.format(match)) if post and cnt_replace > 0: print('{} done'.format(os.path.basename(md_file))) elif cnt_replace == 0: print('{}中没有需要替换的URL'.format(os.path.basename(md_file)))
defrepalce_url(md_file): # 这个函数真正替换markdown中的url img_patten = r'!\[.*?\]\((.*?)\)|<img.*?src=[\'\"](.*?)[\'\"].*?>' if os.path.splitext(md_file)[1] != '.md': print('{}不是Markdown文件,不做处理。'.format(md_file)) return cnt_replace = 0 dir_ts = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime()) with open(md_file, 'r', encoding='utf-8') as f: post = f.read() matches = re.compile(img_patten).findall(post) if matches and len(matches) > 0: for match in list(chain(*matches)): if match and len(match) > 0:
if post and cnt_replace > 0: open(md_file, 'w', encoding='utf-8').write(post) print('done') elif cnt_replace == 0: print('{}中没有需要替换的URL'.format(os.path.basename(md_file)))