我如何将 cookie 传递给 yt-dlp

DDD
发布: 2024-08-19 11:30:20
原创
763 人浏览过

This article explains how to pass cookies to yt-dlp, a command-line utility for downloading videos from YouTube and other video-sharing websites. Cookies are small text files that store user information, such as login credentials and preferences. Pas

我如何将 cookie 传递给 yt-dlp

How can I pass cookies to yt-dlp?

To pass cookies to yt-dlp, you can use the --cookies option. This option takes a file path as its argument, and the file should contain the cookies in the following format:

<code><domain>\t<cookie name>\t<expiration date>\t<value></code>
登录后复制
登录后复制
登录后复制

For example, to pass the SID and SSID cookies from the youtube.com domain, you would create a file named cookies.txt with the following contents:

<code>youtube.com\tSID\t1640000000\tAQAS...
youtube.com\tSSID\t1640000000\tAQAS...</code>
登录后复制
登录后复制

Once you have created the cookies file, you can pass it to yt-dlp using the --cookies option. For example, the following command would download the video with the URL https://www.example.com/video.mp4 and pass the cookies from the cookies.txt file:

<code>yt-dlp --cookies cookies.txt https://www.example.com/video.mp4</code>
登录后复制

What is the process for passing cookies to yt-dlp?

The process for passing cookies to yt-dlp is as follows:

  1. Create a file containing the cookies in the following format:
<code><domain>\t<cookie name>\t<expiration date>\t<value></code>
登录后复制
登录后复制
登录后复制
  1. Save the file with a .txt extension, such as cookies.txt.
  2. Pass the cookies file to yt-dlp using the --cookies option.
  3. Run yt-dlp to download the video or audio file.

How do I pass cookies to yt-dlp?

To pass cookies to yt-dlp, use the --cookies option followed by the path to the cookies file. The cookies file should contain the cookies in the following format:

<code><domain>\t<cookie name>\t<expiration date>\t<value></code>
登录后复制
登录后复制
登录后复制

For example, to pass the SID and SSID cookies from the youtube.com domain to yt-dlp, create a file named cookies.txt with the following contents:

<code>youtube.com\tSID\t1640000000\tAQAS...
youtube.com\tSSID\t1640000000\tAQAS...</code>
登录后复制
登录后复制

Then, run yt-dlp with the following command:

<code>yt-dlp --cookies cookies.txt https://www.youtube.com/watch?v=dQw4w9WgXcQ</code>
登录后复制

以上是我如何将 cookie 传递给 yt-dlp的详细内容。更多信息请关注PHP中文网其他相关文章!

来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板