YoutubeExplode icon indicating copy to clipboard operation
YoutubeExplode copied to clipboard

Failed to extract cipher manifest

Open mikethea1 opened this issue 1 year ago • 17 comments

Version

6.5.4

Platform

.NET 8 / Windows 11

Steps to reproduce

var client = new YoutubeClient();
VideoId id = new("https://www.youtube.com/watch?v=UFdO3wodIJk");
try { await client.Videos.GetAsync(id); }
catch (Exception ex) { Console.WriteLine(ex); } // VideoUnavailableException
try { var cc = await client.Videos.ClosedCaptions.GetManifestAsync(id); }
catch (Exception ex) { Console.WriteLine(ex); } // VideoUnavailableException
try { var streams = await client.Videos.Streams.GetManifestAsync(id); }
catch (Exception ex) { Console.WriteLine(ex); } // YouTubeExplodeException "Failed to extract the cipher manifest."

Details

Thanks for building and maintaining this great library!

While the library works great for most videos I try it with, this particular one fails reliably for me even though on the front-end I don't see anything special about it.

Checklist

  • [x] I have looked through existing issues to make sure that this bug has not been reported before
  • [x] I have provided a descriptive title for this issue
  • [x] I have made sure that this bug is reproducible on the latest version of the package
  • [x] I have provided all the information needed to reproduce this bug as efficiently as possible
  • [ ] I have sponsored this project
  • [ ] I have not read any of the above and just checked all the boxes to submit the issue

mikethea1 avatar Aug 11 '25 20:08 mikethea1

same error, any fix?

Image

wy6688 avatar Aug 14 '25 10:08 wy6688

Worked fine for me until all of a sudden throws this exception, same code same everything, did you find any solution?

Kexnuf avatar Sep 24 '25 19:09 Kexnuf

Could this be related to https://github.com/yt-dlp/yt-dlp/issues/14404 ?

mikethea1 avatar Sep 25 '25 17:09 mikethea1

Could this be related to yt-dlp/yt-dlp#14404 ?

Possibly, but at least for me, installing Deno solved nothing.

Sumanuil avatar Oct 05 '25 05:10 Sumanuil

@Sumanuil installing deno wouldn't help since that solution is specific to yt-dlp. I was more wondering whether YoutubeExplode was running into any of the same problems that were motivating yt-dlp to install deno.

mikethea1 avatar Oct 06 '25 15:10 mikethea1

YouTube changed their player source code format in a very significant way, basically making the current parsing logic that YTE employs obsolete. I spent some time analyzing the new format, and it seems that it would be quite difficult to adapt.

Note that the cipher route is only used as a fallback when the main route fails. Currently, the main route does not work because of #853 -- and the fallback route does not work because of the above-mentioned updates. If/when #853 is fixed, this issue will become much less impactful, as the fallback won't be needed for 99% of videos.

Tyrrrz avatar Oct 11 '25 20:10 Tyrrrz

Could this be related to yt-dlp/yt-dlp#14404 ?

It is related, yes. YTE doesn't use an interpreter though, but the underlying issue is the same.

Tyrrrz avatar Oct 11 '25 20:10 Tyrrrz

@Tyrrrz sooo any idea how to fix this? :) Where should we look for a possible places to make changes? PlayerResponse class?

ZmorzynskiK avatar Oct 15 '25 07:10 ZmorzynskiK

I just remove these apps and changed to https://github.com/yt-dlp/yt-dlp, replace the ps script with my modification

YT_downloader_by_PowerShell.zip

and generate "www.youtube.com_cookies.txt" file using MS/Chrome Plugin

  1. install https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc
  2. open a youtube video and login your youtube account.
  3. In MS Edge ?Chrome Plugin Bar, open the Get coodkies Plugin
Image 4 . export as button to save the cookies

This Solution is very reliable and never let me disappointed,

The full folder zip

wy6688 avatar Oct 16 '25 00:10 wy6688

@Tyrrrz sooo any idea how to fix this? :) Where should we look for a possible places to make changes? PlayerResponse class?

It's PlayerSource: https://github.com/Tyrrrz/YoutubeExplode/blob/master/YoutubeExplode/Bridge/PlayerSource.cs

Basically, all the assumptions made about the player source code are now obsolete. You can debug through the CipherManifest property to find that the regular expressions no longer work. And if you look at the full source code, you'll see that its format has changed significantly.

