Quantcast
Channel: Active questions tagged youtube-api - Stack Overflow
Viewing all articles
Browse latest Browse all 3638

How to find the total time all videos of a YT playlist have been viewed

$
0
0

Suppose a YouTube PlayList P has videos v1,v2,... . I want to find the total time any video from that list has been viewed prior to now (or prior to time T). Is there a JavaScript that I can run in the console to do this?

I see YT analytics provides the average view length for each individual video. But I do not see that information for a playlist.

Here is my partial attempt:

var totalTime = 0;var videos = document.querySelectorAll('ytd-playlist-video-renderer');videos.forEach(function(video) {totalTime += parseInt(video.querySelector('.ytd-thumbnail-overlay-time-  status-renderer').innerText.split(':').pop()); });console.log('Total time: '+ totalTime +' seconds');

A related question on the number of views.


Viewing all articles
Browse latest Browse all 3638

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>