Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YouTube Shorts / GDPR consent #543

Closed
TheDelta opened this issue Jun 24, 2024 · 1 comment
Closed

YouTube Shorts / GDPR consent #543

TheDelta opened this issue Jun 24, 2024 · 1 comment

Comments

@TheDelta
Copy link

In #326 the consent issue was described for YouTube (and Google Maps). and the fix is to fetch it over the API (requires token) or to use a custom plugin.

The latest version of iframely doesn't handle unfortunately YouTube shorts url.
My fix is to simply add the shorts url to the regex as well:

custom_plugins/domains/youtube.video.js

import * as plugin from './../../plugins/domains/youtube.com/youtube.video.js';

const fixedPlugin = { ...plugin.default };

fixedPlugin.re = [
    ...fixedPlugin.re,
    // add missing shorts support:
    /^https?:\/\/(?:www\.)?youtube\.com\/shorts\/([\w-]+)/i,
];

export default fixedPlugin;

but this will embed the short as a youtube video.

The other way to make it work (and display as embedded short) would be to set the cookie consent with the request.
Based on: https://stackoverflow.com/a/74132453/5152479

a new custom plugin custom_plugins/domains/youtube.short.js

// https://stackoverflow.com/a/74132453/5152479
const CONSENT_ACCEPT = 'CAISNQgDEitib3FfaWRlbnRpdHlmcm9udGVuZHVpc2VydmVyXzIwMjMwODI5LjA3X3AxGgJlbiACGgYIgLC_pwY';
const CONSENT_REJECT = 'CAESEwgDEgk0ODE3Nzk3MjQaAmVuIAEaBgiA_LyaBg';

export default {
    re: /^https?:\/\/(?:www\.)?youtube\.com\/shorts\/([\w-]+)/i,
    getData: function(options) {
        options.jar = { SOCS: CONSENT_REJECT };
    },
};

This will make the request with accepted consent and does the fetch like with an US based server and proper short embed.
But once youtube changes the format, this will most likely break.

Would be great to have some discussion and maybe a better solutions by the developers.

iparamonau added a commit that referenced this issue Jun 24, 2024
Please configure  `fix_shorts_in_eu: true` - see example config file.

cc #543
@iparamonau
Copy link
Member

Please see the suggested fix and activate it via fix_shorts_in_eu: true flag in your config file for YouTube.

YouTube video player and YouTube player for shorts is the same thing. It seems they style they differently via CSS based on the aspect-ratio.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants