diff --git a/src/you_get/common.py b/src/you_get/common.py index 90e628c7..1831c8cb 100755 --- a/src/you_get/common.py +++ b/src/you_get/common.py @@ -1161,6 +1161,7 @@ def script_main(script_name, download, download_playlist, **kwargs): output_dir = a elif o in ('-p', '--player'): player = a + caption = False elif o in ('-x', '--http-proxy'): proxy = a elif o in ('-y', '--extractor-proxy'): diff --git a/src/you_get/processor/ffmpeg.py b/src/you_get/processor/ffmpeg.py index 7262c462..e4ea1223 100644 --- a/src/you_get/processor/ffmpeg.py +++ b/src/you_get/processor/ffmpeg.py @@ -2,6 +2,7 @@ import os.path import subprocess +from ..util.strings import parameterize def get_usable_ffmpeg(cmd): try: @@ -53,7 +54,7 @@ def ffmpeg_concat_mp4_to_mpg(files, output='output.mpg'): concat_list = open(output + '.txt', 'w', encoding="utf-8") for file in files: if os.path.isfile(file): - concat_list.write("file '%s'\n" % file) + concat_list.write("file %s\n" % parameterize(file)) concat_list.close() params = [FFMPEG] + LOGLEVEL @@ -118,7 +119,7 @@ def ffmpeg_concat_flv_to_mp4(files, output='output.mp4'): if os.path.isfile(file): # for escaping rules, see: # https://www.ffmpeg.org/ffmpeg-utils.html#Quoting-and-escaping - concat_list.write("file '%s'\n" % file.replace("'", r"'\''")) + concat_list.write("file %s\n" % parameterize(file)) concat_list.close() params = [FFMPEG] + LOGLEVEL + ['-f', 'concat', '-y', '-i'] @@ -163,7 +164,7 @@ def ffmpeg_concat_mp4_to_mp4(files, output='output.mp4'): concat_list = open(output + '.txt', 'w', encoding="utf-8") for file in files: if os.path.isfile(file): - concat_list.write("file '%s'\n" % file) + concat_list.write("file %s\n" % parameterize(file)) concat_list.close() params = [FFMPEG] + LOGLEVEL + ['-f', 'concat', '-y', '-i'] diff --git a/src/you_get/util/strings.py b/src/you_get/util/strings.py index 7e74f35e..26d55594 100644 --- a/src/you_get/util/strings.py +++ b/src/you_get/util/strings.py @@ -1,25 +1,28 @@ try: - # py 3.4 - from html import unescape as unescape_html + # py 3.4 + from html import unescape as unescape_html except ImportError: - import re - from html.entities import entitydefs + import re + from html.entities import entitydefs - def unescape_html(string): - '''HTML entity decode''' - string = re.sub(r'&#[^;]+;', _sharp2uni, string) - string = re.sub(r'&[^;]+;', lambda m: entitydefs[m.group(0)[1:-1]], string) - return string + def unescape_html(string): + '''HTML entity decode''' + string = re.sub(r'&#[^;]+;', _sharp2uni, string) + string = re.sub(r'&[^;]+;', lambda m: entitydefs[m.group(0)[1:-1]], string) + return string - def _sharp2uni(m): - '''&#...; ==> unicode''' - s = m.group(0)[2:].rstrip(';;') - if s.startswith('x'): - return chr(int('0'+s, 16)) - else: - return chr(int(s)) + def _sharp2uni(m): + '''&#...; ==> unicode''' + s = m.group(0)[2:].rstrip(';;') + if s.startswith('x'): + return chr(int('0'+s, 16)) + else: + return chr(int(s)) from .fs import legitimize def get_filename(htmlstring): - return legitimize(unescape_html(htmlstring)) + return legitimize(unescape_html(htmlstring)) + +def parameterize(string): + return "'%s'" % string.replace("'", r"'\''") diff --git a/src/you_get/version.py b/src/you_get/version.py index a9872b96..d8db720e 100644 --- a/src/you_get/version.py +++ b/src/you_get/version.py @@ -1,4 +1,4 @@ #!/usr/bin/env python script_name = 'you-get' -__version__ = '0.4.350' +__version__ = '0.4.365'