From b00868aea591c3f67b21efc17ff83c3874bc5f8f Mon Sep 17 00:00:00 2001 From: A S Lewis Date: Thu, 5 Dec 2024 10:17:37 +0000 Subject: [PATCH] Fix yt-dlp install issues on MSWin --- README.rst | 6 +- VERSION | 2 +- nsis/tartube_install_64bit.nsi | 6 +- pack/bin/no_download/tartube | 4 +- pack/bin/pkg/tartube | 4 +- pack/bin/strict/tartube | 4 +- pack/tartube.1 | 2 +- setup.py | 2 +- tartube/tartube | 4 +- tartube/updates.py | 119 ++++++++++++++------------------- 10 files changed, 69 insertions(+), 84 deletions(-) diff --git a/README.rst b/README.rst index 2bc1bf6..ae7eb38 100644 --- a/README.rst +++ b/README.rst @@ -44,13 +44,13 @@ Problems can be reported at `our GitHub page `__): -- `MS Windows (64-bit) installer `__, `MS Windows (64-bit) and FFmpeg installer `__ and `portable edition `__ from Sourceforge +- `MS Windows (64-bit) installer `__, `MS Windows (64-bit) and FFmpeg installer `__ and `portable edition `__ from Sourceforge - Tartube is no longer supported on older versions of MS Windows - see `7.24 Doesn't work on 32-bit Windows / Windows 7 / Windows 8`_ - `DEB package (for Debian-based distros, e.g. Ubuntu, Linux Mint) `__ from Sourceforge - `RPM package (for RHEL-based distros, e.g. Fedora) `__ from Sourceforge diff --git a/VERSION b/VERSION index f2fffa7..7a76137 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.5.059 +2.5.062 diff --git a/nsis/tartube_install_64bit.nsi b/nsis/tartube_install_64bit.nsi index d8cf896..3fc1903 100644 --- a/nsis/tartube_install_64bit.nsi +++ b/nsis/tartube_install_64bit.nsi @@ -1,4 +1,4 @@ -# Tartube v2.5.059 installer script for MS Windows +# Tartube v2.5.062 installer script for MS Windows # # Copyright (C) 2019-2024 A S Lewis # @@ -294,7 +294,7 @@ ;Name and file Name "Tartube" - OutFile "install-tartube-2.5.059-64bit.exe" + OutFile "install-tartube-2.5.062-64bit.exe" ;Default installation folder InstallDir "$LOCALAPPDATA\Tartube" @@ -397,7 +397,7 @@ Section "Tartube" SecClient # "Publisher" "A S Lewis" # WriteRegStr HKLM \ # "Software\Microsoft\Windows\CurrentVersion\Uninstall\Tartube" \ -# "DisplayVersion" "2.5.059" +# "DisplayVersion" "2.5.062" # Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" diff --git a/pack/bin/no_download/tartube b/pack/bin/no_download/tartube index 66aab19..1bb99aa 100644 --- a/pack/bin/no_download/tartube +++ b/pack/bin/no_download/tartube @@ -44,8 +44,8 @@ import mainapp # 'Global' variables __packagename__ = 'tartube' -__version__ = '2.5.059' -__date__ = '26 Nov 2024' +__version__ = '2.5.062' +__date__ = '5 Dec 2024' __copyright__ = 'Copyright \xa9 2019-2024 A S Lewis' __license__ = """ Copyright \xa9 2019-2024 A S Lewis. diff --git a/pack/bin/pkg/tartube b/pack/bin/pkg/tartube index 9b8cb28..f12d74f 100644 --- a/pack/bin/pkg/tartube +++ b/pack/bin/pkg/tartube @@ -44,8 +44,8 @@ import mainapp # 'Global' variables __packagename__ = 'tartube' -__version__ = '2.5.059' -__date__ = '26 Nov 2024' +__version__ = '2.5.062' +__date__ = '5 Dec 2024' __copyright__ = 'Copyright \xa9 2019-2024 A S Lewis' __license__ = """ Copyright \xa9 2019-2024 A S Lewis. diff --git a/pack/bin/strict/tartube b/pack/bin/strict/tartube index 73cea2d..5761424 100644 --- a/pack/bin/strict/tartube +++ b/pack/bin/strict/tartube @@ -44,8 +44,8 @@ import mainapp # 'Global' variables __packagename__ = 'tartube' -__version__ = '2.5.059' -__date__ = '26 Nov 2024' +__version__ = '2.5.062' +__date__ = '5 Dec 2024' __copyright__ = 'Copyright \xa9 2019-2024 A S Lewis' __license__ = """ Copyright \xa9 2019-2024 A S Lewis. diff --git a/pack/tartube.1 b/pack/tartube.1 index 35db209..b494602 100644 --- a/pack/tartube.1 +++ b/pack/tartube.1 @@ -1,4 +1,4 @@ -.TH man 1 "26 Nov 2024" "2.5.059" "tartube man page" +.TH man 1 "5 Dec 2024" "2.5.062" "tartube man page" .SH NAME tartube \- GUI front-end for youtube-dl and yt-dlp .SH SYNOPSIS diff --git a/setup.py b/setup.py index 755c3dd..b84eb91 100644 --- a/setup.py +++ b/setup.py @@ -164,7 +164,7 @@ # Setup setuptools.setup( name = 'tartube', - version = '2.5.059', + version = '2.5.062', description = 'GUI front-end for youtube-dl and yt-dlp', long_description = long_description, long_description_content_type = 'text/plain', diff --git a/tartube/tartube b/tartube/tartube index 4381b15..d803c2a 100644 --- a/tartube/tartube +++ b/tartube/tartube @@ -44,8 +44,8 @@ import mainapp # 'Global' variables __packagename__ = 'tartube' -__version__ = '2.5.059' -__date__ = '26 Nov 2024' +__version__ = '2.5.062' +__date__ = '5 Dec 2024' __copyright__ = 'Copyright \xa9 2019-2024 A S Lewis' __license__ = """ Copyright \xa9 2019-2024 A S Lewis. diff --git a/tartube/updates.py b/tartube/updates.py index a7d35cb..2cd435d 100644 --- a/tartube/updates.py +++ b/tartube/updates.py @@ -611,87 +611,82 @@ def install_ytdl(self): # Rather than trying to distinguish the portable and non-portable # versions, just do this for all MS Windows users with default # settings - uninstall_fail_flag = False if os.name == 'nt' and self.wiz_win_obj is None and ( ytdl_update_current == 'ytdl_update_win_64' \ or ytdl_update_current == 'ytdl_update_win_64_no_dependencies' \ or ytdl_update_current == 'ytdl_update_win_32' \ or ytdl_update_current == 'ytdl_update_win_32_no_dependencies' ): - if not self.uninstall_ytdl(downloader, ytdl_update_current): - uninstall_fail_flag = True + self.uninstall_ytdl(downloader, ytdl_update_current) - if not uninstall_fail_flag: - - # Prepare a system command... - if os.name == 'nt' \ - and ytdl_update_current == 'ytdl_update_custom_path' \ - and re.search(r'\.exe$', self.app_obj.ytdl_path): - # Special case: on MS Windows, a custom path may point at an - # .exe, therefore 'python3' must be removed from the system - # command (we can't run 'python3.exe youtube-dl.exe' or - # anything like that) - cmd_list = [self.app_obj.ytdl_path, '-U'] + # Prepare a system command... + if os.name == 'nt' \ + and ytdl_update_current == 'ytdl_update_custom_path' \ + and re.search(r'\.exe$', self.app_obj.ytdl_path): + # Special case: on MS Windows, a custom path may point at an .exe, + # therefore 'python3' must be removed from the system command (we + # can't run 'python3.exe youtube-dl.exe' or anything like that) + cmd_list = [self.app_obj.ytdl_path, '-U'] - else: - cmd_list = self.app_obj.ytdl_update_dict[ytdl_update_current] + else: + cmd_list = self.app_obj.ytdl_update_dict[ytdl_update_current] - mod_list = [] - for arg in cmd_list: + mod_list = [] + for arg in cmd_list: - # Substitute in the fork, if one is specified - arg = self.app_obj.check_downloader(arg, self.wiz_win_obj) - # Convert a path beginning with ~ (not on MS Windows) - if os.name != 'nt': - arg = re.sub(r'^\~', os.path.expanduser('~'), arg) + # Substitute in the fork, if one is specified + arg = self.app_obj.check_downloader(arg, self.wiz_win_obj) + # Convert a path beginning with ~ (not on MS Windows) + if os.name != 'nt': + arg = re.sub(r'^\~', os.path.expanduser('~'), arg) - mod_list.append(arg) + mod_list.append(arg) - # ...and display it in the Output tab (if required) - self.install_ytdl_write_output( - ' '.join(mod_list), - True, # A system command, not a message - ) + # ...and display it in the Output tab (if required) + self.install_ytdl_write_output( + ' '.join(mod_list), + True, # A system command, not a message + ) - # Create a new child process using that command... - self.create_child_process(mod_list) - # ...and set up the PipeReader objects to read from the child - # process STDOUT and STDERR - if self.child_process is not None: - self.stdout_reader.attach_fh(self.child_process.stdout) - self.stderr_reader.attach_fh(self.child_process.stderr) + # Create a new child process using that command... + self.create_child_process(mod_list) + # ...and set up the PipeReader objects to read from the child process + # STDOUT and STDERR + if self.child_process is not None: + self.stdout_reader.attach_fh(self.child_process.stdout) + self.stderr_reader.attach_fh(self.child_process.stderr) - while self.is_child_process_alive(): + while self.is_child_process_alive(): - # Pause a moment between each iteration of the loop (we don't - # want to hog system resources) - time.sleep(self.sleep_time) + # Pause a moment between each iteration of the loop (we don't want + # to hog system resources) + time.sleep(self.sleep_time) - # Read from the child process STDOUT and STDERR, in the correct - # order, until there is nothing left to read - while self.read_ytdl_child_process(downloader): - pass + # Read from the child process STDOUT and STDERR, in the correct + # order, until there is nothing left to read + while self.read_ytdl_child_process(downloader): + pass - # (Generate our own error messages for debugging purposes, in - # certain situations) - if self.child_process is None: + # (Generate our own error messages for debugging purposes, in certain + # situations) + if self.child_process is None: - msg = _('Update did not start') + msg = _('Update did not start') - self.stderr_list.append(msg) - self.install_ytdl_write_output(msg) + self.stderr_list.append(msg) + self.install_ytdl_write_output(msg) - elif self.child_process.returncode > 0: + elif self.child_process.returncode > 0: - msg = _('Child process exited with non-zero code: {}').format( - self.child_process.returncode, - ) + msg = _('Child process exited with non-zero code: {}').format( + self.child_process.returncode, + ) - self.stderr_list.append(msg) - self.install_ytdl_write_output(msg) + self.stderr_list.append(msg) + self.install_ytdl_write_output(msg) # Operation complete. self.success_flag is checked by - # mainapp.TartubeApp.update_manager_finished + # mainapp.TartubeApp.update_manager_finished() if not self.stderr_list: self.success_flag = True @@ -722,10 +717,6 @@ def uninstall_ytdl(self, downloader, ytdl_update_current): mainapp.TartubeApp.ytdl_update_current, or an overriding value chosen by the calling function - Return values: - - True on success, False on failure - """ # Prepare a system command... @@ -782,12 +773,6 @@ def uninstall_ytdl(self, downloader, ytdl_update_current): self.stderr_list.append(msg) self.install_ytdl_write_output(msg) - # Uninstall complete - if self.stderr_list: - return False - else: - return True - def install_ytdl_write_output(self, msg, system_cmd_flag=False):