Youtube music and video downloader

Video.js 673B

12345678910111213141516171819202122232425
  1. export default class Video {
  2. constructor(result) {
  3. this.id = result.id.videoId;
  4. this.title = result.snippet.title;
  5. this.thumb = result.snippet.thumbnails.default;
  6. this.url = `https://www.youtube.com/watch?v=${this.id}`;
  7. this.stats = {
  8. viewCount: 0,
  9. likeCount: 0,
  10. dislikeCount: 0,
  11. commentCount: 0,
  12. favoriteCount: 0,
  13. };
  14. this.duration = 0;
  15. this.converted = {};
  16. }
  17. update(stats, duration) {
  18. for (count in stats)
  19. this.stats[count] = numeral(stats[count]).format('0.[00]a');
  20. console.log(duration);
  21. const time = moment.utc(moment.duration(duration).asMilliseconds())
  22. this.duration = time.format(time.hours() ? 'k:mm:ss' : 'm:ss');
  23. }
  24. }