Repository: ytdl-org/youtube-dl

Issue:
Unrecognized option 'x'
Two issues going on the first for a long time:

- `youtube-dl`, not able to download youtube stories anymore (a couple of months now)
- website Crunchyroll when listing with `youtube-dl -F`, `ffmpeg 5.0` throw two errors:
    - `Unrecognized option 'x'.` (which I have none in my scripts, I checked my script)
    - `WARNING: Unable to download XML: HTTP Error 404: Not Found`

I'm using Android 11, in `termux`, everything is updated!

The full output is here:

```bash
youtube-dl https://www.crunchyroll.com/blade-runner-black-lotus/episode-2-all-we-are-not-821199 -v
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-iwc', '-f', '247+251/(webm,mp4)[vcodec=vp9][height<=720]+bestaudio/best', '--external-downloader', 'aria2c', '--external-downloader-args', '-c -j 3 -x 3 -s 3 -k 1M', 'https://www.crunchyroll.com/blade-runner-black-lotus/episode-2-all-we-are-not-821199', '-v']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2021.12.17
[debug] Python version 3.10.2 (CPython) - Linux-4.4.177-22825772-aarch64-with-libc
[debug] exe versions: ffmpeg 5.0, ffprobe 5.0
[debug] Proxy map: {}
[crunchyroll] 821199: Downloading webpage
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-itIT information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-deDE information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-ruRU information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-frFR information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-ptBR information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-esLA information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-arME information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-enUS information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP-hardsub-esES information
[crunchyroll] 821199: Downloading adaptive_hls-audio-jaJP information
[crunchyroll] 821199: Downloading media info
WARNING: Unable to download XML: HTTP Error 404: Not Found
[debug] Invoking downloader on 'https://pl.crunchyroll.com/evs1/d49814b5d1b4559b4116c61340859c05/assets/55a8dac6325aec426489ec881993e62b_4219205.mp4/index-v1-a1.m3u8?Expires=1645645554&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9wbC5jcnVuY2h5cm9sbC5jb20vZXZzMS9kNDk4MTRiNWQxYjQ1NTliNDExNmM2MTM0MDg1OWMwNS9hc3NldHMvNTVhOGRhYzYzMjVhZWM0MjY0ODllYzg4MTk5M2U2MmJfKi5tM3U4PyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2NDU2NDU1NTR9fX1dfQ__&Signature=IXFWPeUoD7PnT4NYB25WCv1VRR0pkUeSH-jO72KzZIfI-fsPXhDzwHgpczqiOJMa-Iehu54Cp76Pj-mEzdMlBZ5Iy8An8RdlgJCRYyG3J5KggXHBjV5mH9BjPkVWlKiT-122z9jJPummI9j5chtISIQxTA0ESKXAWLWoEBGtGcVEantMVlIXVDdywlmLRsu1PbuEfEgOpXWLWS5TzyaKe-AJ~lqPXMzX1QqfucPA1u7NR5HIMGd2kGvMU2DrNq1wcVr1VztOF0WIpWL6ydRiQQwJDkcGYJ9lby6FQYioSa0ToHK5F121QWR6M16SQRCyqxoEOLAUWfyBzk4iWY7JxQ__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA&cdn=fy-prod'
[download] Destination: Blade Runner - Black Lotus Episodio 2 – All We Are Not-821199.mp4
[debug] ffmpeg command line: ffmpeg -y -loglevel verbose -c -j 3 -x 3 -s 3 -k 1M -headers 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3532.5 Safari/537.36
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip, deflate
Accept-Language: en-us,en;q=0.5
Cookie: __cf_bm=ydpZI69xGgP7YGCPygyTS3l77V4QInfa288FYZ3xhA8-1645472751-0-ARgz355+kKWxr9j5uhQXsPwQhX2uXoLiLMRh+lFpUJ61T+h0bQhyL+oI6xRDUWugLSxpjlNiu2gr6jzMTMazTdCYQxoCsR0xv/i1fEnmPL+w; session_id=f70c104b941ffc05cf3ac3706fe010ad; c_visitor=15aa9604-fca1-4105-a846-2782eacdbc74
' -i 'https://pl.crunchyroll.com/evs1/d49814b5d1b4559b4116c61340859c05/assets/55a8dac6325aec426489ec881993e62b_4219205.mp4/index-v1-a1.m3u8?Expires=1645645554&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9wbC5jcnVuY2h5cm9sbC5jb20vZXZzMS9kNDk4MTRiNWQxYjQ1NTliNDExNmM2MTM0MDg1OWMwNS9hc3NldHMvNTVhOGRhYzYzMjVhZWM0MjY0ODllYzg4MTk5M2U2MmJfKi5tM3U4PyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2NDU2NDU1NTR9fX1dfQ__&Signature=IXFWPeUoD7PnT4NYB25WCv1VRR0pkUeSH-jO72KzZIfI-fsPXhDzwHgpczqiOJMa-Iehu54Cp76Pj-mEzdMlBZ5Iy8An8RdlgJCRYyG3J5KggXHBjV5mH9BjPkVWlKiT-122z9jJPummI9j5chtISIQxTA0ESKXAWLWoEBGtGcVEantMVlIXVDdywlmLRsu1PbuEfEgOpXWLWS5TzyaKe-AJ~lqPXMzX1QqfucPA1u7NR5HIMGd2kGvMU2DrNq1wcVr1VztOF0WIpWL6ydRiQQwJDkcGYJ9lby6FQYioSa0ToHK5F121QWR6M16SQRCyqxoEOLAUWfyBzk4iWY7JxQ__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA&cdn=fy-prod' -c copy -f mp4 'file:Blade Runner - Black Lotus Episodio 2 – All We Are Not-821199.mp4.part'
ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with Android (7714059, based on r416183c1) clang version 12.0.8 (https://android.googlesource.com/toolchain/llvm-project c935d99d7cf2016289302412d708641d52d2f7ee)
  configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --pkg-config=/home/builder/.termux-build/_cache/android-r23b-api-24-v6/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-libaom --enable-libass --enable-libdav1d --enable-libmp3lame --enable-libfreetype --enable-libvorbis --enable-libopus --enable-librav1e --enable-libsoxr --enable-libx264 --enable-libx265 --enable-libxvid --enable-libvidstab --enable-libvpx --enable-libwebp --enable-libxml2 --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Unrecognized option 'x'.
Error splitting the argument list: Option not found


ERROR: ffmpeg exited with code 1
  File "/data/data/com.termux/files/usr/bin/youtube-dl", line 8, in <module>
    sys.exit(main())
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/__init__.py", line 475, in main
    _real_main(argv)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/__init__.py", line 465, in _real_main
    retcode = ydl.download(all_urls)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 2068, in download
    res = self.extract_info(
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 808, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 815, in wrapper
    return func(self, *args, **kwargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 847, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 881, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 1692, in process_video_result
    self.process_info(new_info)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 1976, in process_info
    success = dl(filename, info_dict)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 1915, in dl
    return fd.download(name, info)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/downloader/common.py", line 366, in download
    return self.real_download(filename, info_dict)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/downloader/external.py", line 63, in real_download
    self.report_error('%s exited with code %d' % (
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/downloader/common.py", line 165, in report_error
    self.ydl.report_error(*args, **kargs)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 628, in report_error
    self.trouble(error_message, tb)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/YoutubeDL.py", line 590, in trouble
    tb_data = traceback.format_list(traceback.extract_stack())
```


