Пример #1
0
 def select_subtitle_file(self, sub_path, handle_successful_select):
     def handle_ok():
         handle_successful_select()
     def handle_err():
         app.playback_manager.stop()
     copy_subtitle_file(sub_path, self.item_info.video_path)
     self.set_item(self.item_info, handle_ok, handle_err, True)
Пример #2
0
    def select_subtitle_file(self, sub_path, handle_successful_select):
        def handle_ok():
            handle_successful_select()

        def handle_err():
            app.playback_manager.stop()

        copy_subtitle_file(sub_path, self.item_info.filename)
        self.set_item(self.item_info, handle_ok, handle_err, True)
Пример #3
0
    def test_simple_with_language(self):
        sub_path = os.path.join(self.tempdir, "otherdir/subtitle.en.srt")
        video_path = os.path.join(self.tempdir, "foo.mov")
        self.create_files([sub_path, video_path])

        ret = util.copy_subtitle_file(sub_path, video_path)
        expected = os.path.join(self.tempdir, "foo.en.srt")
        self.assert_(os.path.exists(expected))
        self.assertEqual(expected, ret)
Пример #4
0
    def test_simple_with_language(self):
        sub_path = os.path.join(self.tempdir, "otherdir/subtitle.en.srt")
        video_path = os.path.join(self.tempdir, "foo.mov")
        self.create_files([sub_path, video_path])

        ret = util.copy_subtitle_file(sub_path, video_path)
        expected = os.path.join(self.tempdir, "foo.en.srt")
        self.assert_(os.path.exists(expected))
        self.assertEqual(expected, ret)
Пример #5
0
    def test_nonlanguage(self):
        # "ex" is not a valid language code, so this should ignore
        # that part
        sub_path = os.path.join(self.tempdir, "otherdir/subtitle.ex.srt")
        video_path = os.path.join(self.tempdir, "foo.mov")
        self.create_files([sub_path, video_path])

        ret = util.copy_subtitle_file(sub_path, video_path)
        expected = os.path.join(self.tempdir, "foo.srt")
        self.assert_(os.path.exists(expected))
        self.assertEqual(expected, ret)
Пример #6
0
    def test_nonlanguage(self):
        # "ex" is not a valid language code, so this should ignore
        # that part
        sub_path = os.path.join(self.tempdir, "otherdir/subtitle.ex.srt")
        video_path = os.path.join(self.tempdir, "foo.mov")
        self.create_files([sub_path, video_path])

        ret = util.copy_subtitle_file(sub_path, video_path)
        expected = os.path.join(self.tempdir, "foo.srt")
        self.assert_(os.path.exists(expected))
        self.assertEqual(expected, ret)
Пример #7
0
 def select_subtitle_file(self, iteminfo, sub_path,
                          handle_successful_select):
     if not self.supports_subtitles:
         return
     subtitle_encoding = self.playbin.get_property("subtitle-encoding")
     def handle_ok():
         self.playbin.set_property("subtitle-encoding", subtitle_encoding)
         handle_successful_select()
     def handle_err():
         app.playback_manager.stop()
     filenames = [filename for lang, filename in self.get_subtitles().values()]
     if sub_path not in filenames:
         sub_path = copy_subtitle_file(sub_path, iteminfo.video_path)
     self.select_file(iteminfo, handle_ok, handle_err, sub_path)
Пример #8
0
    def select_subtitle_file(self, iteminfo, sub_path,
                             handle_successful_select):
        if not self.supports_subtitles:
            return
        subtitle_encoding = self.playbin.get_property("subtitle-encoding")

        def handle_ok():
            self.playbin.set_property("subtitle-encoding", subtitle_encoding)
            handle_successful_select()

        def handle_err():
            app.playback_manager.stop()
        filenames = [filename
                     for lang, filename in self.get_subtitles().values()]
        if sub_path is not None and sub_path not in filenames:
            sub_path = util.copy_subtitle_file(sub_path, iteminfo.video_path)
        self.select_file(iteminfo, handle_ok, handle_err, sub_path)
Пример #9
0
Файл: vlc.py Проект: codito/miro
    def select_subtitle_file(self, item, sub_path, handle_successful_select):
        try:
            sub_path = copy_subtitle_file(sub_path, item.video_path)
        except WindowsError:
            # FIXME - need a better way to deal with this.  when this
            # happens, then the subtitle file isn't in the right place
            # for VLC to pick it up on the next playback forcing the
            # user to select it again.
            # This is bug 12813.
            vlc_logger.exception("exception thrown when copying subtitle file")

        sub_path = sub_path.encode("utf-8")
        res = libvlc.libvlc_video_set_subtitle_file(self.media_player, ctypes.c_char_p(sub_path), self.exc.ref())
        try:
            self.exc.check()
        except VLCError, e:
            vlc_logger.warn("exception when setting subtitle track to file: %s", e)
Пример #10
0
Файл: vlc.py Проект: kmshi/miro
    def select_subtitle_file(self, item, sub_path, handle_successful_select):
        try:
            sub_path = copy_subtitle_file(sub_path, item.video_path)
        except WindowsError:
            # FIXME - need a better way to deal with this.  when this
            # happens, then the subtitle file isn't in the right place
            # for VLC to pick it up on the next playback forcing the
            # user to select it again.
            # This is bug 12813.
            vlc_logger.exception("exception thrown when copying subtitle file")

        sub_path = sub_path.encode('utf-8')
        res = libvlc.libvlc_video_set_subtitle_file(
            self.media_player, ctypes.c_char_p(sub_path), self.exc.ref())
        try:
            self.exc.check()
        except VLCError, e:
            vlc_logger.warn(
                "exception when setting subtitle track to file: %s", e)