|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import click
|
|
|
|
|
import click, re
|
|
|
|
|
|
|
|
|
|
from textual import events
|
|
|
|
|
from textual.app import App, ComposeResult
|
|
|
|
@ -29,8 +29,8 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
CSS = """
|
|
|
|
|
|
|
|
|
|
Grid {
|
|
|
|
|
grid-size: 5 11;
|
|
|
|
|
grid-rows: 2 2 2 2 6 2 2 6 2 2 2;
|
|
|
|
|
grid-size: 5 12;
|
|
|
|
|
grid-rows: 2 2 2 2 2 6 2 2 6 2 2 2;
|
|
|
|
|
grid-columns: 25 25 25 25 25;
|
|
|
|
|
height: 100%;
|
|
|
|
|
width: 100%;
|
|
|
|
@ -79,7 +79,6 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
self.__sc = ShowController(context = self.context)
|
|
|
|
|
self.__tc = TrackController(context = self.context)
|
|
|
|
|
|
|
|
|
|
self.pattern_id = patternId
|
|
|
|
|
self.pattern_obj = self.__pc.getPatternDescriptor(patternId) if patternId is not None else {}
|
|
|
|
|
|
|
|
|
|
self.show_obj = self.__sc.getShowDesciptor(showId) if showId is not None else {}
|
|
|
|
@ -108,9 +107,9 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
self.audioStreamsTable.clear()
|
|
|
|
|
|
|
|
|
|
trackIds = self.__tc.findAllTracks(self.pattern_id) #! id missing
|
|
|
|
|
trackIds = self.__tc.findAllTracks(self.pattern_obj['id'])
|
|
|
|
|
|
|
|
|
|
for audioTrackId in trackIds['audio']:
|
|
|
|
|
for audioTrackId in trackIds[TrackType.AUDIO.label()]:
|
|
|
|
|
|
|
|
|
|
ad = self.__tc.getTrackDescriptor(audioTrackId)
|
|
|
|
|
dispoList = ad['disposition_list']
|
|
|
|
@ -126,24 +125,24 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
def updateSubtitleTracks(self):
|
|
|
|
|
|
|
|
|
|
self.audioStreamsTable.clear()
|
|
|
|
|
self.subtitleStreamsTable.clear()
|
|
|
|
|
|
|
|
|
|
trackIds = self.__tc.findAllTracks(self.pattern_id)
|
|
|
|
|
trackIds = self.__tc.findAllTracks(self.pattern_obj['id'])
|
|
|
|
|
|
|
|
|
|
for audioTrackId in trackIds['audio']:
|
|
|
|
|
for subtitleTrackId in trackIds[TrackType.SUBTITLE.label()]:
|
|
|
|
|
|
|
|
|
|
ad = self.__tc.getTrackDescriptor(audioTrackId)
|
|
|
|
|
dispoList = ad['disposition_list']
|
|
|
|
|
sd = self.__tc.getTrackDescriptor(subtitleTrackId)
|
|
|
|
|
dispoList = sd['disposition_list']
|
|
|
|
|
|
|
|
|
|
row = (ad['sub_index'],
|
|
|
|
|
row = (sd['sub_index'],
|
|
|
|
|
" ",
|
|
|
|
|
ad['language'].label(),
|
|
|
|
|
ad['title'],
|
|
|
|
|
sd['language'].label(),
|
|
|
|
|
sd['title'],
|
|
|
|
|
'Yes' if TrackDisposition.DEFAULT in dispoList else 'No',
|
|
|
|
|
'Yes' if TrackDisposition.FORCED in dispoList else 'No')
|
|
|
|
|
|
|
|
|
|
self.audioStreamsTable.add_row(*map(str, row))
|
|
|
|
|
|
|
|
|
|
self.subtitleStreamsTable.add_row(*map(str, row))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def on_mount(self):
|
|
|
|
|
|
|
|
|
@ -198,7 +197,8 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
# 2
|
|
|
|
|
yield Static("from show")
|
|
|
|
|
yield Static("", id="showlabel")
|
|
|
|
|
yield Static("", id="showlabel", classes="three")
|
|
|
|
|
yield Button("Substitute pattern", id="patternbutton")
|
|
|
|
|
|
|
|
|
|
# 3
|
|
|
|
|
yield Static(" ", classes="five")
|
|
|
|
@ -315,15 +315,11 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
if self.pattern_obj:
|
|
|
|
|
|
|
|
|
|
if self.pattern_id is None:
|
|
|
|
|
if self.__pc.updatePattern(self.pattern_obj['id'], patternDescriptor):
|
|
|
|
|
self.dismiss(patternDescriptor)
|
|
|
|
|
else:
|
|
|
|
|
#TODO: Meldung
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
else:
|
|
|
|
|
if self.__pc.updatePattern(self.pattern_id, patternDescriptor):
|
|
|
|
|
self.dismiss(patternDescriptor)
|
|
|
|
|
else:
|
|
|
|
|
#TODO: Meldung
|
|
|
|
|
self.app.pop_screen()
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
if self.__pc.addPattern(patternDescriptor):
|
|
|
|
@ -345,24 +341,35 @@ class PatternDetailsScreen(Screen):
|
|
|
|
|
|
|
|
|
|
if event.button.id == "button_add_audio_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackType = TrackType.AUDIO, patternId = self.pattern_obj['id'], subIndex = len(self.audioStreamsTable.rows)), self.handle_add_track)
|
|
|
|
|
if event.button.id == "button_edit_audio_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackId = self.getSelectedAudioTrackId()), self.handle_edit_track)
|
|
|
|
|
|
|
|
|
|
selectedAudioTrackId = self.getSelectedAudioTrackId()
|
|
|
|
|
if selectedAudioTrackId is not None:
|
|
|
|
|
if event.button.id == "button_edit_audio_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackId = selectedAudioTrackId), self.handle_edit_track)
|
|
|
|
|
if event.button.id == "button_delete_audio_stream":
|
|
|
|
|
self.app.push_screen(TrackDeleteScreen(trackId = selectedAudioTrackId), self.handle_delete_track)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if event.button.id == "button_add_subtitle_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackType = TrackType.SUBTITLE, patternId = self.pattern_obj['id'], subIndex = len(self.subtitleStreamsTable.rows)), self.handle_add_track)
|
|
|
|
|
if event.button.id == "button_edit_subtitle_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackId = self.getSelectedSubtitleTrackId()), self.handle_edit_track)
|
|
|
|
|
|
|
|
|
|
selectedSubtitleTrackId = self.getSelectedSubtitleTrackId()
|
|
|
|
|
if selectedSubtitleTrackId is not None:
|
|
|
|
|
if event.button.id == "button_edit_subtitle_stream":
|
|
|
|
|
self.app.push_screen(TrackDetailsScreen(trackId = selectedSubtitleTrackId), self.handle_edit_track)
|
|
|
|
|
if event.button.id == "button_delete_subtitle_stream":
|
|
|
|
|
self.app.push_screen(TrackDeleteScreen(trackId = selectedSubtitleTrackId), self.handle_delete_track)
|
|
|
|
|
|
|
|
|
|
if event.button.id == "patternbutton":
|
|
|
|
|
|
|
|
|
|
INDICATOR_PATTERN = '([sS][0-9]+[eE][0-9]+)'
|
|
|
|
|
|
|
|
|
|
pattern = self.query_one("#pattern_input", Input).value
|
|
|
|
|
|
|
|
|
|
patternMatch = re.search(INDICATOR_PATTERN, pattern)
|
|
|
|
|
|
|
|
|
|
if patternMatch:
|
|
|
|
|
self.query_one("#pattern_input", Input).value = pattern.replace(patternMatch.group(1), INDICATOR_PATTERN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def handle_add_track(self, trackDescriptor):
|
|
|
|
|
|
|
|
|
|