【问题标题】:How to identify YouTube Shorts video with head request in EUHow to identify YouTube Shorts video with head request in EU
【发布时间】:2022-12-28 02:05:18
【问题描述】:

I'm using YouTube Data API V3 to extract info about my YouTube channel. I'd like to identify Shorts so I can analyze them separately. I've found in another discussion a solution which is to do a head request at "https://www.youtube.com/shorts/videoId" as it should redirect the URL if it's not a short and it should not if it is one.

Unfortunately, regardless of if I'm passing a Short or not I get <Response [302]>. I suspect this is because I'm in the EU and if I try to access the URL without being logged-in I'm redirected to the cookie consent page: https://consent.youtube.com/m?continue=https%3A%2F%2Fwww.youtube.com%2Fshorts%2F-2mHZGXtXSo%3Fcbrd%3D1&gl=DE&m=0&pc=yt&uxe=eomty&hl=en&src=1

Is that the case? If so, is there any workaround? (aside from a VPN)

Thanks in advance, I would have gladly commented on the other discussion instead of creating another topic but I'm a simple lurker with no reputation so I can't comment

Here is the original conversation: how do i get youtube shorts from youtube api data v3

【问题讨论】:

  • You can try to read the hashtags of the video and if there is a #shorts then that would mean that it's a short
  • Thanks I'll do that for now. Apparently it is no longer mandatory to add Short in the tags though, so it might not work 100% of the time but it's still much better than nothing
  • By EU you mean Europe, correct? If so, it looks like a weird behavior as I am also in Europe and not experiencing this issue. If you are still encountering this issue and interested to solve this problem, don't hesitate to contact me to try to debug things together.

标签: python youtube


【解决方案1】:

Ran into this as well trying to identify shorts. Turns out, sending a cookie value of CONSENT=YES+ will bypass the consent screen. In Python, this might look like:

requests.head(shorts_link, cookies={"CONSENT": "YES+"})

【讨论】:

    猜你喜欢
    • 2022-12-28
    • 2022-12-26
    • 2022-12-02
    • 2022-12-26
    • 2022-12-27
    • 2022-12-19
    • 2022-12-19
    • 2022-12-26
    • 2022-12-01
    相关资源
    最近更新 更多