---
# System prepended metadata

title: Problem statement
tags: [TY]

---

---
tags: TY
---
# Problem statement
Use YouTube to host and manage videos for the TY website; subject to the following features:
1. Users should be able to freely switch quality, similar to youtube.com
2. Users should not be able to share videos.
3. No extra visible layer of authentication should be there.
4. It'd be nice to have analytical information.

# Official solutions
As suggested by you, I tried exploring if YouTube provides a "private channel" functionality wherein we get out custom space where we can re-direct users to.

Unlisted playlists could be a solution but we won't be able to stop users from sharing.

And apart from setting video permissions as private, I did not found a solution. This isn't desirable because it'd require another layer of authentication.

(I'm actually unsure what kind of solution can exist where we can redirect users to an external website without requiring extra auth.)

## Solution using GSuite SSO
We can transparently authenticate users to private vidoes/playlists using GSuite's SSO feature.

However, this might be a costly solution as the pricing scales on a per user basis (starting from INR 125/user/month).

**A possible trick**: maybe we can authenticate everyone as one GSuite user(say `proxyuser`), this would save us on costs. I'm unsure if Google can block this behaviour though. The workflow would look like:
- User clicks on a link from the TY website.
- Our backend signs a SAML request in favour of `proxyuser`.
- Redirect them to YouTube authenticated as `proxyuser` which has permissions to view our videos.


# Unofficial solutions

## Overlay trick
This is what we're currently using. Basically, draw an overlay over YouTube's embeded player to hide the sharing options.

The drawback being, in the currently overlay, we can't switch qualities due to YouTube's Embed API limitations.

One solutions could be to create a custom overlay that keeping the original controls, and just hides the sharing option.

## Alternate backend
Various open-source projects are present to make privacy-focused YouTube front-ends (eg: [Piped](https://github.com/TeamPiped/Piped), [Invidious](https://github.com/iv-org/invidious)). They do this by creating a custom backend that can fetch direct videos links from YouTube; and those direct links can be used by any front-end player. The following diagram demonstrates this:

![](https://i.imgur.com/sfMEeqT.png)


The obvious advantage of this approach is that we'd have full control over video stream at the frontend including switching qualities. There are multiple publicly hosted servers available so, no extra infrastructure is needed.

Even though these solutions are heavily used by thousands of users, it's not official supported. There's a minor risk that YouTube can ban them.


# Conclusion
If we're fine with the risk, using an alternate backend would be the best solution from users as well as development perspective.

Otherwise, using a custom overlay should be a doable work-around.