From a4a12514f332db1f83ad9d66192f207a479744d2 Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Tue, 29 Oct 2024 14:26:40 +0100 Subject: [PATCH 1/4] fix non-existent paths --- CHANGELOG | 6 ++++-- debian/changelog | 5 ++++- videomass/vdms_sys/configurator.py | 15 ++++++--------- videomass/vdms_sys/settings_manager.py | 17 ++++++++++++++++- 4 files changed, 30 insertions(+), 13 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 60f6fb49..6c29df5a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ License: GPL3 Change Log: +------------------------------------+ -Mon, 28 Oct 2024 V.5.0.21 +Tue, 29 Oct 2024 V.5.0.21 * Update French language (thanks to Phil Aug). * Update Spanish language (thanks to katnatek). @@ -19,7 +19,9 @@ Mon, 28 Oct 2024 V.5.0.21 * Fixed some broken link. * Fixed an issue when restoring the configuration directory, which copied unnecessary files and directories. - + * Fixed issue with using physically non-existent and access-denied output + paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably + lead to an application reset. +------------------------------------+ Sun, 28 July 2024 V.5.0.20 diff --git a/debian/changelog b/debian/changelog index 161b2432..a2653476 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,8 +10,11 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium * Fixed some broken link. * Fixed an issue when restoring the configuration directory, which copied unnecessary files and directories. + * Fixed issue with using physically non-existent and access-denied output + paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably + lead to an application reset. - -- Gianluca Pernigotto Mon, 28 Oct 2024 00:00:00 +0200 + -- Gianluca Pernigotto Tue, 29 Oct 2024 14:00:00 +0200 videomass (5.0.20-1) UNRELEASED; urgency=medium diff --git a/videomass/vdms_sys/configurator.py b/videomass/vdms_sys/configurator.py index b999fecd..0e975860 100644 --- a/videomass/vdms_sys/configurator.py +++ b/videomass/vdms_sys/configurator.py @@ -49,13 +49,8 @@ def create_dirs(dirname, fconf): if not os.path.exists(dirname): try: os.makedirs(dirname, mode=0o777) - except FileExistsError as err: + except Exception as err: return {'ERROR': err} - except OSError as err: - os.remove(fconf) # force to restart on deleting - thismsg = ('Please try restarting Videomass to ' - 'restore default settings now.') - return {'ERROR': f'{err}\n{thismsg}'} return {'R': None} @@ -111,6 +106,11 @@ def get_options(fileconf, makeportable): conf.write_options() data = {'R': conf.read_options()} + diff = conf.default_outputdirs(**data['R']) + if diff != data['R']: + conf.write_options(**diff) # restore default outputdirs + data = {'R': conf.read_options()} + return data @@ -159,9 +159,6 @@ def portable_paths(portdirname): cache_dir = os.path.join(dir_conf, 'cache') # updates executable trash_dir = os.path.join(dir_conf, "Trash") - if not os.path.exists(dir_conf): - os.makedirs(dir_conf, mode=0o777) - return file_conf, dir_conf, log_dir, cache_dir, trash_dir diff --git a/videomass/vdms_sys/settings_manager.py b/videomass/vdms_sys/settings_manager.py index 482e87bb..4e8ed3f9 100644 --- a/videomass/vdms_sys/settings_manager.py +++ b/videomass/vdms_sys/settings_manager.py @@ -6,7 +6,7 @@ Author: Gianluca Pernigotto Copyleft - 2024 Gianluca Pernigotto license: GPL3 -Rev: Apr.09.2024 +Rev: Oct.29.2024 Code checker: flake8, pylint This file is part of Videomass. @@ -338,3 +338,18 @@ def read_options(self): return None return options + + def default_outputdirs(self, **options): + """ + Restores default output paths. + This method is needed to set the values ​​of the `outputdir` + and `ydlp-outputdir` keys set to physically non-existent + filesystem paths (such as pendrives, hard-drives, etc.). + Returns a dictionary object. + """ + if not os.path.exists(os.path.dirname(options['outputdir'])): + options['outputdir'] = f"{os.path.expanduser('~')}" + if not os.path.exists(os.path.dirname(options['ydlp-outputdir'])): + options['ydlp-outputdir'] = f"{os.path.expanduser('~')}" + + return options From 241f39bff61d11cbe897d999c1e12b1fa5965bff Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Tue, 29 Oct 2024 14:35:44 +0100 Subject: [PATCH 2/4] fix pylint E2515 --- videomass/vdms_sys/settings_manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/videomass/vdms_sys/settings_manager.py b/videomass/vdms_sys/settings_manager.py index 4e8ed3f9..74f9ef2e 100644 --- a/videomass/vdms_sys/settings_manager.py +++ b/videomass/vdms_sys/settings_manager.py @@ -342,7 +342,7 @@ def read_options(self): def default_outputdirs(self, **options): """ Restores default output paths. - This method is needed to set the values ​​of the `outputdir` + This method is needed to set the values of the `outputdir` and `ydlp-outputdir` keys set to physically non-existent filesystem paths (such as pendrives, hard-drives, etc.). Returns a dictionary object. From e80626dbf92aa66850a9a663a199eeb5f39d4f34 Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Wed, 30 Oct 2024 00:23:33 +0100 Subject: [PATCH 3/4] bugfix --- CHANGELOG | 10 ++++++++-- debian/changelog | 12 +++++++++--- videomass/vdms_main/main_frame.py | 6 +++--- videomass/vdms_sys/configurator.py | 23 +++++++++++++++++------ videomass/vdms_sys/settings_manager.py | 14 ++++++++------ 5 files changed, 45 insertions(+), 20 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6c29df5a..0396bdc7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,7 +7,7 @@ License: GPL3 Change Log: +------------------------------------+ -Tue, 29 Oct 2024 V.5.0.21 +Wed, 30 Oct 2024 V.5.0.21 * Update French language (thanks to Phil Aug). * Update Spanish language (thanks to katnatek). @@ -21,7 +21,13 @@ Tue, 29 Oct 2024 V.5.0.21 unnecessary files and directories. * Fixed issue with using physically non-existent and access-denied output paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably - lead to an application reset. + lead to an application reset during startup (Very annoying). + * Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'? + during presets download operation. + * Changed: Unlike portable mode, In installed mode output directories are no + longer recreated if they do not exist. + * Changed the names of the default output directories when using the + application in portable mode. +------------------------------------+ Sun, 28 July 2024 V.5.0.20 diff --git a/debian/changelog b/debian/changelog index a2653476..8c406d9d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,9 +12,15 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium unnecessary files and directories. * Fixed issue with using physically non-existent and access-denied output paths (e.g. removing USB sticks, hard drives, etc.) which would inevitably - lead to an application reset. - - -- Gianluca Pernigotto Tue, 29 Oct 2024 14:00:00 +0200 + lead to an application reset during startup (Very annoying). + * Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'? + during presets download operation. + * Changed: Unlike portable mode, In installed mode output directories are no + longer recreated if they do not exist. + * Changed the names of the default output directories when using the + application in portable mode. + + -- Gianluca Pernigotto Wed, 30 Oct 2024 00:00:00 +0200 videomass (5.0.20-1) UNRELEASED; urgency=medium diff --git a/videomass/vdms_main/main_frame.py b/videomass/vdms_main/main_frame.py index 8e06f265..bd87ffc5 100644 --- a/videomass/vdms_main/main_frame.py +++ b/videomass/vdms_main/main_frame.py @@ -6,7 +6,7 @@ Author: Gianluca Pernigotto Copyleft - 2024 Gianluca Pernigotto license: GPL3 -Rev: June.24.2024 +Rev: Oct.29.2024 Code checker: flake8, pylint This file is part of Videomass. @@ -867,8 +867,8 @@ def prst_downloader(self, event): tarball = io_tools.get_github_releases(url, "tarball_url") if tarball[0] in ['request error:', 'response error:']: - wx.MessageBox(f"{tarbal[0]} {tarbal[1]}", - f"{tarbal[0]}", wx.ICON_ERROR, self) + wx.MessageBox(f"{tarball[0]} {tarball[1]}", + f"{tarball[0]}", wx.ICON_ERROR, self) return name = f"Videomass-presets-{tarball[0].split('/v')[-1]}.tar.gz" diff --git a/videomass/vdms_sys/configurator.py b/videomass/vdms_sys/configurator.py index 0e975860..e9cfc8ff 100644 --- a/videomass/vdms_sys/configurator.py +++ b/videomass/vdms_sys/configurator.py @@ -55,10 +55,11 @@ def create_dirs(dirname, fconf): return {'R': None} -def restore_dirconf(dirconf, srcdata): +def restore_dirconf(dirconf, srcdata, portable): """ - check existence of configuration directory - with possibility of restore. + This function is responsible for restoring the + configuration directory if it is missing and + populating it with its essential files. Returns dict: key == 'R' key == ERROR (if any errors) @@ -74,6 +75,17 @@ def restore_dirconf(dirconf, srcdata): if drest: return {'ERROR': drest} + if portable: + transoutdir = os.path.join(dirconf, "Media", "Transcoding") + dwlddir = os.path.join(dirconf, "Media", "Downloads") + try: + if not os.path.exists(transoutdir): + os.makedirs(transoutdir, mode=0o777) + if not os.path.exists(dwlddir): + os.makedirs(dwlddir, mode=0o777) + except Exception as err: + return {'ERROR': err} + return {'R': None} @@ -108,7 +120,7 @@ def get_options(fileconf, makeportable): diff = conf.default_outputdirs(**data['R']) if diff != data['R']: - conf.write_options(**diff) # restore default outputdirs + conf.write_options(**diff) # write default outputdirs data = {'R': conf.read_options()} return data @@ -304,6 +316,7 @@ def get_configuration(self): # checks configuration directory ckdconf = restore_dirconf(self.dataloc['confdir'], self.dataloc['srcdata'], + self.makeportable, ) if ckdconf.get('ERROR'): return ckdconf @@ -317,8 +330,6 @@ def get_configuration(self): # create the required directories if not existing requiredirs = (os.path.join(self.dataloc['cachedir'], 'tmp'), self.dataloc['logdir'], - userconf['outputdir'], - userconf['ydlp-outputdir'], self.dataloc['trashdir_default'] ) if not userconf['trashdir_loc'].strip(): diff --git a/videomass/vdms_sys/settings_manager.py b/videomass/vdms_sys/settings_manager.py index 74f9ef2e..9ba916f6 100644 --- a/videomass/vdms_sys/settings_manager.py +++ b/videomass/vdms_sys/settings_manager.py @@ -301,10 +301,12 @@ def __init__(self, filename, makeportable=None): self.filename = filename if makeportable: - path = os.path.join(makeportable, "My_Files") - outputdir = os.path.relpath(path) - ConfigManager.DEFAULT_OPTIONS['outputdir'] = outputdir - ConfigManager.DEFAULT_OPTIONS['ydlp-outputdir'] = outputdir + trscodepath = os.path.join(makeportable, "Media", "Transcoding") + dwldpath = os.path.join(makeportable, "Media", "Downloads") + trscodedir = os.path.relpath(trscodepath) + dwlddir = os.path.relpath(dwldpath) + ConfigManager.DEFAULT_OPTIONS['outputdir'] = trscodedir + ConfigManager.DEFAULT_OPTIONS['ydlp-outputdir'] = dwlddir def write_options(self, **options): """ @@ -347,9 +349,9 @@ def default_outputdirs(self, **options): filesystem paths (such as pendrives, hard-drives, etc.). Returns a dictionary object. """ - if not os.path.exists(os.path.dirname(options['outputdir'])): + if not os.path.exists(options['outputdir']): options['outputdir'] = f"{os.path.expanduser('~')}" - if not os.path.exists(os.path.dirname(options['ydlp-outputdir'])): + if not os.path.exists(options['ydlp-outputdir']): options['ydlp-outputdir'] = f"{os.path.expanduser('~')}" return options From a37a47353ab1d93d27110dcd3aa5d5f956b513d2 Mon Sep 17 00:00:00 2001 From: Gianluca Pernigotto Date: Wed, 30 Oct 2024 13:25:36 +0100 Subject: [PATCH 4/4] yt-dlp[default] --- CHANGELOG | 4 ++-- INSTALL | 9 +++++++-- debian/changelog | 4 ++-- requirements/requirements-linux.txt | 2 +- requirements/requirements-windows.txt | 2 +- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0396bdc7..6afa576d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,9 +25,9 @@ Wed, 30 Oct 2024 V.5.0.21 * Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'? during presets download operation. * Changed: Unlike portable mode, In installed mode output directories are no - longer recreated if they do not exist. + longer automatically recreated if they do not exist. * Changed the names of the default output directories when using the - application in portable mode. + application in portable mode (see Media/Transcoding + Media/Downloads). +------------------------------------+ Sun, 28 July 2024 V.5.0.20 diff --git a/INSTALL b/INSTALL index bbc9b967..33e542a9 100644 --- a/INSTALL +++ b/INSTALL @@ -93,7 +93,10 @@ Installing on Linux/FreeBSD: python3 -m pip install videomass Optionally install yt-dlp: - python3 -m pip install yt-dlp + please read this before installing yt-dlp: https://github.com/yt-dlp/yt-dlp/pull/11255 + + python3 -m pip install "yt-dlp[default]" + Installing on Windows and MacOs: @@ -110,7 +113,9 @@ Installing on Windows and MacOs: python3 -m pip install videomass Optionally install yt-dlp: - python3 -m pip install yt-dlp + please read this before installing yt-dlp: https://github.com/yt-dlp/yt-dlp/pull/11255 + + python3 -m pip install "yt-dlp[default]" To Update on Windows, MacOs, Linux, FreeBSD: diff --git a/debian/changelog b/debian/changelog index 8c406d9d..f675f525 100644 --- a/debian/changelog +++ b/debian/changelog @@ -16,9 +16,9 @@ videomass (5.0.21-1) UNRELEASED; urgency=medium * Fixed NameError: name 'tarbal' is not defined. Did you mean: 'tarball'? during presets download operation. * Changed: Unlike portable mode, In installed mode output directories are no - longer recreated if they do not exist. + longer automatically recreated if they do not exist. * Changed the names of the default output directories when using the - application in portable mode. + application in portable mode (see Media/Transcoding + Media/Downloads). -- Gianluca Pernigotto Wed, 30 Oct 2024 00:00:00 +0200 diff --git a/requirements/requirements-linux.txt b/requirements/requirements-linux.txt index 9a8a18c7..3f5250a5 100644 --- a/requirements/requirements-linux.txt +++ b/requirements/requirements-linux.txt @@ -1,5 +1,5 @@ videomass -yt-dlp +yt-dlp[default] hatchling build wheel diff --git a/requirements/requirements-windows.txt b/requirements/requirements-windows.txt index fb3703ff..bf9f6b2a 100644 --- a/requirements/requirements-windows.txt +++ b/requirements/requirements-windows.txt @@ -5,7 +5,7 @@ pypubsub six wxpython requests -yt-dlp +yt-dlp[default] # Requirements for Windows