Compare commits
2 commits
842b28a2b0
...
b3d7768839
| Author | SHA1 | Date | |
|---|---|---|---|
| b3d7768839 | |||
| 9f56cff77b |
3 changed files with 175 additions and 3 deletions
40
backup_annotations.py
Executable file
40
backup_annotations.py
Executable file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import unicodedata
|
||||
|
||||
import ox
|
||||
import ox.api
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) > 1:
|
||||
target = sys.argv[1]
|
||||
else:
|
||||
target = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Films')
|
||||
|
||||
if not target.endswith('/'):
|
||||
target += '/'
|
||||
|
||||
site = 'pandora.cinemusespace.com'
|
||||
api = ox.api.signin('https://%s/api/' % site)
|
||||
|
||||
keep = []
|
||||
r = api.find({'range': [0, 1000], 'keys': ['id']})
|
||||
for i in r['data']['items']:
|
||||
item = api.get(id=i['id'], keys=[])['data']
|
||||
layers = api.get(id=i['id'], keys=['layers'])['data']
|
||||
item['layers'] = layers['layers']
|
||||
director = item.get('director', ['Unknown Director'])
|
||||
path = os.path.join('; '.join(director), '%s' % (item['title']))
|
||||
if 'year' in item:
|
||||
path += ' (%s)' % item['year']
|
||||
path = ox.decode_html(path)
|
||||
path = os.path.join(target, path)
|
||||
ox.makedirs(path)
|
||||
path = os.path.join(path, 'annotations.json')
|
||||
with open(path, 'w') as fd:
|
||||
json.dump(item, fd, ensure_ascii=False, indent=4, sort_keys=True)
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#!/usr/bin/python3
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
|
@ -16,7 +16,13 @@ def get_extension(api, oshash):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
target = sys.argv[1]
|
||||
if len(sys.argv) > 1:
|
||||
target = sys.argv[1]
|
||||
else:
|
||||
target = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'Films')
|
||||
|
||||
if not target.endswith('/'):
|
||||
target += '/'
|
||||
|
||||
site = 'pandora.cinemusespace.com'
|
||||
api = ox.api.signin('https://%s/api/' % site)
|
||||
|
|
@ -31,6 +37,9 @@ if __name__ == '__main__':
|
|||
path += ' (%s)' % item['year']
|
||||
path = ox.decode_html(path)
|
||||
prefix = ox.decode_html(item['title'])
|
||||
|
||||
keep.append(unicodedata.normalize('NFD', os.path.join(target, path, 'annotations.json')))
|
||||
|
||||
parts = []
|
||||
if len(item['streams']) == 1:
|
||||
id = item['streams'][0]
|
||||
|
|
@ -54,7 +63,7 @@ if __name__ == '__main__':
|
|||
os.unlink(abspath)
|
||||
if not os.path.exists(abspath):
|
||||
url = 'https://%s/%s/download/source/%s' % (site, id, part)
|
||||
print('downloading', abspath[len(target) + 1:])
|
||||
print('downloading', abspath[len(target):])
|
||||
api.save_url(url, abspath)
|
||||
keep.append(unicodedata.normalize('NFD', abspath))
|
||||
|
||||
|
|
|
|||
123
static/js/renameKeywordDialog.cms.js
Normal file
123
static/js/renameKeywordDialog.cms.js
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
|
||||
pandora.ui.renameKeywordDialog = function() {
|
||||
|
||||
var dialogHeight = 100,
|
||||
dialogWidth = 512 + 16,
|
||||
formWidth = getFormWidth(),
|
||||
|
||||
$button,
|
||||
$content = Ox.Element(),
|
||||
old,
|
||||
value,
|
||||
$input = [
|
||||
Ox.Input({
|
||||
label: Ox._('From'),
|
||||
labelWidth: 96,
|
||||
width: 512
|
||||
}).css({
|
||||
margin: '8px'
|
||||
}).bindEvent({
|
||||
change: function(data) {
|
||||
$button.options({disabled: !data.value && !value});
|
||||
old = data.value;
|
||||
}
|
||||
}).appendTo($content),
|
||||
Ox.Input({
|
||||
label: Ox._('To'),
|
||||
labelWidth: 96,
|
||||
width: 512
|
||||
}).css({
|
||||
margin: '8px'
|
||||
}).bindEvent({
|
||||
change: function(data) {
|
||||
$button.options({disabled: !data.value && !old});
|
||||
value = data.value;
|
||||
}
|
||||
}).appendTo($content)
|
||||
],
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
Ox.Button({
|
||||
id: 'cancel',
|
||||
title: Ox._('Cancel')
|
||||
})
|
||||
.bindEvent({
|
||||
click: function() {
|
||||
that.close();
|
||||
}
|
||||
}),
|
||||
$button = Ox.Button({
|
||||
disabled: true,
|
||||
id: 'update',
|
||||
title: Ox._('Rename Keyword')
|
||||
})
|
||||
.bindEvent({
|
||||
click: renameKeyword
|
||||
})
|
||||
],
|
||||
closeButton: true,
|
||||
content: $content,
|
||||
height: dialogHeight,
|
||||
removeOnClose: true,
|
||||
title: Ox._('Change Keyword'),
|
||||
width: dialogWidth
|
||||
})
|
||||
.bindEvent({
|
||||
resize: setSize
|
||||
});
|
||||
|
||||
function getFormWidth() {
|
||||
return dialogWidth - 32 - Ox.UI.SCROLLBAR_SIZE;
|
||||
}
|
||||
|
||||
function setSize(data) {
|
||||
dialogHeight = data.height;
|
||||
dialogWidth = data.width;
|
||||
formWidth = getFormWidth();
|
||||
$input.forEach(function($element) {
|
||||
$element.options({width: formWidth});
|
||||
});
|
||||
}
|
||||
|
||||
function renameAnnotation(layer, old, value, callback) {
|
||||
pandora.api.findAnnotations({
|
||||
'query': {
|
||||
'conditions': [{
|
||||
'key': 'value',
|
||||
'value': old,
|
||||
'operator': '=='
|
||||
},
|
||||
{
|
||||
'key': 'layer',
|
||||
'value': layer,
|
||||
'operator': '=='
|
||||
}],
|
||||
'operator': '&'
|
||||
},
|
||||
'keys': ['id', 'in', 'out', 'value', 'user', 'created'],
|
||||
'range': [0, 500000]
|
||||
}, function(result) {
|
||||
console.log('got annots', result.data.items);
|
||||
Ox.serialForEach(result.data.items, function(annotation, index, array, next) {
|
||||
pandora.api.editAnnotation({
|
||||
id: annotation.id,
|
||||
value: value
|
||||
}, function(result) {
|
||||
next()
|
||||
})
|
||||
}, function() {
|
||||
callback()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function renameKeyword() {
|
||||
that.options({content: Ox.LoadingScreen().start()});
|
||||
renameAnnotation('keywords', old, value, function() {
|
||||
Ox.Request.clearCache();
|
||||
that.close();
|
||||
})
|
||||
}
|
||||
return that;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue