Ejemplo n.º 1
0
 def GetValue(self):
     if self.isValid():
         if self.m_radioAuto.GetValue():
             return ChannelsMap.auto()
         elif self.m_radioAllChannels.GetValue():
             return ChannelsMap.all()
         else:
             chs = [c for c in self.channels if self.channels[c].GetValue()]
             return ChannelsMap.custom(chs)
     else:
         return ChannelsMap.auto()
Ejemplo n.º 2
0
def parseSyncArgs(args):
    from subsync.synchro import SyncTask, SubFile, RefFile, OutputFile, ChannelsMap

    sub = SubFile(path=args.sub)
    if args.sub_stream is not None:
        sub.select(args.sub_stream - 1)
    elif args.sub_stream_by_lang:
        sub.selectBy(lang=args.sub_stream_by_lang)
    sub.setNotNone(lang=args.sub_lang, enc=args.sub_enc, fps=args.sub_fps)

    ref = RefFile(path=args.ref)
    if args.ref_stream is not None:
        ref.select(args.ref_stream - 1)
    elif args.ref_stream_by_type or args.ref_stream_by_lang:
        ref.selectBy(type=args.ref_stream_by_type,
                     lang=args.ref_stream_by_lang)
    ref.setNotNone(lang=args.ref_lang, enc=args.ref_enc, fps=args.ref_fps)
    if args.ref_channels is not None:
        ref.channels = ChannelsMap.deserialize(args.ref_channels)

    out = args.out and OutputFile(
        path=args.out, fps=args.out_fps, enc=args.out_enc)
    task = SyncTask(sub, ref, out)
    settings().tasks = [task]
    return task
Ejemplo n.º 3
0
    def addChannel(self, channel):
        name = ChannelsMap.getChannelDescription(channel)
        box = wx.CheckBox(self.m_panelCustom, wx.ID_ANY, name)
        self.m_panelCustom.GetSizer().Add(box, 0, wx.LEFT|wx.RIGHT|wx.EXPAND, 5)
        box.Bind(wx.EVT_CHECKBOX, self.onCheckCustomChannelCheck)

        self.channels[channel] = box
        self.m_radioCustom.Enable(True)
Ejemplo n.º 4
0
    def onMenuChannelsClick(self, event, cell=None):
        ids = set()
        for cell in self.iterSelected(0, 1):
            stream = cell.item.stream()
            if cell.item.type == 'audio' and stream is not None and stream.audio is not None:
                ids |= set(ChannelsMap.layoutToIds(stream.audio.channelLayout))

        if ids:
            with ChannelsWin(self, channelIds=ids) as dlg:
                if dlg.ShowModal() == wx.ID_OK:
                    self.updateSelectedInputs(channels=dlg.GetValue())
Ejemplo n.º 5
0
    def __init__(self, parent, audio):
        super().__init__(parent)

        self.channels = {}
        for channel in ChannelsMap.layoutToIds(audio.channelLayout):
            self.addChannel(channel)

        self.update()
        self.Fit()
        self.Layout()
        self.m_panelCustom.Enable(False)
Ejemplo n.º 6
0
def parseSyncArgs(args):
    from subsync.synchro import SyncTask, SubFile, RefFile, OutputFile, ChannelsMap

    sub = SubFile(path=args.sub)
    if args.sub_stream is not None:
        sub.select(args.sub_stream - 1)
    sub.setNotNone(lang=args.sub_lang, enc=args.sub_enc, fps=args.sub_fps)

    ref = RefFile(path=args.ref)
    if args.ref_stream is not None:
        ref.select(args.ref_stream - 1)
    ref.setNotNone(lang=args.ref_lang, enc=args.ref_enc, fps=args.ref_fps)
    if args.ref_channels is not None:
        ref.channels = ChannelsMap.deserialize(args.ref_channels)

    out = args.out and OutputFile(path=args.out, fps=args.out_fps, enc=args.out_enc)

    return SyncTask(sub, ref, out)
Ejemplo n.º 7
0
    def selectStream(self, file, updateLang=False):
        self.m_listStreams.selectStream(file.no)
        self.file.no = file.no
        self.file.type = file.type

        if updateLang and file.lang:
            self.file.lang = validateLang(file.lang)
            self.m_choiceLang.SetValue(self.file.lang)

        isSubText = file.type == 'subtitle/text'
        isAudio = file.type == 'audio'

        if isAudio:
            self.selectAudioChannels(ChannelsMap.auto())
        else:
            self.m_textChannels.SetValue('')

        self.m_choiceEncoding.Enable(isSubText)
        self.m_textChannels.Enable(isAudio)
        self.m_buttonSelectChannels.Enable(isAudio)
        self.m_buttonOk.Enable(True)