RFC imports
This commit is contained in:
@@ -1,23 +1,7 @@
|
||||
import os, time, sqlite3, sqlalchemy
|
||||
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
# from ffx.model.show import Base, Show
|
||||
# from ffx.model.pattern import Pattern
|
||||
# from ffx.model.track import Track
|
||||
|
||||
# from ffx.model.media_tag import MediaTag
|
||||
# from ffx.model.track_tag import TrackTag
|
||||
from textual.app import App
|
||||
|
||||
from .shows_screen import ShowsScreen
|
||||
from .warning_screen import WarningScreen
|
||||
from .dashboard_screen import DashboardScreen
|
||||
from .settings_screen import SettingsScreen
|
||||
from .help_screen import HelpScreen
|
||||
|
||||
|
||||
class FfxApp(App):
|
||||
|
||||
|
||||
@@ -3,11 +3,6 @@ import os, re, click, json
|
||||
from .media_descriptor import MediaDescriptor
|
||||
from .pattern_controller import PatternController
|
||||
|
||||
#from .track_type import TrackType
|
||||
#from .audio_layout import AudioLayout
|
||||
|
||||
#from .track_disposition import TrackDisposition
|
||||
|
||||
from .process import executeProcess
|
||||
|
||||
|
||||
|
||||
@@ -93,15 +93,6 @@ class IsoLanguage(Enum):
|
||||
return foundLangs[0] if foundLangs else IsoLanguage.UNDEFINED
|
||||
|
||||
|
||||
# def get(lang : str):
|
||||
#
|
||||
# selectedLangs = [l for l in IsoLanguage if l.value['iso639_2'] == lang]
|
||||
#
|
||||
# if selectedLangs:
|
||||
# return selectedLangs[0]
|
||||
# else:
|
||||
# return None
|
||||
|
||||
def label(self):
|
||||
return str(self.value['name'])
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@ import click, re
|
||||
|
||||
from ffx.model.pattern import Pattern
|
||||
|
||||
from .media_descriptor import MediaDescriptor
|
||||
|
||||
|
||||
class PatternController():
|
||||
|
||||
@@ -88,12 +86,7 @@ class PatternController():
|
||||
s = self.Session()
|
||||
q = s.query(Pattern).filter(Pattern.id == int(patternId))
|
||||
|
||||
if q.count():
|
||||
# pattern = q.first()
|
||||
#return self.getPatternDict(pattern)
|
||||
return q.first()
|
||||
else:
|
||||
return None
|
||||
return q.first() if q.count() else None
|
||||
|
||||
except Exception as ex:
|
||||
raise click.ClickException(f"PatternController.getPattern(): {repr(ex)}")
|
||||
@@ -125,11 +118,6 @@ class PatternController():
|
||||
|
||||
def matchFilename(self, filename):
|
||||
|
||||
#SEASON_PATTERN = '[sS]([0-9]+)'
|
||||
#EPISODE_PATTERN = '[eE]([0-9]+)'
|
||||
|
||||
#result = {}
|
||||
|
||||
try:
|
||||
s = self.Session()
|
||||
q = s.query(Pattern)
|
||||
@@ -141,26 +129,6 @@ class PatternController():
|
||||
else:
|
||||
return None
|
||||
|
||||
# for pattern in q.all():
|
||||
#
|
||||
# match = re.search(pattern.pattern, filename)
|
||||
#
|
||||
# if match:
|
||||
#
|
||||
# result['pattern_id'] = pattern.id
|
||||
# result['show_id'] = pattern.show_id
|
||||
#
|
||||
# result['indicator'] = match.group(1)
|
||||
#
|
||||
# seasonMatch = re.search(SEASON_PATTERN, result['indicator'])
|
||||
# if seasonMatch:
|
||||
# result['season'] = int(seasonMatch.group(1))
|
||||
#
|
||||
# episodeMatch = re.search(EPISODE_PATTERN, result['indicator'])
|
||||
# if episodeMatch:
|
||||
# result['episode'] = int(episodeMatch.group(1))
|
||||
|
||||
|
||||
except Exception as ex:
|
||||
raise click.ClickException(f"PatternController.findPattern(): {repr(ex)}")
|
||||
finally:
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
import click
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
|
||||
from ffx.model.pattern import Pattern
|
||||
from textual.widgets import Header, Footer, Static, Button
|
||||
from textual.containers import Grid
|
||||
|
||||
from .show_controller import ShowController
|
||||
from .pattern_controller import PatternController
|
||||
|
||||
@@ -3,8 +3,8 @@ import click, re
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.widgets import Header, Footer, Static, Button, Input, DataTable
|
||||
from textual.containers import Grid
|
||||
|
||||
from ffx.model.show import Show
|
||||
from ffx.model.pattern import Pattern
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
import subprocess
|
||||
|
||||
|
||||
#class ProcessController():
|
||||
|
||||
#def __init__(self, commandSequence):
|
||||
# self.__commandSequence = commandSequence
|
||||
|
||||
def executeProcess(commandSequence):
|
||||
|
||||
process = subprocess.Popen(commandSequence, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
|
||||
output, error = process.communicate()
|
||||
|
||||
return output.decode('utf-8'), error.decode('utf-8'), process.returncode
|
||||
|
||||
|
||||
@@ -17,25 +17,10 @@ class ShowController():
|
||||
s = self.Session()
|
||||
q = s.query(Show).filter(Show.id == showId)
|
||||
|
||||
showDescriptor = {}
|
||||
|
||||
if q.count():
|
||||
show = q.first()
|
||||
|
||||
# showDescriptor['id'] = int(show.id)
|
||||
# showDescriptor['name'] = str(show.name)
|
||||
# showDescriptor['year'] = int(show.year)
|
||||
#
|
||||
# showDescriptor['index_season_digits'] = int(show.index_season_digits)
|
||||
# showDescriptor['index_episode_digits'] = int(show.index_episode_digits)
|
||||
# showDescriptor['indicator_season_digits'] = int(show.indicator_season_digits)
|
||||
# showDescriptor['indicator_episode_digits'] = int(show.indicator_episode_digits)
|
||||
#
|
||||
# return showDescriptor
|
||||
|
||||
return show.getDesciptor()
|
||||
|
||||
|
||||
except Exception as ex:
|
||||
raise click.ClickException(f"ShowController.getShowDesciptor(): {repr(ex)}")
|
||||
finally:
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import click
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
|
||||
from ffx.model.show import Show
|
||||
from textual.widgets import Header, Footer, Static, Button
|
||||
from textual.containers import Grid
|
||||
|
||||
from .show_controller import ShowController
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
import click
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.widgets import Header, Footer, Static, Button, DataTable, Input
|
||||
from textual.containers import Grid
|
||||
from textual.widgets._data_table import CellDoesNotExist
|
||||
|
||||
|
||||
@@ -215,12 +213,9 @@ class ShowDetailsScreen(Screen):
|
||||
|
||||
# Define the columns with headers
|
||||
self.column_key_pattern = self.patternTable.add_column("Pattern", width=150)
|
||||
#self.column_key_name = self.patternTable.add_column("Name", width=50)
|
||||
#self.column_key_year = self.patternTable.add_column("Year", width=10)
|
||||
|
||||
self.patternTable.cursor_type = 'row'
|
||||
|
||||
|
||||
yield Header()
|
||||
|
||||
with Grid():
|
||||
|
||||
@@ -3,7 +3,7 @@ import click
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.containers import Grid
|
||||
|
||||
from ffx.model.show import Show
|
||||
|
||||
|
||||
@@ -2,11 +2,6 @@ import click
|
||||
|
||||
from ffx.model.track import Track
|
||||
|
||||
from .track_type import TrackType
|
||||
|
||||
from .track_disposition import TrackDisposition
|
||||
from .iso_language import IsoLanguage
|
||||
|
||||
from ffx.model.media_tag import MediaTag
|
||||
from ffx.model.track_tag import TrackTag
|
||||
|
||||
@@ -70,58 +65,6 @@ class TagController():
|
||||
s.close()
|
||||
|
||||
|
||||
# def addTrackTag(self, trackDescriptor):
|
||||
#
|
||||
# try:
|
||||
# s = self.Session()
|
||||
#
|
||||
# track = Track(pattern_id = int(trackDescriptor['pattern_id']),
|
||||
#
|
||||
# track_type = int(trackDescriptor['type'].value),
|
||||
#
|
||||
# sub_index = int(trackDescriptor['sub_index']),
|
||||
#
|
||||
# # language = str(trackDescriptor['language'].threeLetter()),
|
||||
# # title = str(trackDescriptor['title']),
|
||||
#
|
||||
# disposition_flags = int(TrackDisposition.toFlags(trackDescriptor['disposition_list'])))
|
||||
#
|
||||
# s.add(track)
|
||||
# s.commit()
|
||||
#
|
||||
# except Exception as ex:
|
||||
# raise click.ClickException(f"TrackController.addTrack(): {repr(ex)}")
|
||||
# finally:
|
||||
# s.close()
|
||||
#
|
||||
#
|
||||
#
|
||||
# def updateTrack(self, trackId, trackDescriptor):
|
||||
#
|
||||
# try:
|
||||
# s = self.Session()
|
||||
# q = s.query(Track).filter(Track.id == int(trackId))
|
||||
#
|
||||
# if q.count():
|
||||
#
|
||||
# track = q.first()
|
||||
#
|
||||
# track.sub_index = int(trackDescriptor['sub_index'])
|
||||
# # track.language = str(trackDescriptor['language'].threeLetter())
|
||||
# # track.title = str(trackDescriptor['title'])
|
||||
# track.disposition_flags = int(TrackDisposition.toFlags(trackDescriptor['disposition_list']))
|
||||
#
|
||||
# s.commit()
|
||||
#
|
||||
# return True
|
||||
#
|
||||
# else:
|
||||
# return False
|
||||
#
|
||||
# except Exception as ex:
|
||||
# raise click.ClickException(f"TrackController.addTrack(): {repr(ex)}")
|
||||
# finally:
|
||||
# s.close()
|
||||
def findAllMediaTags(self, trackId) -> dict:
|
||||
|
||||
try:
|
||||
@@ -223,9 +166,6 @@ class TagController():
|
||||
s = self.Session()
|
||||
q = s.query(TrackTag).filter(TrackTag.id == int(tagId))
|
||||
|
||||
# raise click.ClickException(f"tagId={tagId}")
|
||||
# raise click.ClickException(f"q count={q.count()}")
|
||||
|
||||
if q.count():
|
||||
|
||||
tag = q.first()
|
||||
|
||||
@@ -1,19 +1,7 @@
|
||||
import click
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.widgets import Header, Footer, Static, Button
|
||||
from textual.containers import Grid
|
||||
|
||||
from ffx.model.pattern import Pattern
|
||||
from ffx.track_descriptor import TrackDescriptor
|
||||
|
||||
# from .show_controller import ShowController
|
||||
# from .pattern_controller import PatternController
|
||||
from .track_controller import TrackController
|
||||
|
||||
from .track_type import TrackType
|
||||
|
||||
# Screen[dict[int, str, int]]
|
||||
class TagDeleteScreen(Screen):
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
import click, time
|
||||
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input, Checkbox, SelectionList, Select
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.widgets import Header, Footer, Static, Button, Input
|
||||
from textual.containers import Grid
|
||||
|
||||
|
||||
# Screen[dict[int, str, int]]
|
||||
class TagDetailsScreen(Screen):
|
||||
|
||||
@@ -123,8 +123,6 @@ class TrackController():
|
||||
q = s.query(Track).filter(Track.pattern_id == int(patternId), Track.track_type == trackType.index(), Track.sub_index == int(subIndex))
|
||||
|
||||
if q.count():
|
||||
#track = q.first()
|
||||
#return int(track.id)
|
||||
return q.first()
|
||||
else:
|
||||
return None
|
||||
@@ -141,7 +139,6 @@ class TrackController():
|
||||
|
||||
if q.count():
|
||||
|
||||
#trackDescriptor = self.getTrackDict(q.first())
|
||||
track = q.first()
|
||||
|
||||
q_siblings = s.query(Track).filter(Track.pattern_id == track.getPatternId(), Track.track_type == track.getType().index()).order_by(Track.sub_index)
|
||||
|
||||
@@ -3,14 +3,12 @@ import click
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.widgets import Header, Footer, Static, Button
|
||||
from textual.containers import Grid
|
||||
|
||||
from ffx.model.pattern import Pattern
|
||||
from ffx.track_descriptor import TrackDescriptor
|
||||
|
||||
# from .show_controller import ShowController
|
||||
# from .pattern_controller import PatternController
|
||||
from .track_controller import TrackController
|
||||
|
||||
from .track_type import TrackType
|
||||
|
||||
@@ -3,17 +3,14 @@ import click, time
|
||||
from textual import events
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.screen import Screen
|
||||
from textual.widgets import Header, Footer, Placeholder, Label, ListView, ListItem, Static, DataTable, Button, Input, Checkbox, SelectionList, Select
|
||||
from textual.containers import Grid, Horizontal
|
||||
from textual.coordinate import Coordinate
|
||||
from textual.widgets import Header, Footer, Static, Button, SelectionList, Select, DataTable, Input
|
||||
from textual.containers import Grid
|
||||
|
||||
from ffx.model.show import Show
|
||||
from ffx.model.pattern import Pattern
|
||||
|
||||
from .track_controller import TrackController
|
||||
from .pattern_controller import PatternController
|
||||
from .tag_controller import TagController
|
||||
# from .show_controller import ShowController
|
||||
|
||||
from .track_type import TrackType
|
||||
|
||||
@@ -301,8 +298,6 @@ class TrackDetailsScreen(Screen):
|
||||
|
||||
trackDescriptor = self.getTrackDescriptorFromInput()
|
||||
|
||||
# raise click.ClickException(f"td.tags={trackDescriptor.getTags()}") # language=ger, title=Deutsch
|
||||
|
||||
# Check for multiple default/forced disposition flags
|
||||
|
||||
if self.__trackType == TrackType.AUDIO:
|
||||
@@ -341,29 +336,24 @@ class TrackDetailsScreen(Screen):
|
||||
else:
|
||||
self.app.pop_screen()
|
||||
|
||||
|
||||
if event.button.id == "cancel_button":
|
||||
self.app.pop_screen()
|
||||
|
||||
|
||||
|
||||
if event.button.id == "button_add_stream_tag":
|
||||
self.app.push_screen(TagDetailsScreen(), self.handle_add_tag)
|
||||
|
||||
#row = ('<key>','<value>')
|
||||
#self.trackTagsTable.add_row(*map(str, row))
|
||||
if not self.__isNew:
|
||||
self.app.push_screen(TagDetailsScreen(), self.handle_update_tag)
|
||||
|
||||
if event.button.id == "button_edit_stream_tag":
|
||||
tagKey, tagValue = self.getSelectedTag()
|
||||
self.app.push_screen(TagDetailsScreen(key=tagKey, value=tagValue), self.handle_add_tag)
|
||||
self.app.push_screen(TagDetailsScreen(key=tagKey, value=tagValue), self.handle_update_tag)
|
||||
|
||||
if event.button.id == "button_delete_stream_tag":
|
||||
tagKey, tagValue = self.getSelectedTag()
|
||||
self.app.push_screen(TagDeleteScreen(key=tagKey, value=tagValue), self.handle_delete_tag)
|
||||
|
||||
|
||||
|
||||
def handle_add_tag(self, tag):
|
||||
def handle_update_tag(self, tag):
|
||||
|
||||
trackId = self.__trackDescriptor.getId()
|
||||
|
||||
@@ -373,32 +363,6 @@ class TrackDetailsScreen(Screen):
|
||||
if self.__tac.updateTrackTag(trackId, tag[0], tag[1]) is not None:
|
||||
self.updateTags()
|
||||
|
||||
|
||||
def handle_edit_tag(self, tag):
|
||||
pass
|
||||
# try:
|
||||
# if trackDescriptor.getType() == TrackType.AUDIO:
|
||||
#
|
||||
# row_key, col_key = self.audioStreamsTable.coordinate_to_cell_key(self.audioStreamsTable.cursor_coordinate)
|
||||
#
|
||||
# self.audioStreamsTable.update_cell(row_key, self.column_key_audio_language, trackDescriptor.getLanguage().label())
|
||||
# self.audioStreamsTable.update_cell(row_key, self.column_key_audio_title, trackDescriptor.getTitle())
|
||||
# self.audioStreamsTable.update_cell(row_key, self.column_key_audio_default, 'Yes' if TrackDisposition.DEFAULT in trackDescriptor.getDispositionSet() else 'No')
|
||||
# self.audioStreamsTable.update_cell(row_key, self.column_key_audio_forced, 'Yes' if TrackDisposition.FORCED in trackDescriptor.getDispositionSet() else 'No')
|
||||
#
|
||||
# if trackDescriptor.getType() == TrackType.SUBTITLE:
|
||||
#
|
||||
# row_key, col_key = self.subtitleStreamsTable.coordinate_to_cell_key(self.subtitleStreamsTable.cursor_coordinate)
|
||||
#
|
||||
# self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_language, trackDescriptor.getLanguage().label())
|
||||
# self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_title, trackDescriptor.getTitle())
|
||||
# self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_default, 'Yes' if TrackDisposition.DEFAULT in trackDescriptor.getDispositionSet() else 'No')
|
||||
# self.subtitleStreamsTable.update_cell(row_key, self.column_key_subtitle_forced, 'Yes' if TrackDisposition.FORCED in trackDescriptor.getDispositionSet() else 'No')
|
||||
#
|
||||
# except CellDoesNotExist:
|
||||
# pass
|
||||
|
||||
|
||||
def handle_delete_tag(self, trackTag):
|
||||
|
||||
trackId = self.__trackDescriptor.getId()
|
||||
@@ -410,5 +374,4 @@ class TrackDetailsScreen(Screen):
|
||||
|
||||
if tag is not None:
|
||||
if self.__tac.deleteTrackTag(tag.id):
|
||||
# raise click.ClickException('deleted!')
|
||||
self.updateTags()
|
||||
|
||||
Reference in New Issue
Block a user