Skip to content

Commit

Permalink
Fix YouTube authentication issue by adding cookie handling
Browse files Browse the repository at this point in the history
  • Loading branch information
PGSCOM committed Feb 2, 2025
1 parent 05c0591 commit f073aae
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1137,3 +1137,21 @@ For more information and documentation about docker, please refer to its officia
[npm-image-url]: https://nodei.co/npm/freyr.png?stars&downloads
[downloads-url]: https://npmjs.org/package/freyr
[downloads-image]: https://badgen.net/npm/dm/freyr -->

### Using YouTube Cookies for Authentication

To bypass YouTube's bot detection mechanism, you can attach your YouTube cookies for authentication. This allows you to download tracks without encountering the "Sign in to confirm you're not a bot" error.

#### Steps to use YouTube cookies:

1. Export your YouTube cookies to a file. You can use browser extensions like [EditThisCookie](https://www.editthiscookie.com/) or [Get cookies.txt](https://chrome.google.com/webstore/detail/get-cookiestxt/).

2. Save the cookies to a file, e.g., `youtube_cookies.txt`.

3. Use the `--cookies` flag to specify the path to the cookies file when running freyr.

Example command:

```bash
freyr --cookies youtube_cookies.txt [options, arguments and queries...]
```
3 changes: 2 additions & 1 deletion src/services/youtube.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,15 @@ function _getSearchArgs(artists, track, album, duration) {
* )} YouTubeSearchResult
*/

function genAsyncGetFeedsFn(url) {
function genAsyncGetFeedsFn(url, cookies) {
return () =>
youtubedl(null, {
'--': [url],
socketTimeout: 20,
cacheDir: false,
dumpSingleJson: true,
noWarnings: true,
cookies: cookies,
});
}

Expand Down

0 comments on commit f073aae

Please sign in to comment.