youtube playlist statitics

statirics the videos duration of youtube playlist video include total,longest,shortest time

18.06.2017 itibariyledir. En son verisyonu görün.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         youtube playlist statitics
// @name:zh-CN   统计YouTube播放列表的时长
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  statirics the videos duration of youtube playlist video include total,longest,shortest time
// @description:zh-cn 统计YouTube播放列表的时长包括总时长,最长,最短,平均
// @author       Youer@https://github.com/youerning
// @match        https://www.youtube.com/playlist?list=*
// @grant        none
// @require      https://code.jquery.com/jquery-2.2.4.min.js
// ==/UserScript==

(function() {
    //'use strict';
    //var allSpan = document.getElementsByTagName("tbody")[0].getElementsByTagName("span");
    var allSpan = $("ul").find("tbody").find('span[aria-label]');
      // Total seconds
    var sumAll = 0;
    var vidTime = 0;
    var timeList = [];

    for(var i=0;i<allSpan.length;i++) {
      var sp = allSpan[i];
      var spText = sp.innerText;
      var sumOne = 0;
      if (spText.indexOf(":") >= 0) {
            var spTextLis = spText.split(":");
            var lg = spTextLis.length;
            for (var j=0; j < lg; j++){
                var m = Math.pow(60, (lg - 1 - j));
                vidTime = parseInt(spTextLis[j]) * m;
                sumOne += vidTime;
            }
        } else {
            vidTime = parseInt(spText);
            sumOne += vidTime;
      }
      timeList.push(sumOne);
      sumAll += sumOne;
    }
    // console somethings
    console.log("The playlist is total: " + (sumAll/3600).toFixed(2) + "hours");
    console.log("average time of all: " + (sumAll / (60 * allSpan.length)).toFixed(2) + "minutes");
    console.log("longest video time: " + (Math.max.apply(Math, timeList)) / 60 + "minutes");
    console.log("shortest video time: " + (Math.min.apply(Math, timeList)) / 60 + "minutes");
})();