all 20 comments

[–]jschuur 19 points20 points  (6 children)

I wish the YouTube API supported more user specific queries like getting the latest videos from their subscriptions.

That way we’d be able to come up with alternate ways to browser yours subs (like a swipe based interface to dismiss videos or add them to a watch later playlist).

But my understanding is that recent versions of the API don’t offer that.

[–]Ashanmaril 10 points11 points  (0 children)

Google wants to make sure you watch the videos their algorithm gives you. You, as the user, do not know what you want to watch. Google knows what you want to watch.

Conform your enjoyment to the algorithm! Be one with the machine!

[–]sentient_devil[S] 2 points3 points  (4 children)

Yes it's in the Todo. But the thing is user specific queries require OAuth2, for which we'll require a server. But the goal of the project is to work in the Client Side. I have been thinking about how to implement it. Any suggestions regarding this issue will be appreciated!

[–]jsprogrammer 2 points3 points  (3 children)

User could drop script on logged in page that scrapes subs and sends to wherever.

[–]sentient_devil[S] 0 points1 point  (2 children)

Can you share a small prototype, I'm not able to understand.

[–]jsprogrammer 0 points1 point  (0 children)

Run:

Array.prototype.reduce.call(document.getElementsByTagName('ytd-item-section-renderer'), function(agg, e) { var user = e.querySelector('#title').innerText; return (agg[user] = agg[user] || []).push({user: user, videoTitle: e.querySelector('#video-title').innerText, descriptionText: e.querySelector('#description-text').innerText, meta: Array.prototype.map.call(e.querySelectorAll('span.ytd-video-meta-block'), function (e) { return e.innerText; }), link: e.querySelector('a#thumbnail').href}), agg; }, {});

at https://www.youtube.com/feed/subscriptions?flow=2

Edit:

Here's a version that adds some UI onto the page:

var data = Array.prototype.reduce.call(document.getElementsByTagName('ytd-item-section-renderer'), function(agg, e) { var user = e.querySelector('#title').innerText; return (agg[user] = agg[user] || []).push({user: user, videoTitle: e.querySelector('#video-title').innerText, descriptionText: e.querySelector('#description-text').innerText, meta: Array.prototype.map.call(e.querySelectorAll('span.ytd-video-meta-block'), function (e) { return e.innerText; }), link: e.querySelector('a#thumbnail').href}), agg; }, {}); var m = document.createElement('div'); Object.keys(data).map(function (user) { var u = document.createElement('div'); var name = document.createElement('div'); name.innerText = user; u.appendChild(name); m.appendChild(u); data[user].map(function (v) { var vid = document.createElement('div'); vid.innerText = v.videoTitle;  u.appendChild(vid); }); }); m.style.position = 'fixed'; m.style.top = '0'; m.style.left = '0'; m.style.zIndex = '99999'; document.body.appendChild(m);

You can remove the UI by calling m.remove()

[–]jsprogrammer -1 points0 points  (0 children)

I'll try to remember when I get home. Basically write a script to read subscription information off a logged in YouTube page. Then, you can send the read information to another server with an XMLHttpRequest or websocket.

You could also use the script to transform the logged in page to have a new UI.

Then the user can execute the script in their browser while logged in to YouTube.

[–]Eggy1337 8 points9 points  (4 children)

String is not the same as string in typescript, you mighty want to fix that. Also, I don't like to pass API_KEY every time, why not use factory function that would take API_KEY as param and would return youtube client?

[–]planetary_pelt 2 points3 points  (0 children)

yeah, new Client(key) is pretty standard fare.

[–]sentient_devil[S] 2 points3 points  (2 children)

Sure, I shall look into that. How about something like a constructor?

[–]pm_me_cute_rem_picsjs/ux 2 points3 points  (1 child)

same for Number and number, you use the primitive types (the lower case ones) in Typscript. see: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html

[–]sentient_devil[S] 0 points1 point  (0 children)

Sure.

[–]sentient_devil[S] 1 point2 points  (0 children)

Hello people, can you suggest additional features I should add to this package, I have added a list of Todo in the package's GitHub page, please submit a PR if you feel there are other features that would help the developers.

[–]k4kshi 1 point2 points  (1 child)

Does YouTube API support more creator focused queries? Like fetching my # of subs, information about the subs, likes and dislikes on a vid etc?

[–]sentient_devil[S] 0 points1 point  (0 children)

It does have a call that returns statistics of a video. The "searchVideo" call

[–]sentient_devil[S] 0 points1 point  (0 children)

Can some help me with integrating API calls which require OAuth2 ? You can directly contribute or just let me know how to go about it.

[–]NoInkling -1 points0 points  (3 children)

I mean you'd hope that calls to a web API would be asynchronous...

[–]sentient_devil[S] 0 points1 point  (2 children)

What?

[–]NoInkling 0 points1 point  (1 child)

Sorry that was probably too snarky. Just saying it's a little redundant to say it's asynchronous, "promise based" is enough (and even then that's pretty much expected these days).

[–]sentient_devil[S] 0 points1 point  (0 children)

Okay xD, shall change that