Skip to content

Commit

Permalink
[fix] video startTimeSecs ignored with proxy (#208)
Browse files Browse the repository at this point in the history
Account proxy response currently does not include playerConfig.

Until we rewrite the account proxy to only include the necessary and bare minimum response, this will be fixed in the client only. I don't want to take the risk of somehow breaking it as the current proxy codebase IMO is a mess.
  • Loading branch information
drunkwinter authored Aug 7, 2023
1 parent 7ecd2e1 commit a7fae37
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions src/components/unlocker/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,36 @@ function getUnlockedPlayerResponse(videoId, reason) {

const isStatusValid = Config.VALID_PLAYABILITY_STATUSES.includes(unlockedPlayerResponse?.playabilityStatus?.status);

/**
* Workaround: https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/issues/191
*
* YouTube checks if the `trackingParams` in the response matches the decoded `trackingParam` in `responseContext.mainAppWebResponseContext`.
* However, sometimes the response does not include the `trackingParam` in the `responseContext`, causing the check to fail.
*
* This workaround addresses the issue by hardcoding the `trackingParams` in the response context.
*/
if (isStatusValid && !unlockedPlayerResponse.trackingParams || !unlockedPlayerResponse.responseContext?.mainAppWebResponseContext?.trackingParam) {
unlockedPlayerResponse.trackingParams = 'CAAQu2kiEwjor8uHyOL_AhWOvd4KHavXCKw=';
unlockedPlayerResponse.responseContext = {
mainAppWebResponseContext: {
trackingParam: 'kx_fmPxhoPZRzgL8kzOwANUdQh8ZwHTREkw2UqmBAwpBYrzRgkuMsNLBwOcCE59TDtslLKPQ-SS',
},
};
if (isStatusValid) {
/**
* Workaround: https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass/issues/191
*
* YouTube checks if the `trackingParams` in the response matches the decoded `trackingParam` in `responseContext.mainAppWebResponseContext`.
* However, sometimes the response does not include the `trackingParam` in the `responseContext`, causing the check to fail.
*
* This workaround addresses the issue by hardcoding the `trackingParams` in the response context.
*/
if (!unlockedPlayerResponse.trackingParams || !unlockedPlayerResponse.responseContext?.mainAppWebResponseContext?.trackingParam) {
unlockedPlayerResponse.trackingParams = 'CAAQu2kiEwjor8uHyOL_AhWOvd4KHavXCKw=';
unlockedPlayerResponse.responseContext = {
mainAppWebResponseContext: {
trackingParam: 'kx_fmPxhoPZRzgL8kzOwANUdQh8ZwHTREkw2UqmBAwpBYrzRgkuMsNLBwOcCE59TDtslLKPQ-SS',
},
};
}

/**
* Workaround: Account proxy response currently does not include `playerConfig`
*
* Stays here until we rewrite the account proxy to only include the necessary and bare minimum response
*/
if (strategy.payload.startTimeSecs && strategy.name === 'Account Proxy') {
unlockedPlayerResponse.playerConfig = {
playbackStartConfig: {
startSeconds: strategy.payload.startTimeSecs,
},
};
}
}

return !isStatusValid;
Expand Down

0 comments on commit a7fae37

Please sign in to comment.