Compare commits
No commits in common. "0b5d56ed94ae4d0008ceb02dbf35911477985c37" and "a09fcaaa863d9c91a78829aad9eb986938c5641c" have entirely different histories.
0b5d56ed94
...
a09fcaaa86
7 changed files with 7 additions and 46 deletions
|
|
@ -30,7 +30,7 @@ if __name__ == '__main__':
|
||||||
edit = api.getEdit(id=i['id'])['data']
|
edit = api.getEdit(id=i['id'])['data']
|
||||||
if edit['status'] == 'private':
|
if edit['status'] == 'private':
|
||||||
continue
|
continue
|
||||||
path = i['id'].replace(':', '\uf022').replace('/', '_').replace('|', '_') + '.json'
|
path = i['id'].replace(':', '_').replace('/', '_') + '.json'
|
||||||
path = ox.decode_html(path)
|
path = ox.decode_html(path)
|
||||||
path = os.path.join(target, path)
|
path = os.path.join(target, path)
|
||||||
ox.makedirs(os.path.dirname(path))
|
ox.makedirs(os.path.dirname(path))
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,9 @@ def get_extension(api, oshash):
|
||||||
r = api.findMedia({'query': {
|
r = api.findMedia({'query': {
|
||||||
'conditions': [{'key': 'oshash', 'value': oshash}]
|
'conditions': [{'key': 'oshash', 'value': oshash}]
|
||||||
}, 'keys': ['extension']})['data']
|
}, 'keys': ['extension']})['data']
|
||||||
return r['items'][0]['extension'].lower()
|
return r['items'][0]['extension']
|
||||||
|
|
||||||
|
|
||||||
COLON = '\uf022'
|
|
||||||
COLON = ':'
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
target = sys.argv[1]
|
target = sys.argv[1]
|
||||||
|
|
@ -31,7 +28,7 @@ if __name__ == '__main__':
|
||||||
api = ox.api.signin('https://%s/api/' % site)
|
api = ox.api.signin('https://%s/api/' % site)
|
||||||
|
|
||||||
keep = []
|
keep = []
|
||||||
r = api.find({'range': [0, 10000], 'keys': ['id']})
|
r = api.find({'range': [0, 1000], 'keys': ['id']})
|
||||||
for i in r['data']['items']:
|
for i in r['data']['items']:
|
||||||
item = api.get(id=i['id'], keys=['id', 'streams', 'title', 'director', 'year', 'instances'])['data']
|
item = api.get(id=i['id'], keys=['id', 'streams', 'title', 'director', 'year', 'instances'])['data']
|
||||||
director = item.get('director', ['Unknown Director'])
|
director = item.get('director', ['Unknown Director'])
|
||||||
|
|
@ -41,10 +38,7 @@ if __name__ == '__main__':
|
||||||
path = ox.decode_html(path)
|
path = ox.decode_html(path)
|
||||||
prefix = ox.decode_html(item['title'])
|
prefix = ox.decode_html(item['title'])
|
||||||
|
|
||||||
path = path.replace(':', COLON)
|
keep.append(unicodedata.normalize('NFD', os.path.join(target, path, 'annotations.json')))
|
||||||
prefix = prefix.replace(':', COLON)
|
|
||||||
|
|
||||||
keep.append(unicodedata.normalize('NFD', os.path.join(target, path, 'annotations.json')).lower())
|
|
||||||
|
|
||||||
parts = []
|
parts = []
|
||||||
if len(item['streams']) == 1:
|
if len(item['streams']) == 1:
|
||||||
|
|
@ -52,7 +46,6 @@ if __name__ == '__main__':
|
||||||
ext = get_extension(api, id)
|
ext = get_extension(api, id)
|
||||||
name = '%s.%s' % (item['title'], ext)
|
name = '%s.%s' % (item['title'], ext)
|
||||||
name = ox.decode_html(name)
|
name = ox.decode_html(name)
|
||||||
name = name.replace(':', COLON)
|
|
||||||
part = 1
|
part = 1
|
||||||
parts.append([os.path.join(path, name), item['id'], id, part])
|
parts.append([os.path.join(path, name), item['id'], id, part])
|
||||||
else:
|
else:
|
||||||
|
|
@ -61,14 +54,12 @@ if __name__ == '__main__':
|
||||||
ext = get_extension(api, id)
|
ext = get_extension(api, id)
|
||||||
name = '%s.Part %d.%s' % (prefix, part, ext)
|
name = '%s.Part %d.%s' % (prefix, part, ext)
|
||||||
name = ox.decode_html(name)
|
name = ox.decode_html(name)
|
||||||
name = name.replace(':', COLON)
|
|
||||||
parts.append([os.path.join(path, name), item['id'], id, part])
|
parts.append([os.path.join(path, name), item['id'], id, part])
|
||||||
part += 1
|
part += 1
|
||||||
|
|
||||||
for path, id, oshash, part in parts:
|
for path, id, oshash, part in parts:
|
||||||
abspath = os.path.join(target, path)
|
abspath = os.path.join(target, path)
|
||||||
if os.path.exists(abspath) and ox.oshash(abspath) != oshash:
|
if os.path.exists(abspath) and ox.oshash(abspath) != oshash:
|
||||||
print('file changed', abspath[len(target):])
|
|
||||||
os.unlink(abspath)
|
os.unlink(abspath)
|
||||||
if not os.path.exists(abspath):
|
if not os.path.exists(abspath):
|
||||||
url = 'https://%s/%s/download/source/%s' % (site, id, part)
|
url = 'https://%s/%s/download/source/%s' % (site, id, part)
|
||||||
|
|
@ -77,11 +68,11 @@ if __name__ == '__main__':
|
||||||
api.save_url(url, abspath)
|
api.save_url(url, abspath)
|
||||||
except:
|
except:
|
||||||
print('failed to download', url)
|
print('failed to download', url)
|
||||||
keep.append(unicodedata.normalize('NFD', abspath).lower())
|
keep.append(unicodedata.normalize('NFD', abspath))
|
||||||
|
|
||||||
for root, folders, files in os.walk(target):
|
for root, folders, files in os.walk(target):
|
||||||
for f in files:
|
for f in files:
|
||||||
path = os.path.join(root, f)
|
path = os.path.join(root, f)
|
||||||
if unicodedata.normalize('NFD', path).lower() not in keep:
|
if unicodedata.normalize('NFD', path) not in keep:
|
||||||
print('deleting', path)
|
print('deleting', path)
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
|
|
|
||||||
|
|
@ -264,8 +264,6 @@
|
||||||
"soup": {},
|
"soup": {},
|
||||||
"tea": {}
|
"tea": {}
|
||||||
},
|
},
|
||||||
"tech": {
|
|
||||||
},
|
|
||||||
"miscellaneous": {
|
"miscellaneous": {
|
||||||
"bicycle": {},
|
"bicycle": {},
|
||||||
"make-up": {},
|
"make-up": {},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
<meta charset="utf-8" />
|
|
||||||
<script src="/static/oxjs/min/Ox.js"></script>
|
<script src="/static/oxjs/min/Ox.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function pandora_api(action, data, callback) {
|
function pandora_api(action, data, callback) {
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,3 @@ body {
|
||||||
stroke: #ccc;
|
stroke: #ccc;
|
||||||
stroke-width: 1.5px;
|
stroke-width: 1.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.zoom {
|
|
||||||
position: fixed;
|
|
||||||
top: 5px;
|
|
||||||
right: 5px;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,6 @@
|
||||||
<title>Ontology Tree</title>
|
<title>Ontology Tree</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="zoom">
|
|
||||||
<button class="plus">+</button>
|
|
||||||
<button class="minus">-</button>
|
|
||||||
</div>
|
|
||||||
<script src="index.js"></script>
|
<script src="index.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -51,22 +51,6 @@ function resize() {
|
||||||
update(root);
|
update(root);
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoom(size) {
|
|
||||||
height = size;
|
|
||||||
tree.size([height, width]);
|
|
||||||
svg.attr("width", width).attr("height", height + margin.top + margin.bottom)
|
|
||||||
document.querySelector('svg').attributes.height.value = height + margin.top + margin.bottom
|
|
||||||
resize()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
document.querySelector('.zoom button.plus').addEventListener('click', function(event) {
|
|
||||||
zoom(height*1.5)
|
|
||||||
})
|
|
||||||
document.querySelector('.zoom button.minus').addEventListener('click', function(event) {
|
|
||||||
zoom(height/1.5)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
function get_color(d) {
|
function get_color(d) {
|
||||||
if (d.children || d._children) {
|
if (d.children || d._children) {
|
||||||
|
|
@ -111,8 +95,7 @@ function update(source) {
|
||||||
})
|
})
|
||||||
.text(function(d) {
|
.text(function(d) {
|
||||||
if (d.children || d._children) {
|
if (d.children || d._children) {
|
||||||
//return d.name;
|
return d.name;
|
||||||
return d.name + '(' + (d.children || d._children).length +')';
|
|
||||||
}
|
}
|
||||||
return d.name + ' (' + d.size + ')';
|
return d.name + ' (' + d.size + ')';
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue