Skip to content

Commit a8445d5

Browse files
committed
* Fixing missing undefined option for audio tracks (thanks to danielly2020)
1 parent 3a0e737 commit a8445d5

File tree

8 files changed

+41
-26
lines changed

8 files changed

+41
-26
lines changed

CHANGES

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Fixing #654 Failed to import attachment due to bad mime type gathering (thanks to larsk2)
66
* Fixing #659 current profile panel won't open (thanks to danielly2020)
7+
* Fixing missing undefined option for audio tracks (thanks to danielly2020)
78
* Fixing missing unittests for common encoder options
89
* Fixing some extra spaces in commands
910
* Fixing logs were showing red for info commands

fastflix/audio_processing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from copy import deepcopy
33

4-
from iso639 import Lang
54
from iso639.exceptions import InvalidLanguageValue
65
from box import Box
76

87
from fastflix.models.profiles import AudioMatch, MatchType, MatchItem
8+
from fastflix.language import Language
99

1010

1111
def apply_audio_filters(
@@ -55,7 +55,7 @@ def apply_audio_filters(
5555
subset_tracks = []
5656
for track in original_tracks:
5757
try:
58-
if Lang(audio_match.match_input) == Lang(track.tags["language"]):
58+
if Language(audio_match.match_input) == Language(track.tags["language"]):
5959
subset_tracks.append((track, audio_match))
6060
except (InvalidLanguageValue, KeyError):
6161
pass

fastflix/language.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from pathlib import Path
1212
import importlib.resources
1313

14+
from iso639 import Lang
1415
from platformdirs import user_data_dir
1516
from box import Box
1617

@@ -19,7 +20,7 @@
1920
language_file = str(lf.resolve())
2021

2122

22-
__all__ = ["t", "translate"]
23+
__all__ = ["t", "translate", "Language"]
2324

2425
config = os.getenv("FF_CONFIG")
2526
if config:
@@ -58,3 +59,18 @@ def translate(text):
5859

5960

6061
t = translate
62+
63+
64+
class Language(Lang):
65+
_data = Lang._data.copy()
66+
_data["name"]["Undefined"] = {
67+
"pt1": "un",
68+
"pt2b": "und",
69+
"pt2t": "und",
70+
"pt3": "und",
71+
"pt5": "",
72+
"name": "Undefined",
73+
}
74+
_data["pt2b"]["und"] = {"name": "Undefined", "pt1": "un", "pt2t": "und", "pt3": "und", "pt5": ""}
75+
_data["pt3"]["und"] = {"name": "Undefined", "pt2b": "und", "pt1": "un", "pt2t": "und", "pt5": ""}
76+
_data["pt1"]["un"] = {"name": "Undefined", "pt2b": "und", "pt2t": "und", "pt3": "und", "pt5": ""}

fastflix/widgets/panels/audio_panel.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
import logging
44

55
from box import Box
6-
from iso639 import Lang, iter_langs
6+
from iso639 import iter_langs
77
from iso639.exceptions import InvalidLanguageValue
88
from PySide6 import QtGui, QtWidgets
99

10-
from fastflix.language import t
10+
from fastflix.language import t, Language
1111
from fastflix.models.encode import AudioTrack
1212
from fastflix.models.profiles import Profile
1313
from fastflix.models.fastflix_app import FastFlixApp
@@ -18,7 +18,7 @@
1818
from fastflix.widgets.windows.audio_conversion import AudioConversion
1919
from fastflix.widgets.windows.disposition import Disposition
2020

21-
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1]
21+
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1] + ["Undefined"]
2222
logger = logging.getLogger("fastflix")
2323

2424
disposition_options = [
@@ -84,7 +84,7 @@ def __init__(
8484
self.widgets.language.setMaximumWidth(150)
8585
if audio_track.language:
8686
try:
87-
lang = Lang(audio_track.language).name
87+
lang = Language(audio_track.language).name
8888
except InvalidLanguageValue:
8989
pass
9090
else:
@@ -215,7 +215,7 @@ def enabled(self):
215215
def language(self) -> str:
216216
if self.widgets.language.currentIndex() == 0:
217217
return ""
218-
return Lang(self.widgets.language.currentText()).pt2b
218+
return Language(self.widgets.language.currentText()).pt2b
219219

220220
@property
221221
def title(self) -> str:

fastflix/widgets/panels/queue_panel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import logging
77
import os
88
from pathlib import Path
9-
10-
# import tracemalloc
119
import gc
1210

1311
from platformdirs import user_data_dir

fastflix/widgets/panels/subtitle_panel.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from typing import Union
44

55
from box import Box
6-
from iso639 import Lang, iter_langs
6+
from iso639 import iter_langs
77
from iso639.exceptions import InvalidLanguageValue
88
from PySide6 import QtCore, QtGui, QtWidgets
99

10-
from fastflix.language import t
10+
from fastflix.language import t, Language
1111
from fastflix.models.encode import SubtitleTrack
1212
from fastflix.models.fastflix_app import FastFlixApp
1313
from fastflix.resources import loading_movie, get_icon
@@ -40,7 +40,7 @@
4040
"xsub": "text",
4141
}
4242

43-
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1]
43+
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1] + ["Undefined"]
4444