Discussion:
This isn't a full verbose log, as it doesn't show the yt-dl version or the _ffmpeg_ command line. Use `-v`.

However WFM with _ffmpeg_ 4.3.2.
> This isn't a full verbose log, as it doesn't show the yt-dl version or the _ffmpeg_ command line. Use `-v`.
> 
> However WFM with _ffmpeg_ 4.3.2.

I updated!

My previous version was `4.3.2` too, I only noticed yesterday that now it was `5.0` !

What are the complications with version `5.0`?
So for the second part of the problem (`-x`), we can see that the command line
```
ffmpeg -y -loglevel verbose -c -j 3 -x 3 -s 3 -k 1M -headers 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3532.5 Safari/537.36' -i 'https://pl.crunchyroll.com/evs1/d49814b5d1b4559b4116c61340859c05/assets/55a8dac6325aec426489ec881993e62b_4219205.mp4/index-v1-a1.m3u8?Expires=1645645554&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9wbC5jcnVuY2h5cm9sbC5jb20vZXZzMS9kNDk4MTRiNWQxYjQ1NTliNDExNmM2MTM0MDg1OWMwNS9hc3NldHMvNTVhOGRhYzYzMjVhZWM0MjY0ODllYzg4MTk5M2U2MmJfKi5tM3U4PyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2NDU2NDU1NTR9fX1dfQ__&Signature=IXFWPeUoD7PnT4NYB25WCv1VRR0pkUeSH-jO72KzZIfI-fsPXhDzwHgpczqiOJMa-Iehu54Cp76Pj-mEzdMlBZ5Iy8An8RdlgJCRYyG3J5KggXHBjV5mH9BjPkVWlKiT-122z9jJPummI9j5chtISIQxTA0ESKXAWLWoEBGtGcVEantMVlIXVDdywlmLRsu1PbuEfEgOpXWLWS5TzyaKe-AJ~lqPXMzX1QqfucPA1u7NR5HIMGd2kGvMU2DrNq1wcVr1VztOF0WIpWL6ydRiQQwJDkcGYJ9lby6FQYioSa0ToHK5F121QWR6M16SQRCyqxoEOLAUWfyBzk4iWY7JxQ__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA&cdn=fy-prod' -c copy -f mp4 'file:Blade Runner - Black Lotus Episodio 2 – All We Are Not-821199.mp4.part'
```
is not valid because you have specified **aria2c as external downloader** and the `--external-downloader-args` are for aria2c, not ffmpeg.

