Compare commits
2 commits
e3ae1367d6
...
334b4af5fe
| Author | SHA1 | Date | |
|---|---|---|---|
| 334b4af5fe | |||
| b70ee35381 |
3 changed files with 81 additions and 3 deletions
|
|
@ -1,5 +1,15 @@
|
|||
#!/bin/bash
|
||||
rsync -avP time:/srv/pandora/data/ /srv/pandora/data/
|
||||
|
||||
rsync -avP power:/srv/pandora/data/ /srv/pandora/data/
|
||||
if systemctl is-active --quiet render-infinity.service; then
|
||||
systemctl stop render-infinity.service
|
||||
restart_infinity=1
|
||||
else
|
||||
restart_infinity=0
|
||||
fi
|
||||
bash /srv/pandora/data/db/reload.sh
|
||||
rsync -avP time:/srv/pandora/data/ /srv/pandora/data/ --delete
|
||||
pandoractl manage generate_clips
|
||||
rsync -avP power:/srv/pandora/data/ /srv/pandora/data/ --delete
|
||||
if [ $restart_infinity == 1 ]; then
|
||||
systemctl start render-infinity.service
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@ Description=Backup pandora database
|
|||
Type=oneshot
|
||||
User=pandora
|
||||
Group=pandora
|
||||
ExecStart=/srv/pandora/db/update.sh
|
||||
ExecStart=/srv/pandora/data/db/update.sh
|
||||
|
|
|
|||
68
import_vo.py
Normal file
68
import_vo.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import ox
|
||||
import os
|
||||
import json
|
||||
import sys
|
||||
import re
|
||||
|
||||
api = ox.api.signin("https://power.0x2620.org/api/")
|
||||
|
||||
prefix = sys.argv[1]
|
||||
|
||||
def fix_timecode(match):
|
||||
ts, ms = match[0].split(',')
|
||||
seconds = int(ms)/1000
|
||||
for i, v in enumerate(list(reversed(ts.split(':')))):
|
||||
seconds += float(v) * pow(60, i)
|
||||
return ox.format_duration(seconds * 1000, years=False).replace('.', ',')
|
||||
|
||||
def fix_timecodes(srt_data):
|
||||
reg = re.compile(r'(\d\d:\d\d:\d\d,\d\d\d\d)')
|
||||
old = srt_data
|
||||
srt_data = re.sub(reg, fix_timecode, srt_data)
|
||||
if srt_data != old:
|
||||
rows1 = old.split('\n')
|
||||
rows2 = srt_data.split('\n')
|
||||
for n, row in enumerate(rows1):
|
||||
if rows1[n] != rows2[n]:
|
||||
print(rows1[n], '->', rows2[n])
|
||||
return srt_data
|
||||
|
||||
for root, folders, files in os.walk(prefix):
|
||||
for file in sorted(files):
|
||||
if file.endswith('.mp3'):
|
||||
print(file)
|
||||
chapter = '%02d' % int(file.split('-')[0].replace('ch', ''))
|
||||
file = os.path.join(root, file)
|
||||
srt = file.replace('.mp3', '_eng.srt')
|
||||
if not os.path.exists(srt):
|
||||
name = os.path.basename(srt)
|
||||
srt = srt.replace(name, name.replace(' ', '_'))
|
||||
with open(srt) as fd:
|
||||
srt_data = fd.read()
|
||||
srt_data = fix_timecodes(srt_data)
|
||||
subs = ox.srt.loads(srt_data)
|
||||
oshash = ox.oshash(file)
|
||||
url = '%supload/direct/' % api.url
|
||||
avinfo = ox.avinfo(file)
|
||||
r = api.addMedia({
|
||||
'id': oshash,
|
||||
'filename': os.path.basename(file),
|
||||
'info': avinfo
|
||||
})
|
||||
id = r['data']['item']
|
||||
if api.upload_chunks(url, file, {'id': oshash}):
|
||||
info = {
|
||||
"id": id,
|
||||
"type": 'voice over',
|
||||
"chapter": [chapter]
|
||||
}
|
||||
api.edit(info)
|
||||
for sub in subs:
|
||||
sub['value'] = sub['value'].replace('\n', '<br>\n')
|
||||
api.addAnnotations({
|
||||
"item": id,
|
||||
"layer": "subtitles",
|
||||
"annotations": subs
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue