ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
132.18k stars 10.02k forks source link

TikTok Error #30445

Open UnixCro opened 2 years ago

UnixCro commented 2 years ago
~/files/Tiktok $ youtube-dl --verbose https://vm.tiktok.com/ZM8Kf5sqY/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['--verbose', 'https://vm.tiktok.com/ZM8Kf5sqY/']
[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.1 (CPython) - Linux-4.14.87+-armv8l-with-libc
[debug] exe versions: ffmpeg 4.4.1, ffprobe 4.4.1
[debug] Proxy map: {}
[generic] ZM8Kf5sqY: Requesting header
[redirect] Following redirect to https://www.tiktok.com/@elektrokurzschluss/video/7042661503035526406?_d=secCgwIARCbDRjEFSACKAESPgo8Py%2BWHrKmQ8k916xwcDBjDWlzWI3uyW3d84Z2wwgZBwA6dO9mCxynY1r%2BVVrZKE4rOvdHB5S4NR7cJt0sGgA%3D&language=de&preview_pb=0&sec_user_id=MS4wLjABAAAAwkLYynP5HnlwKtmz4yBJ6cCjmTTfkDfupLpi6htOTGYDBqQw03ruYBKCSem4mD-x&share_app_id=1233&share_item_id=7042661503035526406&share_link_id=5391ca27-a864-405f-84d3-8fec6466ad88&source=h5_m&timestamp=1640954903&u_code=de7i359c99ad13&user_id=6866698620222948358&utm_campaign=client_share&utm_medium=android&utm_source=copy&_r=1
[TikTok] Setting up session
[TikTok] 7042661503035526406: Downloading webpage
ERROR: Unable to extract data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
Traceback (most recent call last):
  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 836, in __extract_info
    ie_result = ie.extract(url)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 534, in extract
    ie_result = self._real_extract(url)
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/extractor/tiktok.py", line 110, in _real_extract
    page_props = self._parse_json(self._search_regex(
  File "/data/data/com.termux/files/usr/lib/python3.10/site-packages/youtube_dl/extractor/common.py", line 1012, in _search_regex
    raise RegexNotFoundError('Unable to extract %s' % _name)
youtube_dl.utils.RegexNotFoundError: Unable to extract data; please report this issue on https://yt-dl.org/bug . Make sure you are using the latest version; see  https://yt-dl.org/update  on how to update. Be sure to call youtube-dl with the --verbose flag and include its complete output.
dirkf commented 2 years ago

Duplicate of #30251, where a patch that appears to work is provided.

UnixCro commented 2 years ago

No thx

p1ratrulezzz commented 2 years ago

Applied patch from #30251 (comment) and it worked for me.

Tutorial:

  1. Save patch as /tmp/tiktok.patch. (or download attachment). Open it and change first lines as following:
    --- old/youtube-dl/youtube_dl/extractor/tiktok.py
    +++ new/youtube-dl/youtube_dl/extractor/tiktok.py

to

--- old/extractor/tiktok.py
+++ new/extractor/tiktok.py
  1. if you use venv - activate it by
    source venv/bin/activate
  2. Find out site-packages folder location by running
    venv_dir=$(python3 -c "import sysconfig; print(sysconfig.get_path('purelib'))")
    echo $venv_dir
  3. change dir to site-packages and apply the patch
    cd $venv_dir/youtube_dl
    patch -p1 < /tmp/tiktok.patch
  4. If using a venv, run
    deactivate
  5. It should work now.
dirkf commented 2 years ago

Save patch as /tmp/tiktok.patch. (or download attachment). Open it and change first lines as following:

Or use patch -p2 ... later on (step 4). -p says how many of the leading directories in the patch script to strip when finding the file to be patched, which obviously depends on where the patch is relative to the package being patched.

Obviously the procedure doesn't apply if the installation is a single file or not a site-packages installation, but that should encourage people to pip their installation.

p1ratrulezzz commented 2 years ago

-p says how many of the leading directories in the patch script to strip

Thanks, for some reason I didn't even try to check manual, just was using p1 as I got used to many years ago. Now I knew something new!

Yes, I believe people mostly use pip to install this package, as I'm not a python dev I even searched if there is a way to say pip to apply patch but haven't found anything. I hope the solution is temporary unless it will be fixed someday...

I also checked solution with go script by @89z and it also works, I was able to build it under ubuntu 20.04 and go 1.17 but it lacks of some nice paratemeters like "set output filename" or download using shortcut as youtube-dl does.

p1ratrulezzz commented 2 years ago

wow thanks! I'll use it in bot, I was about to add this output argument by myself but you did it so fast and this is very nice!

UnixCro commented 2 years ago

I LOVE YOU DUDE. IT WORKED YOU A GENIUS BRO @p1ratrulezzz

UnixCro commented 2 years ago

Good Morning,

after the patch everything went as usual, but this morning I noticed that youtube-dl was getting problems, regardless of which Tiktok video. It stops at Session and doesn't do anything anymore.

youtube-dl -v https://vm.tiktok.com/ZM8o81GJ6/
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', 'https://vm.tiktok.com/ZM8o81GJ6/']
[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.1 (CPython) - Linux-4.14.87+-armv8l-with-libc
[debug] exe versions: ffmpeg 4.4.1, ffprobe 4.4.1
[debug] Proxy map: {}
[generic] ZM8o81GJ6: Requesting header
[redirect] Following redirect to https://www.tiktok.com/@tal_dahan_98/video/7024900237076483329?_d=secCgwIARCbDRjEFSACKAESPgo8YrY3EKdj1E6gxwNUHIw1x1pyS1GuRWH%2B7yBvtTroH1PZUFsEa6LLl7vAD373o7DlJP0ex0LcUx3xx5RIGgA%3D&checksum=86caa7b721ef97df33eae17f7050f10a2df3b3563b7dbad85fc24c6108f71d6d&language=de&preview_pb=0&sec_user_id=MS4wLjABAAAAwkLYynP5HnlwKtmz4yBJ6cCjmTTfkDfupLpi6htOTGYDBqQw03ruYBKCSem4mD-x&share_app_id=1233&share_item_id=7024900237076483329&share_link_id=B9546FAF-D8BE-478F-B1D6-A82C83A8DCD6&source=h5_m&timestamp=1641475816&tt_from=copy&u_code=de7i359c99ad13&user_id=6866698620222948358&utm_campaign=client_share&utm_medium=ios&utm_source=copy&_r=1
[TikTok] Setting up session

Has anyone noticed the same bug?

dirkf commented 2 years ago

See #30251.

UnixCro commented 2 years ago

Thank you @dirkf. But how exactly do I install the new version now?

dirkf commented 2 years ago

You have to replace the extractor module with the one from the PR. See https://github.com/ytdl-org/youtube-dl/pull/30479#issuecomment-1007495127.

UnixCro commented 2 years ago

Same mistake. It gets stuck after the setting up session.

pip install --force-reinstall -U git+https://github.com/ytdl-org/youtube-dl@refs/pull/30184/merge 
dirkf commented 2 years ago

... (substitute PR number 30479 and file youtube_dl/extractor/tiktok.py as appropriate) ...

You installed PR #30184 instead of #30479!

UnixCro commented 2 years ago

Ah nice 😂😂. It worked @dirkf. Hopefully 100 years with you.

pip install --force-reinstall -U git+https://github.com/ytdl-org/youtube-dl@refs/pull/30479/merge
VasiliPupkin256 commented 2 years ago

@dirkf this PR doesn't work anymore. "Could not send HEAD request to https://www.tiktok.com/....: The read operation timed out"

dirkf commented 2 years ago

Indeed, that's why it hasn't been merged: #30538.