Apparently you get no warning when the specified external downloader isn't used, which I guess it isn't in the context of the command that you posted.

>youtube-dl, not able to download youtube stories anymore (a couple of months now)

Please open a separate issue using the Site Support Template.
> So for the second part of the problem (`-x`), we can see that the command line
> 
> ```
> ffmpeg -y -loglevel verbose -c -j 3 -x 3 -s 3 -k 1M -headers 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3532.5 Safari/537.36' -i 'https://pl.crunchyroll.com/evs1/d49814b5d1b4559b4116c61340859c05/assets/55a8dac6325aec426489ec881993e62b_4219205.mp4/index-v1-a1.m3u8?Expires=1645645554&Policy=eyJTdGF0ZW1lbnQiOlt7IlJlc291cmNlIjoiaHR0cHM6Ly9wbC5jcnVuY2h5cm9sbC5jb20vZXZzMS9kNDk4MTRiNWQxYjQ1NTliNDExNmM2MTM0MDg1OWMwNS9hc3NldHMvNTVhOGRhYzYzMjVhZWM0MjY0ODllYzg4MTk5M2U2MmJfKi5tM3U4PyoiLCJDb25kaXRpb24iOnsiRGF0ZUxlc3NUaGFuIjp7IkFXUzpFcG9jaFRpbWUiOjE2NDU2NDU1NTR9fX1dfQ__&Signature=IXFWPeUoD7PnT4NYB25WCv1VRR0pkUeSH-jO72KzZIfI-fsPXhDzwHgpczqiOJMa-Iehu54Cp76Pj-mEzdMlBZ5Iy8An8RdlgJCRYyG3J5KggXHBjV5mH9BjPkVWlKiT-122z9jJPummI9j5chtISIQxTA0ESKXAWLWoEBGtGcVEantMVlIXVDdywlmLRsu1PbuEfEgOpXWLWS5TzyaKe-AJ~lqPXMzX1QqfucPA1u7NR5HIMGd2kGvMU2DrNq1wcVr1VztOF0WIpWL6ydRiQQwJDkcGYJ9lby6FQYioSa0ToHK5F121QWR6M16SQRCyqxoEOLAUWfyBzk4iWY7JxQ__&Key-Pair-Id=APKAJMWSQ5S7ZB3MF5VA&cdn=fy-prod' -c copy -f mp4 'file:Blade Runner - Black Lotus Episodio 2 – All We Are Not-821199.mp4.part'
> ```
> 
> is not valid because you have specified **aria2c as external downloader** and the `--external-downloader-args` are for aria2c, not ffmpeg.
> 
> Apparently you get no warning when the specified external downloader isn't used, which I guess isn't in the context of the command that you posted.
> 
> > youtube-dl, not able to download youtube stories anymore (a couple of months now)
> 
> Please open a separate issue using the Site Support Template.

Yes! You're right but I don't understand, this same code with `aria2c` worked in the past. What happened? Have I mistyped something?

Here is the alias thet I created and having being using for months without problem:

    alias youtube-dl="youtube-dl -iwc -f '247+251/(webm,mp4)[vcodec=vp9][height<=720]+bestaudio/best' --external-downloader aria2c --external-downloader-args '-c -j 3 -x 3 -s 3 -k 1M'"

Resolving patch:
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -1906,8 +1906,17 @@ def ensure_dir_exists(path):
 
         if not self.params.get('skip_download', False):
             try:
+                def checked_get_suitable_downloader(info_dict, params):
+                    ed_args = params.get('external_downloader_args')
+                    dler = get_suitable_downloader(info_dict, params)
+                    if ed_args and not params.get('external_downloader_args'):
+                        # external_downloader_args was cleared because external_downloader was rejected
+                        self.report_warning('Requested external downloader cannot be used: '
+                                            'ignoring --external-downloader-args.')
+                    return dler
+
                 def dl(name, info):
-                    fd = get_suitable_downloader(info, self.params)(self, self.params)
+                    fd = checked_get_suitable_downloader(info, self.params)(self, self.params)
                     for ph in self._progress_hooks:
                         fd.add_progress_hook(ph)
                     if self.params.get('verbose'):
diff --git a/youtube_dl/downloader/__init__.py b/youtube_dl/downloader/__init__.py
--- a/youtube_dl/downloader/__init__.py
+++ b/youtube_dl/downloader/__init__.py
@@ -50,6 +50,9 @@ def _get_suitable_downloader(info_dict, params={}):
         ed = get_external_downloader(external_downloader)
         if ed.can_download(info_dict):
             return ed
+        # Avoid using unwanted args since external_downloader was rejected
+        if params.get('external_downloader_args'):
+            params['external_downloader_args'] = None
 
     protocol = info_dict['protocol']
     if protocol.startswith('m3u8') and info_dict.get('is_live'):


Test patch: