41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import unittest
|
|
from pathlib import Path
|
|
|
|
from rei_toolbox.dubstrip import has_audio_in_lang, make_dubstrip_command
|
|
|
|
|
|
class DubstripTestCase(unittest.TestCase):
|
|
def test_lang(self) -> None:
|
|
meta = {
|
|
"streams": [
|
|
{"index": 0, "codec_type": "video"},
|
|
{"index": 1, "codec_type": "audio", "tags": {"language": "eng"}},
|
|
{"index": 2, "codec_type": "audio", "tags": {"language": "jpn"}},
|
|
{"index": 3, "codec_type": "subtitle", "tags": {"language": "jpn"}},
|
|
{"index": 4, "codec_type": "subtitle", "tags": {"language": "und"}},
|
|
]
|
|
}
|
|
self.assertTrue(has_audio_in_lang(meta, "jpn"))
|
|
self.assertTrue(has_audio_in_lang(meta, "eng"))
|
|
self.assertFalse(has_audio_in_lang(meta, "fra"))
|
|
|
|
fin = Path("a.mkv")
|
|
fout = Path("b.mkv")
|
|
|
|
self.assertEqual(
|
|
make_dubstrip_command(fin, fout, meta, "jpn"),
|
|
[
|
|
"ffmpeg",
|
|
"-nostdin",
|
|
"-i",
|
|
"file:a.mkv",
|
|
"-map",
|
|
"0",
|
|
"-map",
|
|
"-0:1",
|
|
"-c",
|
|
"copy",
|
|
"file:b.mkv",
|
|
],
|
|
)
|