Compare commits

..

No commits in common. "841a654254372f755c5bbae8d70847a116e09b8e" and "7e4c062a13ae03203440e09734a822e30858d2c4" have entirely different histories.

2 changed files with 6 additions and 37 deletions

View file

@ -35,7 +35,6 @@ class Sync(Thread):
destination = "255.255.255.255" destination = "255.255.255.255"
reload_check = None reload_check = None
_pos = None _pos = None
_tick = 0
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.is_main = kwargs.get('mode', 'main') == 'main' self.is_main = kwargs.get('mode', 'main') == 'main'
@ -67,6 +66,7 @@ class Sync(Thread):
self.sync_to_main() self.sync_to_main()
self.ready = True self.ready = True
Thread.__init__(self) Thread.__init__(self)
self.daemon = True
self.start() self.start()
def run(self): def run(self):
@ -77,13 +77,6 @@ class Sync(Thread):
self.read_position_main() self.read_position_main()
#self.adjust_position() #self.adjust_position()
self.reload_playlist() self.reload_playlist()
if self._tick and abs(time.time() - self._tick) > 10:
logger.error("player is stuck")
self._tick = 0
self.mpv.loadlist(self.playlist)
self.mpv.playlist_play_index(0)
self.mpv.pause = False
self.mpv.wait_until_playing()
def q_binding(self, *args): def q_binding(self, *args):
self.stop() self.stop()
@ -96,7 +89,6 @@ class Sync(Thread):
self.sock = None self.sock = None
def time_pos_cb(self, pos, *args, **kwargs): def time_pos_cb(self, pos, *args, **kwargs):
self._tick = time.time()
if self.is_main: if self.is_main:
self.send_position_local() self.send_position_local()
elif self.ready: elif self.ready:

View file

@ -282,7 +282,7 @@ def render(root, scene, prefix=''):
files.append(path) files.append(path)
return files return files
def get_fragments(clips, voice_over, prefix): def get_fragments(clips, voice_over):
import itemlist.models import itemlist.models
import item.models import item.models
from collections import defaultdict from collections import defaultdict
@ -293,37 +293,14 @@ def get_fragments(clips, voice_over, prefix):
if l.name.split(' ')[0].isdigit(): if l.name.split(' ')[0].isdigit():
fragment = { fragment = {
'name': l.name, 'name': l.name,
'tags': [], 'tags': [t['value'] for t in l.query['conditions'][1]['conditions'] if t['operator'] == '=='],
'anti-tags': [], 'anti-tags': [t['value'] for t in l.query['conditions'][1]['conditions'] if t['operator'] == '!='],
'description': l.description 'description': l.description
} }
for con in l.query['conditions']:
if "conditions" in con:
for sub in con["conditions"]:
if sub['key'] == "tags" and sub['operator'] == '==':
fragment['tags'].append(sub['value'])
elif sub['key'] == "tags" and sub['operator'] == '!=':
fragment['tags'].append(sub['value'])
else:
print('unknown sub condition', sub)
elif con.get('key') == "tags" and con['operator'] == '==':
fragment['tags'].append(con['value'])
elif con.get('key') == "tags" and con['operator'] == '!=':
fragment['anti-tags'].append(con['value'])
fragment["id"] = int(fragment['name'].split(' ')[0]) fragment["id"] = int(fragment['name'].split(' ')[0])
originals = []
for i in l.get_items(l.user):
orig = i.files.filter(selected=True).first()
if orig:
ext = os.path.splitext(orig.data.path)[1]
type_ = i.data['type'][0].lower()
target = os.path.join(prefix, type_, i.data['title'] + ext)
originals.append(target)
fragment['clips'] = [] fragment['clips'] = []
for clip in clips: for clip in clips:
#if set(clip['tags']) & set(fragment['tags']) and not set(clip['tags']) & set(fragment['anti-tags']): if set(clip['tags']) & set(fragment['tags']) and not set(clip['tags']) & set(fragment['anti-tags']):
if clip['original'] in originals:
fragment['clips'].append(clip) fragment['clips'].append(clip)
fragment["voice_over"] = voice_over.get(str(fragment["id"]), {}) fragment["voice_over"] = voice_over.get(str(fragment["id"]), {})
fragments.append(fragment) fragments.append(fragment)
@ -345,7 +322,7 @@ def render_all(options):
clips = json.load(fd) clips = json.load(fd)
with open(os.path.join(prefix, "voice_over.json")) as fd: with open(os.path.join(prefix, "voice_over.json")) as fd:
voice_over = json.load(fd) voice_over = json.load(fd)
fragments = get_fragments(clips, voice_over, prefix) fragments = get_fragments(clips, voice_over)
with open(os.path.join(prefix, "fragments.json"), "w") as fd: with open(os.path.join(prefix, "fragments.json"), "w") as fd:
json.dump(fragments, fd, indent=2, ensure_ascii=False) json.dump(fragments, fd, indent=2, ensure_ascii=False)
position = target_position = 0 position = target_position = 0