Tag Archives: youtube-dl

Linux youtube downloader errors

first, let's see the youtube-dl error
youtube-dl https://www.youtube.com/playlist?list=PLEmVsSEEP5HDTSik5ZSyOWz0qsS1tPos_
[youtube:playlist] PLEmVsSEEP5HDTSik5ZSyOWz0qsS1tPos_: Downloading webpage
[download] Downloading playlist: cantece pt copii in germana
[youtube:playlist] playlist cantece pt copii in germana: Downloading 6 videos
[download] Downloading video 1 of 6
[youtube] dtZ7U7csvcw: Downloading webpage
[youtube] dtZ7U7csvcw: Downloading video info webpage
[youtube] dtZ7U7csvcw: Extracting video information
[youtube] dtZ7U7csvcw: Downloading MPD manifest
Traceback (most recent call last):
  File "/usr/bin/youtube-dl", line 6, in 
    youtube_dl.main()
  File "/usr/lib/python2.7/dist-packages/youtube_dl/__init__.py", line 444, in main
    _real_main(argv)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/__init__.py", line 434, in _real_main
    retcode = ydl.download(all_urls)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1791, in download
    url, force_generic_extractor=self.params.get('force_generic_extractor', False))
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 705, in extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 866, in process_ie_result
    extra_info=extra)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 758, in process_ie_result
    extra_info=extra_info)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 694, in extract_info
    ie_result = ie.extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 357, in extract
    return self._real_extract(url)
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/youtube.py", line 1671, in _real_extract
    formats_dict=self._formats):
  File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 1547, in _extract_mpd_formats
    compat_etree_fromstring(mpd.encode('utf-8')), mpd_id, mpd_base_url,
  File "/usr/lib/python2.7/dist-packages/youtube_dl/compat.py", line 2526, in compat_etree_fromstring
    doc = _XML(text, parser=etree.XMLParser(target=_TreeBuilder(element_factory=_element_factory)))
  File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 1476, in __init__
    "No module named expat; use SimpleXMLTreeBuilder instead"
ImportError: No module named expat; use SimpleXMLTreeBuilder instead

some checks
Search for pyexpat*.so:
ll /usr/lib/python2.7/lib-dynload/pyexpat*
-rw-r--r-- 1 root root 68K Nov 19 11:35 /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
Check for it's dependencies:
ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
	linux-vdso.so.1 =>  (0x00007fff059fd000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fac3b8c7000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fac3b4fe000)
	libexpat.so.1 => /u01/app/oracle/product/12.1.0/dbhome_1/lib/libexpat.so.1 (0x00007fac3b2da000)
	/lib64/ld-linux-x86-64.so.2 (0x000055c542d57000)
When strange dependencies are listed (e.g. libexpat.so.1 from oracle) try to fix them.
Check for LD_LIBRARY_PATH value:
echo $LD_LIBRARY_PATH
/u01/app/oracle/product/12.1.0/dbhome_1/lib:/lib:/usr/lib:/usr/lib64

possible solution
Solution (for me this will probably break oracle):
unset LD_LIBRARY_PATH
ldd /usr/lib/python2.7/lib-dynload/pyexpat.x86_64-linux-gnu.so
	linux-vdso.so.1 =>  (0x00007ffd1ff13000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fe242eba000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe242af1000)
	libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fe2428c7000)
	/lib64/ld-linux-x86-64.so.2 (0x0000558368063000)
And now youtube-dl works again!
Of course you'll have to set LD_LIBRARY_PATH when running oracle.