tubesync icon indicating copy to clipboard operation
tubesync copied to clipboard

Create a caching web service for accessing YouTube account details

Open tcely opened this issue 7 months ago • 7 comments

This is unlikely to be part of this project, but anyone looking for ideas or a small project is welcome to contribute an implementation.

I found UnTube^UnTube which was a playlist manager, so it likely has most of what this would need already coded.

Requires

  • access to a YouTube account

Provides

  • [ ] a suitable cookies file for yt-dlp to use
  • [ ] a listing of available playlists in the YouTube account
  • [ ] the playlist ID, title, last modified timestamp, and creator ID for every playlist that is available
  • [ ] the ID, description, title, availability and timestamp for every media in a playlist
  • [x] a listing of subscriptions from the account including the channel ID

Based on this comment:

It would be great if TubeSync could implement the YouTube API and call the /subscriptions method to "sync" the user's subscriptions periodically (like once an hour or something)

Originally posted by @derekantrican in #245

More resources:

  • https://developers.google.com/youtube/v3/guides/auth/server-side-web-apps
  • https://developers.google.com/youtube/v3/docs/subscriptions/list?apix_params=%7B%22part%22%3A%5B%22contentDetails%22%5D%2C%22mine%22%3Atrue%7D

tcely avatar Jun 05 '25 09:06 tcely

Ok, after a lot of ChatGPT (and a TON of arguing with the Google oauth approval team about what this service does), I think I set something up: https://ytsubs.app . I wanted to learn about AWS and figured this would be a pretty simple use-case to work with ChatGPT to build this out.

The homepage should be pretty self explanatory, but basically:

  1. Users can go to https://ytsubs.app and click "Sign in with Google"
  2. Once the auth flow is completed, they'll be presented with an API key and their Google User ID
  3. A request can be made to https://ytsubs.app/subscriptions with ?api_key=APIKEY&google_user_id=GOOGLEUSERID to retrieve the subscriptions (response format is visible on the homepage)

The user's subscriptions are retrieved from YouTube when the https://ytsubs.app/subscriptions endpoint is called unless the last call was less than 12 hours ago - then the user's subscriptions are returned from the cache

derekantrican avatar Jun 25 '25 15:06 derekantrican

Thank you for your efforts! 👏

This looks like it is working, at least for subscriptions, as well as TubeSync would need it to.

I can't wait to see what else might be added to your app!

Is the source code available for review?

tcely avatar Jun 25 '25 16:06 tcely

Right now the source is closed, but I could open source it later.

There's only 3 functional files: oauth_start.py (which also shows the homepage), oauth_callback.py (which also shows the auth completion page), and fetch_subscriptions.py (which handles the API requests). I can share any of these if you like (less keen about sharing my workflow ymls and such until I fully review & clean-up)

derekantrican avatar Jun 25 '25 16:06 derekantrican

Creating a git repository for this and linking to it from the privacy policy page would be a great step.

I, of course, understand wanting to polish things a bit before publishing. However, like others, I would be more comfortable using a service such as this after reviewing what the code is doing. It also makes it easier for others to contribute.

I am hopeful that this app, or a project similar to it, will gain a community and let people install and use this locally in addition to using AWS.

tcely avatar Jun 25 '25 16:06 tcely

ytsubs-main.zip

Here's the current state of the repo minus the README and Workflows

@tcely - I could also add you as a contributor to review the repo to help me decide if anything (like accidentally leaking secrets somehow) should be changed before open-sourcing it

derekantrican avatar Jun 25 '25 17:06 derekantrican

I could also add you as a contributor to review the repo

Go ahead, I am happy to review this. By the way, I think GitHub calls that a collaborator.

Having looked through the zip file, I would suggest that you use the getenv function from this project.

https://github.com/meeb/tubesync/blob/1c4da6641cdbb0fbb0650757ac98178987084a57/tubesync/common/utils.py#L23-L57

tcely avatar Jun 25 '25 17:06 tcely

The repository is now public: https://github.com/derekantrican/ytsubs

I've added issues for the remaining points needed to close this issue:

  • derekantrican/ytsubs#26
  • derekantrican/ytsubs#33

There is also a management command for adding sources from subscriptions:

  • #1155

Thanks again to @derekantrican for providing this solution!

tcely avatar Jul 08 '25 22:07 tcely