cinemuse
This commit is contained in:
commit
28f7c4f102
5 changed files with 2710 additions and 0 deletions
0
__init__.py
Normal file
0
__init__.py
Normal file
1422
config.jsonc
Normal file
1422
config.jsonc
Normal file
File diff suppressed because it is too large
Load diff
84
install.py
Executable file
84
install.py
Executable file
|
@ -0,0 +1,84 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
from os.path import join, abspath, basename, dirname
|
||||||
|
|
||||||
|
# change this
|
||||||
|
name = 'cinemuse'
|
||||||
|
overwrite = (
|
||||||
|
#('home', 'indiancinema'),
|
||||||
|
#('infoView', 'indiancinema'),
|
||||||
|
)
|
||||||
|
|
||||||
|
base = abspath(dirname(__file__))
|
||||||
|
os.chdir(base)
|
||||||
|
|
||||||
|
for root, folders, files in os.walk(join(base, 'static')):
|
||||||
|
for f in files:
|
||||||
|
src = join(root, f)
|
||||||
|
target = src.replace(base, '/srv/pandora')
|
||||||
|
rel_src = os.path.relpath(src, dirname(target))
|
||||||
|
if os.path.exists(target):
|
||||||
|
os.unlink(target)
|
||||||
|
os.symlink(rel_src, target)
|
||||||
|
|
||||||
|
if overwrite:
|
||||||
|
os.chdir('/srv/pandora/static/js')
|
||||||
|
for filename, sitename in overwrite:
|
||||||
|
src = '%s.%s.js' % (filename, sitename)
|
||||||
|
target = '%s.%s.js' % (filename, name)
|
||||||
|
if os.path.exists(target):
|
||||||
|
os.unlink(target)
|
||||||
|
os.symlink(src, target)
|
||||||
|
|
||||||
|
os.chdir(base)
|
||||||
|
src = join(base, 'config.jsonc')
|
||||||
|
target = '/srv/pandora/pandora/config.%s.jsonc' % name
|
||||||
|
rel_src = os.path.relpath(src, dirname(target))
|
||||||
|
if os.path.exists(target):
|
||||||
|
os.unlink(target)
|
||||||
|
os.symlink(rel_src, target)
|
||||||
|
t = '/srv/pandora/pandora/config.jsonc'
|
||||||
|
if os.path.exists(t):
|
||||||
|
os.unlink(t)
|
||||||
|
os.symlink(basename(target), t)
|
||||||
|
|
||||||
|
for root, folders, files in os.walk(join(base, 'scripts')):
|
||||||
|
for f in files:
|
||||||
|
src = join(root, f)
|
||||||
|
target = src.replace(base, '/srv/pandora')
|
||||||
|
rel_src = os.path.relpath(src, dirname(target))
|
||||||
|
if os.path.exists(target):
|
||||||
|
os.unlink(target)
|
||||||
|
os.symlink(rel_src, target)
|
||||||
|
if f == 'poster.%s.py' % name:
|
||||||
|
t = os.path.join(dirname(target), 'poster.py')
|
||||||
|
if os.path.exists(t):
|
||||||
|
os.unlink(t)
|
||||||
|
os.symlink(f, os.path.join(dirname(target), t))
|
||||||
|
|
||||||
|
if os.path.exists('__init__.py'):
|
||||||
|
# make module available to pandora
|
||||||
|
target = os.path.join('/srv/pandora/pandora/', name)
|
||||||
|
rel_src = os.path.relpath(base, dirname(target))
|
||||||
|
if os.path.exists(target):
|
||||||
|
os.unlink(target)
|
||||||
|
os.symlink(rel_src, target)
|
||||||
|
|
||||||
|
# include module in local settings
|
||||||
|
local_settings_py = '/srv/pandora/pandora/local_settings.py'
|
||||||
|
with open(local_settings_py) as fd:
|
||||||
|
local_settings_changed = False
|
||||||
|
local_settings = fd.read()
|
||||||
|
if 'LOCAL_APPS' not in local_settings:
|
||||||
|
local_settings += '\nLOCAL_APPS = ["%s"]\n' % name
|
||||||
|
local_settings_changed = True
|
||||||
|
else:
|
||||||
|
apps = re.compile('(LOCAL_APPS.*?)\]', re.DOTALL).findall(local_settings)[0]
|
||||||
|
if name not in apps:
|
||||||
|
new_apps = apps.strip() + ',\n"%s"\n' % name
|
||||||
|
local_settings = local_settings.replace(apps, new_apps)
|
||||||
|
local_settings_changed = True
|
||||||
|
if local_settings_changed:
|
||||||
|
with open(local_settings_py, 'w') as fd:
|
||||||
|
fd.write(local_settings)
|
63
split_keywords.py
Executable file
63
split_keywords.py
Executable file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import ox
|
||||||
|
import ox.web.auth
|
||||||
|
import json
|
||||||
|
import sys
|
||||||
|
|
||||||
|
url = 'http://131.111.144.26/api/'
|
||||||
|
|
||||||
|
api = ox.API(url)
|
||||||
|
site = '131.111.144.26'
|
||||||
|
|
||||||
|
try:
|
||||||
|
credentials = ox.web.auth.get(site)
|
||||||
|
except:
|
||||||
|
credentials = {}
|
||||||
|
print('Please provide your username and password for %s:' % site)
|
||||||
|
credentials['username'] = input('Username: ')
|
||||||
|
credentials['password'] = getpass.getpass('Password: ')
|
||||||
|
update = True
|
||||||
|
r = api.signin(**credentials)
|
||||||
|
if 'errors' in r.get('data', {}):
|
||||||
|
for kv in r['data']['errors'].items():
|
||||||
|
print('%s: %s' % kv)
|
||||||
|
sys.exit(1)
|
||||||
|
if update:
|
||||||
|
ox.web.auth.update(site, credentials)
|
||||||
|
|
||||||
|
old = []
|
||||||
|
for annotation in api.findAnnotations({
|
||||||
|
'query': {
|
||||||
|
'conditions': [{
|
||||||
|
'key': 'value',
|
||||||
|
'value': ', ',
|
||||||
|
'operator': '='
|
||||||
|
}, {
|
||||||
|
'key': 'layer',
|
||||||
|
'value': 'keywords',
|
||||||
|
'operator': '=='
|
||||||
|
}],
|
||||||
|
'operator': '&'
|
||||||
|
},
|
||||||
|
'keys': ['id', 'in', 'out', 'value', 'user', 'created'],
|
||||||
|
'range': [0, 50000]
|
||||||
|
})['data']['items']:
|
||||||
|
item = annotation['id'].split('/')[0]
|
||||||
|
for v in annotation['value'].split(', '):
|
||||||
|
v = v.strip()
|
||||||
|
a = {
|
||||||
|
'in': annotation['in'],
|
||||||
|
'out': annotation['out'],
|
||||||
|
'item': item,
|
||||||
|
'layer': 'keywords',
|
||||||
|
'value': v,
|
||||||
|
}
|
||||||
|
print(a)
|
||||||
|
r = api.addAnnotation(a)
|
||||||
|
print(r.get('status'))
|
||||||
|
api.removeAnnotation({'id': annotation['id']})
|
||||||
|
old.append(annotation)
|
||||||
|
|
||||||
|
with open('old.json', 'w') as fd:
|
||||||
|
json.dump(old, fd, indent=4, ensure_ascii=False)
|
1141
static/js/infoView.cinemuse.js
Normal file
1141
static/js/infoView.cinemuse.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue