| 123456789101112131415161718192021222324 |
- export default class Video {
- constructor(result) {
- this.id = result.id.videoId;
- this.title = result.snippet.title;
- this.thumb = result.snippet.thumbnails.default;
- this.url = `https://www.youtube.com/watch?v=${this.id}`;
- this.stats = {
- viewCount: 0,
- likeCount: 0,
- dislikeCount: 0,
- commentCount: 0,
- favoriteCount: 0,
- };
- this.duration = 0;
- this.converted = {};
- }
-
- update(stats, duration) {
- for (count in stats)
- this.stats[count] = numeral(stats[count]).format('0.[00]a');
- const time = moment.utc(moment.duration(duration).asMilliseconds())
- this.duration = time.format(time.hours() ? 'k:mm:ss' : 'm:ss');
- }
- }
|