yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
81.88k stars 6.38k forks source link

Add Kwai support #4502

Open denaunistic opened 2 years ago

denaunistic commented 2 years ago

Checklist

Region

Mexico

Example URLs

https://s.kw.ai/p/zL3z89CB https://s.kw.ai/p/PcxCll3a https://s.kw.ai/p/bvCMz94h

Provide a description that is worded well enough to be understood

Yt-dlp can already download videos from kwai but only using the extractor for generic sites, adding a custom extractor would allow some improvements or features like downloading videos without watermark like tiktok or search, or extracting more things (disclaimer: to use kwai you need to have the app on your phone)

Provide verbose output that clearly demonstrates the problem

Complete Verbose Output

[debug] Command-line config: ['-vU', 'https://s.kw.ai/p/bvCMz94h']
[debug] Encodings: locale cp1252, fs utf-8, pref cp1252, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version 2022.07.18 [135f05e] (win32_exe)
[debug] Python 3.8.10 (CPython 64bit) - Windows-10-10.0.19044-SP0
[debug] Checking exe version: ffmpeg -bsfs
[debug] Checking exe version: ffprobe -bsfs
[debug] exe versions: ffmpeg 2022-07-14-git-882aac99d2-essentials_build-www.gyan.dev (setts), ffprobe 2022-07-14-git-882aac99d2-essentials_build-www.gyan.dev
[debug] Optional libraries: Cryptodome-3.15.0, brotli-1.0.9, certifi-2022.06.15, mutagen-1.45.1, sqlite3-2.6.0, websockets-10.3
[debug] Proxy map: {}
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: 2022.07.18, Current version: 2022.07.18
yt-dlp is up to date (2022.07.18)
[debug] [generic] Extracting URL: https://s.kw.ai/p/bvCMz94h
[generic] bvCMz94h: Downloading webpage
[redirect] Following redirect to https://m.kwai.com/photo/150001174877117/5218696167009868754?userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i%2F4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h
[debug] [generic] Extracting URL: https://m.kwai.com/photo/150001174877117/5218696167009868754?userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i%2F4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h
[generic] 5218696167009868754?userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i/4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h: Downloading webpage
WARNING: [generic] Falling back on generic information extractor.
[generic] 5218696167009868754?userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i/4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h: Extracting information
[debug] Looking for video embeds
[debug] Identified a HTML5 media
[debug] Formats sorted by: hasvid, ie_pref, lang, quality, res, fps, hdr:12(7), vcodec:vp9.2(10), acodec, filesize, fs_approx, tbr, vbr, abr, asr, proto, vext, aext, hasaud, source, id
[download] Downloading playlist: ¡Te recomiendo este video!
[generic] Playlist ¡Te recomiendo este video!: Downloading 1 videos of 1
[download] Downloading video 1 of 1
[debug] Default format spec: bestvideo*+bestaudio/best
[info] 5218696167009868754?userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i/4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h: Downloading 1 format(s): 0
[debug] Invoking http downloader on "https://g-br-cdn.kwai.net/bs2/newWatermark/f28444a5134192696bd8dedda3e86c65_en_17.mp4"
ERROR: unable to open for writing: [Errno 2] No such file or directory: '¡Te recomiendo este video! [5218696167009868754userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i_4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h].mp4.part'
Traceback (most recent call last):
  File "yt_dlp\utils.py", line 625, in sanitize_open
yt_dlp.utils.LockingUnsupportedError: File locking is not supported

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "yt_dlp\downloader\http.py", line 269, in download
  File "yt_dlp\downloader\common.py", line 224, in inner
  File "yt_dlp\downloader\common.py", line 242, in sanitize_open
  File "yt_dlp\utils.py", line 628, in sanitize_open
FileNotFoundError: [Errno 2] No such file or directory: '¡Te recomiendo este video! [5218696167009868754userId=150001174877117&photoId=5218696167009868754&cc=COPY_LINK&timestamp=1659217238074&language=es-us&share_device_id=ANDROID_0b214d14f697934b&share_uid=0&share_id=ANDROID_0b214d14f697934b_1659217233818&sharePage=photo&share_item_type=photo&share_item_info=5218696167009868754&fid=0&et=1_i_4747540155883074135_se6401&shareEnter=1&kpn=KWAI&translateKey=default_share041401&shareBucket=spa&shareBiz=photo&mcc=732&nscore=26&short_key=bvCMz94h].mp4.part'

[download] Finished downloading playlist: ¡Te recomiendo este video!

[download] Finished downloading playlist: ¡Te recomiendo este video!
pukkandan commented 2 years ago

adding a custom extractor would allow some improvements or features like downloading videos without watermark like tiktok or search, or extracting more things

None of these work just because there is a dedicated extractor. They each have to be implemented one by one. So pls elaborate on "or extracting more things". What features do you actually want?

As for the things you already specified:

downloading videos without watermark

Do you have any reason to believe videos without watermark even exist on the site?

or search

Can you give the search URL? (If there is one)

denaunistic commented 2 years ago

None of these work just because there is a dedicated extractor. They each have to be implemented one by one. So pls elaborate on "or extracting more things". What features do you actually want?

hello sorry for not elaborating in depth, by extracting more things I meant the metadata of the video, at this moment the generic extractor does not extract the title of the video, when you download it using the generic extractor it gives you a random phrase like "pls watch this video" from when you copy the link in another app like whatsapp, an option to download entire profiles may also be useful https://s.kw.ai/u/S44TC9f6

Do you have any reason to believe videos without watermark even exist on the site?

yes, it seems that the watermark is embedded in the same way that tiktok does it, since it is possible to download them without the watermark using an app (on web we have https://ssstik.io/en to download tiktoks without watermark but for kwai we need an app)

Can you give the search URL? (If there is one)

I have been looking for a way to get a url from the search but have not been able to get it.

guitiba05 commented 1 year ago

Can you please write a code to Brazil kwai?