Skip to content

Commit

Permalink
[MovieList] add option to hide underscore
Browse files Browse the repository at this point in the history
  • Loading branch information
koivo committed Dec 16, 2023
1 parent 79e8114 commit f13fe56
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/python/Components/MovieList.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
from Tools.LoadPixmap import LoadPixmap
from Tools.TextBoundary import getTextBoundarySize

AUDIO_EXTENSIONS = frozenset((".dts", ".mp3", ".wav", ".wave", ".ogg", ".flac", ".m4a", ".mp2", ".m2a", ".3gp", ".3g2", ".asf", ".wma"))
DVD_EXTENSIONS = ('.iso', '.img')
IMAGE_EXTENSIONS = frozenset((".jpg", ".png", ".gif", ".bmp"))
MOVIE_EXTENSIONS = frozenset((".mpg", ".vob", ".wav", ".m4v", ".mkv", ".avi", ".divx", ".dat", ".flv", ".mp4", ".mov", ".wmv", ".m2ts", ".webm"))
AUDIO_EXTENSIONS = frozenset((".dts", ".mp3", ".wav", ".wave", ".wv", ".oga", ".ogg", ".flac", ".m4a", ".mp2", ".m2a", ".wma", ".ac3", ".mka", ".aac", ".ape", ".alac", ".amr", ".au", ".mid"))
DVD_EXTENSIONS = frozenset((".iso", ".img", ".nrg"))
IMAGE_EXTENSIONS = frozenset((".jpg", ".png", ".gif", ".bmp", ".jpeg", ".jpe", ".svg"))
MOVIE_EXTENSIONS = frozenset((".mpg", ".vob", ".m4v", ".mkv", ".avi", ".divx", ".dat", ".flv", ".mp4", ".mov", ".wmv", ".asf", ".3gp", ".3g2", ".mpeg", ".mpe", ".rm", ".rmvb", ".ogm", ".ogv", ".m2ts", ".mts", ".webm", ".pva", ".wtv"))
KNOWN_EXTENSIONS = MOVIE_EXTENSIONS.union(IMAGE_EXTENSIONS, DVD_EXTENSIONS, AUDIO_EXTENSIONS)
RECORD_EXTENSIONS = (".ts")
RECORD_EXTENSIONS = (".ts", ".stream")

cutsParser = Struct('>QI') # big-endian, 64-bit PTS and 32-bit type

Expand Down Expand Up @@ -377,6 +377,8 @@ def buildMovieListEntry(self, serviceref, info, begin, data):
res.append(MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=_("Deleted items")))
res.append(MultiContentEntryText(pos=(width - dateSize - listEndX, textPosY), size=(dateSize, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Trashcan")))
return res
if not config.movielist.show_underscores.value:
txt = txt.replace('_', ' ').strip()
dateSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), _("Directory")).width()
res.append(MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=self.iconFolder))
res.append(MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=txt))
Expand All @@ -388,7 +390,10 @@ def buildMovieListEntry(self, serviceref, info, begin, data):
x = self.list[cur_idx] # x = ref,info,begin,...
data.len = 0 #dont recalc movielist to speedup loading the list
self.list[cur_idx] = (x[0], x[1], x[2], data) #update entry in list... so next time we don't need to recalc
data.txt = info.getName(serviceref)
if config.movielist.show_underscores.value:
data.txt = info.getName(serviceref)
else:
data.txt = info.getName(serviceref).replace('_', ' ').strip()
if config.movielist.hide_extensions.value:
fileName, fileExtension = os_path.splitext(data.txt)
if fileExtension in KNOWN_EXTENSIONS:
Expand Down
2 changes: 2 additions & 0 deletions lib/python/Screens/MovieSelection.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
config.movielist.root = ConfigSelection(default="/media", choices=["/", "/media", "/media/hdd", "/media/hdd/movie", "/media/usb", "/media/usb/movie"])
config.movielist.hide_extensions = ConfigYesNo(default=False)
config.movielist.stop_service = ConfigYesNo(default=True)
config.movielist.show_underscores = ConfigYesNo(default=False)

userDefinedButtons = None
last_selected_dest = []
Expand Down Expand Up @@ -274,6 +275,7 @@ def __init__(self, session, args=0):
configList.append(getConfigListEntry(_("Play audio in background"), config.movielist.play_audio_internal, _("Keeps MovieList open whilst playing audio files.")))
configList.append(getConfigListEntry(_("Root directory"), config.movielist.root, _("Sets the root folder of movie list, to remove the '..' from benign shown in that folder.")))
configList.append(getConfigListEntry(_("Hide known extensions"), config.movielist.hide_extensions, _("Allows you to hide the extensions of known file types.")))
configList.append(getConfigListEntry(_("Show underscore characters"), config.movielist.show_underscores, _("Set to 'Disabled' to replace underscore characters, '_', in file and directory names with spaces.")))
configList.append(getConfigListEntry(_("Show live tv when movie stopped"), config.movielist.show_live_tv_in_movielist, _("When set the PIG will return to live after a movie has stopped playing.")))
for btn in (('red', _('Red')), ('green', _('Green')), ('yellow', _('Yellow')), ('blue', _('Blue')), ('redlong', _('Red long')), ('greenlong', _('Green long')), ('yellowlong', _('Yellow long')), ('bluelong', _('Blue long')), ('TV', _('TV')), ('Radio', _('Radio')), ('Text', _('Text')), ('F1', _('F1')), ('F2', _('F2')), ('F3', _('F3'))):
configList.append(getConfigListEntry(_("Button") + " " + _(btn[1]), userDefinedButtons[btn[0]], _("Allows you to setup the button to do what you choose.")))
Expand Down

0 comments on commit f13fe56

Please sign in to comment.