4545
# TODO give warning about exact time needed for text based subtitles
4646

@@ -177,7 +177,7 @@ def init_language(self, sub_track: SubtitleTrack):
177177
self.widgets.language.addItems(language_list)
178178
self.widgets.language.setMaximumWidth(110)
179179
try:
180-
self.widgets.language.setCurrentIndex(language_list.index(Lang(sub_track.language).name))
180+
self.widgets.language.setCurrentIndex(language_list.index(Language(sub_track.language).name))
181181
except Exception:
182182
self.widgets.language.setCurrentIndex(language_list.index("English"))
183183
self.widgets.language.currentIndexChanged.connect(self.page_update)
@@ -212,7 +212,7 @@ def enabled(self):
212212

213213
@property
214214
def language(self):
215-
return Lang(self.widgets.language.currentText()).pt2b
215+
return Language(self.widgets.language.currentText()).pt2b
216216

217217
@property
218218
def burn_in(self):
@@ -295,11 +295,11 @@ def lang_match(self, track: Union[Subtitle, dict], ignore_first=False):
295295
self._first_selected = True
296296
return True
297297
try:
298-
track_lang = Lang(language)
298+
track_lang = Language(language)
299299
except InvalidLanguageValue:
300300
return True
301301
else:
302-
if Lang(self.app.fastflix.config.opt("subtitle_language")) == track_lang:
302+
if Language(self.app.fastflix.config.opt("subtitle_language")) == track_lang:
303303
if (
304304
not ignore_first
305305
and self.app.fastflix.config.opt("subtitle_select_first_matching")

fastflix/widgets/settings.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
import shutil
55
from pathlib import Path
66

7-
from iso639 import Lang, iter_langs
7+
from iso639 import iter_langs
88
from iso639.exceptions import InvalidLanguageValue
99
from PySide6 import QtCore, QtGui, QtWidgets
1010

1111
from fastflix.exceptions import FastFlixInternalException
12-
from fastflix.language import t
12+
from fastflix.language import t, Language
1313
from fastflix.models.fastflix_app import FastFlixApp
1414
from fastflix.shared import error_message, link
1515

@@ -91,7 +91,7 @@ def __init__(self, app: FastFlixApp, main, *args, **kwargs):
9191
# index = known_language_list.index("Chinese (Traditional)")
9292

9393
else:
94-
index = known_language_list.index(Lang(self.app.fastflix.config.language).name)
94+
index = known_language_list.index(Language(self.app.fastflix.config.language).name)
9595
except (IndexError, InvalidLanguageValue):
9696
logger.exception(f"{t('Could not find language for')} {self.app.fastflix.config.language}")
9797
index = known_language_list.index("English")
@@ -320,7 +320,7 @@ def save(self):
320320
# self.app.fastflix.config.language = "cht"
321321

322322
else:
323-
self.app.fastflix.config.language = Lang(self.language_combo.currentText()).pt3
323+
self.app.fastflix.config.language = Language(self.language_combo.currentText()).pt3
324324
except InvalidLanguageValue:
325325
error_message(
326326
f"{t('Could not set language to')} {self.language_combo.currentText()}\n {t('Please report this issue')}"

fastflix/widgets/windows/profile_window.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@
33
import logging
44

55
from box import Box
6-
from iso639 import Lang, iter_langs
6+
from iso639 import iter_langs
77
from PySide6 import QtCore, QtWidgets
88

99
from fastflix.exceptions import FastFlixError
1010
from fastflix.flix import ffmpeg_valid_color_primaries, ffmpeg_valid_color_transfers, ffmpeg_valid_color_space
11-
from fastflix.language import t
11+
from fastflix.language import t, Language
1212
from fastflix.widgets.panels.abstract_list import FlixList
1313
from fastflix.models.fastflix_app import FastFlixApp
1414
from fastflix.models.encode import x265Settings, setting_types
1515
from fastflix.models.profiles import AudioMatch, Profile, MatchItem, MatchType, AdvancedOptions
1616
from fastflix.shared import error_message
1717
from fastflix.encoders.common.audio import channel_list
1818

19-
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1]
19+
language_list = [v.name for v in iter_langs() if v.pt2b and v.pt1] + ["Undefined"]
2020

2121
logger = logging.getLogger("fastflix")
2222

@@ -143,7 +143,7 @@ def get_settings(self):
143143
elif match_item_enum == MatchItem.TRACK:
144144
match_input_value = self.match_input.currentText()
145145
elif match_item_enum == MatchItem.LANGUAGE:
146-
match_input_value = Lang(self.match_input.currentText()).pt2b
146+
match_input_value = Language(self.match_input.currentText()).pt2b
147147
elif match_item_enum == MatchItem.CHANNELS:
148148
match_input_value = str(self.match_input.currentIndex())
149149
else:
@@ -495,7 +495,7 @@ def save(self):
495495
subtitle_enabled = False
496496
elif self.subtitle_select.sub_language.currentIndex() != 0:
497497
subtitle_select_preferred_language = True
498-
sub_lang = Lang(self.subtitle_select.sub_language.currentText()).pt2b
498+
sub_lang = Language(self.subtitle_select.sub_language.currentText()).pt2b
499499

500500
self.advanced_options.color_space = (
501501
None

0 commit comments

Comments
 (0)