Tyrrrz avatar Oct 20 '25 12:10 Tyrrrz

I have tried to do some simple analyze about new js content. It seems Youtube has encode basic methods like .split and .join into elements in an array. For a specific video, it holds an array named R, and here's the relationship:

R[0] = "fromCharCode" R[7] = "length" R[8] = "call" R[15] = "match" R[19] = "forEach" R[21] = "slice" R[22] = "splice" R[25] = "push" R[26] = "split" R[29] = "indexOf" R[31] = "reverse" R[33] = "unshift" R[38] = "assign" R[41] = "startsWith" R[59] = "toString" R[69] = "join" R[77] = "replace" R[81] = "pop"

I haven't done deeper search, but I think this is why the old regex failed. Hoping someone can use this to better the software's robustness.

DreamRuthenium avatar May 04 '26 05:05 DreamRuthenium

I have added some better handling of errors around the cipher manifest fallback code.

The reason is that I believe that some of these errors aren't cipher errors and more to do with Point Origin Tokens, which is working against us. The cipher issue does exist, but so does the POT issue.

I've done experiments with "other" clients as well and it's the same. investigating more now

LuckyNoS7evin avatar May 26 '26 17:05 LuckyNoS7evin

Still having this issue, seems to be related to videos marked as "kids" or "family" content, in my case. The "Oculus Quest 3" user agent is not working with this kind of videos and yt-dlp has the same problem, I tried a bunch of other user agents but no one is working. EDIT: yt-dlp can actually solve the issue if you have Deno installed

93Omar avatar May 29 '26 19:05 93Omar

I'm having this issue too, for example with video https://www.youtube.com/watch?v=nQuzyJ-C1Fc Any news? Thank you!

mugnap avatar Jun 01 '26 15:06 mugnap

Issue fixed in this PR https://github.com/Tyrrrz/YoutubeExplode/pull/965

mysteryx93 avatar Aug 19 '26 01:08 mysteryx93

Still seeing Failed to extract the cipher manifest on a build that already includes #965, so I'm adding a concrete case in case it helps.

Build: prime up to c703892 (#978), which includes ea791ab (#965). Plus one local commit that only adds a flag to skip per-stream probing. .NET 10, Linux. Seen 2026-11-23, three attempts over ~10 minutes, all failing the same way.

Repro: my service calls StreamClient.GetManifestAsync for the video. On a livestream that had ended about 8.5 hours earlier it throws YoutubeExplodeException: Failed to extract the cipher manifest. within about 0.5 s. Other videos work with the same build, including a livestream from the same channel that ended a week earlier.

Difference between the two livestreams (watch page):

  • The failing one has playabilityStatus.reason: "This live event has ended.", playableInEmbed: false, no approxDurationMs on its formats, and 13 format entries.
  • The working one has no "has ended" reason, has approxDurationMs, and 8 format entries. It ended a week earlier.

So the processing state of the stream seems to decide whether the cipher fallback is needed.

Cause of the exception: PlayerSource.CipherManifest returns null. I ran its regexes against the player script in use (/s/player/6b3d0364/player_ias.vflset/en_US/base.js):

  • (?:signatureTimestamp|sts):(\d{5}) matches (20774).
  • The cipher callsite regex [$_\w]+=function\([$_\w]+\){([$_\w]+)=\1\.split\(['"]{2}\);.*?return \1\.join\(['"]{2}\)} matches nothing. The script has no function of that shape: all 14 .split("") calls are generic helpers and the 3 .reverse() calls are unrelated.

This looks like what Tyrrrz described in Oct 2025, that all assumptions about the player source are obsolete. #965 fixed the common path, but the cipher fallback is still broken for streams that need it.

ykne avatar Nov 23 '26 03:11 ykne

  • The failing one has playabilityStatus.reason: "This live event has ended.", playableInEmbed: false, no approxDurationMs on its formats, and 13 format entries.

I wonder if, besides having playabilityStatus.reason, it was also marked as unplayable? And whether those format entries are still related to the livestream.

What is happening, I believe, is that a finished livestream video needs some time before YouTube converts its progressive streams into regular video streams. During that time, you can still watch the video on YouTube as a livestream (albeit finished), but YoutubeExplode does not support it.

Tyrrrz avatar Nov 24 '26 14:11 Tyrrrz