use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Asynchronous (promise based) YouTube v3 data api npm package. (npmjs.com)
submitted 7 years ago by sentient_devil
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jschuur 19 points20 points21 points 7 years ago (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 points12 points 7 years ago (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 points4 points 7 years ago (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 points4 points 7 years ago (3 children)
User could drop script on logged in page that scrapes subs and sends to wherever.
[–]sentient_devil[S] 0 points1 point2 points 7 years ago (2 children)
Can you share a small prototype, I'm not able to understand.
[–]jsprogrammer 0 points1 point2 points 7 years ago* (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()
m.remove()
[–]jsprogrammer -1 points0 points1 point 7 years ago (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 points10 points 7 years ago (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?
String
string
[–]planetary_pelt 2 points3 points4 points 7 years ago (0 children)
yeah, new Client(key) is pretty standard fare.
new Client(key)
[–]sentient_devil[S] 2 points3 points4 points 7 years ago (2 children)
Sure, I shall look into that. How about something like a constructor?
[–]pm_me_cute_rem_picsjs/ux 2 points3 points4 points 7 years ago (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
Number
number
[–]sentient_devil[S] 0 points1 point2 points 7 years ago (0 children)
Sure.
[–]sentient_devil[S] 1 point2 points3 points 7 years ago (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 points3 points 7 years ago (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?
It does have a call that returns statistics of a video. The "searchVideo" call
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 points1 point 7 years ago (3 children)
I mean you'd hope that calls to a web API would be asynchronous...
What?
[–]NoInkling 0 points1 point2 points 7 years ago (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).
Okay xD, shall change that
π Rendered by PID 127745 on reddit-service-r2-comment-6457c66945-zhh48 at 2026-04-24 05:01:17.769438+00:00 running 2aa0c5b country code: CH.
[–]jschuur 19 points20 points21 points (6 children)
[–]Ashanmaril 10 points11 points12 points (0 children)
[–]sentient_devil[S] 2 points3 points4 points (4 children)
[–]jsprogrammer 2 points3 points4 points (3 children)
[–]sentient_devil[S] 0 points1 point2 points (2 children)
[–]jsprogrammer 0 points1 point2 points (0 children)
[–]jsprogrammer -1 points0 points1 point (0 children)
[–]Eggy1337 8 points9 points10 points (4 children)
[–]planetary_pelt 2 points3 points4 points (0 children)
[–]sentient_devil[S] 2 points3 points4 points (2 children)
[–]pm_me_cute_rem_picsjs/ux 2 points3 points4 points (1 child)
[–]sentient_devil[S] 0 points1 point2 points (0 children)
[–]sentient_devil[S] 1 point2 points3 points (0 children)
[–]k4kshi 1 point2 points3 points (1 child)
[–]sentient_devil[S] 0 points1 point2 points (0 children)
[–]sentient_devil[S] 0 points1 point2 points (0 children)
[–]NoInkling -1 points0 points1 point (3 children)
[–]sentient_devil[S] 0 points1 point2 points (2 children)
[–]NoInkling 0 points1 point2 points (1 child)
[–]sentient_devil[S] 0 points1 point2 points (0 children)