From 4ab20803e0edbabdff945f37111ab2ff58e36a23 Mon Sep 17 00:00:00 2001 From: Yuanle Song Date: Tue, 17 Sep 2024 22:34:25 +0800 Subject: [PATCH] v0.11.1 bugfix: when on windows, properly delete temp dir when temp dir filename contains special characters. previously filename is not properly escaped when delete using shell command rd/remove-dir. --- m3u8downloader/__init__.py | 2 +- m3u8downloader/main.py | 3 ++- operational | 24 +++++++++++++++++++----- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/m3u8downloader/__init__.py b/m3u8downloader/__init__.py index ae6db5f..fee46bd 100644 --- a/m3u8downloader/__init__.py +++ b/m3u8downloader/__init__.py @@ -1 +1 @@ -__version__ = "0.11.0" +__version__ = "0.11.1" diff --git a/m3u8downloader/main.py b/m3u8downloader/main.py index 683c745..d04f648 100644 --- a/m3u8downloader/main.py +++ b/m3u8downloader/main.py @@ -17,6 +17,7 @@ import sys import os import os.path import subprocess +import shutil import re from urllib.parse import urljoin, urlparse from collections import OrderedDict @@ -294,7 +295,7 @@ class M3u8Downloader: if os.path.exists("/bin/rm"): subprocess.run(["/bin/rm", "-rf", self.tempdir]) elif os.path.exists("C:/Windows/SysWOW64/cmd.exe"): - subprocess.run(["rd", "/s", "/q", self.tempdir], shell=True) + shutil.rmtree(self.tempdir) logger.info("temp files removed") def mirror_url_resource(self, remote_file_url): diff --git a/operational b/operational index 9c24e35..f3dfc82 100644 --- a/operational +++ b/operational @@ -51,6 +51,10 @@ to handle it on ryzen5. * current :entry: ** +** 2020-05-08 add travis CI for this project. +- add travis CI to run unit tests on linux and windows. +- add badge in README.rst +* done :entry: ** 2024-09-17 shell command escape issue when filename contains special characters - bug report by Steven Van Ingelgem. #+begin_src python @@ -59,11 +63,21 @@ to handle it on ryzen5. shutil.rmtree(self.tempdir) logger.info("temp files removed") #+end_src -- -** 2020-05-08 add travis CI for this project. -- add travis CI to run unit tests on linux and windows. -- add badge in README.rst -* done :entry: +- check all shell invoke. + M-x grep + git grep --full-name -n -F 'subprocess.' +- it's because I have shell=True there. + all other invokes should be fine. + subprocess.run(["rd", "/s", "/q", self.tempdir], shell=True) + + well, mabye just use shutil.rmtree for windows. + + is there shell escape function for windows cmd shell? + + shlex — Simple lexical analysis — Python 3.11.2 documentation + https://localdocs.emacsos.com/python3/library/shlex.html#module-shlex + that is for unix shell. not cmd shell. + ** 2024-09-17 when it convert my file into mp4 i lose the sound of the video could you please add feature to be able to get the ts/m3u8 file without convert -- GitLab