/QMLQuadWarp
README.mdにあるみたいに長方形を変形できる.例では画像('Image')エレメントを利用しているが,`Item`から派生したコンポーネントであれば画像でなくてもソースとして利用できるはず.多分.
機会があればこれでプロジェクションマッピングしたい.
#!/usr/bin/env python3 | |
"""nicovideo.py: parse json and show video info""" | |
__author__ = "Yuto Tokunaga" | |
import sys | |
import os | |
import glob | |
import json | |
def print_usage(): | |
usage = "usage: nicovideo.py [option] [file/directory]\n" +\ | |
"\n" +\ | |
" options list: list files\n" +\ | |
" show: show file desctiption\n" +\ | |
"\n" | |
print(usage) | |
def list_files(dirname): | |
files = glob.glob(dirname + '/*.json') | |
for f in files: | |
jsonfile = open(f) | |
jsondata = json.load(jsonfile) | |
print("{0}: {1}".format(f.split('/')[-1].rstrip('.json'), jsondata['videoTitle'])) | |
print("\t{0}".format(jsondata['thumbDescription'])) | |
jsonfile.close() | |
def show_file(file): | |
filename = "" | |
if os.path.exists(file): | |
if file.split('.')[-1] != 'json': | |
print("file is not JSON file") | |
return | |
filename = file | |
elif os.path.exists(file + '.json'): | |
filename = file + '.json' | |
else: | |
print("file not exists!") | |
return | |
jsonfile = open(filename) | |
jsondata = json.load(jsonfile) | |
print("{0}: {1}".format(filename.split('/')[-1].rstrip('.json'), jsondata['videoTitle'])) | |
print("\t{0}".format(jsondata['description'])) | |
print("") | |
"""parse tag""" | |
tagstr = jsondata['tagList'].strip('/') | |
tagdatas = json.loads(tagstr) | |
taglist = [] | |
for tag in tagdatas: | |
taglist.append(tag['tag']) | |
print(taglist) | |
if __name__ == '__main__': | |
if len(sys.argv) < 2: | |
print_usage() | |
elif sys.argv[1] == 'list': | |
if len(sys.argv) < 3: | |
list_files('.') | |
else: | |
list_files(sys.argv[2]) | |
elif sys.argv[1] == 'show': | |
if len(sys.argv) < 3: | |
print("invalid format!") | |
else: | |
show_file(sys.argv[2]) | |
else: | |
print("invalid format!") |