Skip to content

Commit 7f55df0

Browse files
author
Foxlet
committed
youtube.py - Completed v3 API support
1 parent 00ea8d6 commit 7f55df0

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

plugins/youtube.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,18 @@ def youtime(text):
107107
if json.get('error'):
108108
return
109109
data = json['data']
110+
content_details = data[0]['contentDetails']
111+
statistics = data[0]['statistics']
110112

111-
if not data.get('duration'):
113+
if not content_details.get('duration'):
112114
return
113115

114-
length = data['duration']
115-
views = data['viewCount']
116-
total = int(length * views)
116+
length = isodate.parse_duration(content_details['duration'])
117+
l_sec = int(length.total_seconds())
118+
views = statistics['viewCount']
119+
total = int(l_sec * views)
117120

118-
length_text = timeformat.format_time(length, simple=True)
121+
length_text = timeformat.format_time(l_sec, simple=True)
119122
total_text = timeformat.format_time(total, accuracy=8)
120123

121124
return 'The video \x02{}\x02 has a length of {} and has been viewed {:,} times for ' \

0 commit comments

Comments
 (0)