Skip to content

Commit 1e31389

Browse files
author
Foxlet
committed
youtube.py - Why strings? I don't know.
1 parent 7f55df0 commit 1e31389

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

plugins/youtube.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def youtime(text):
106106

107107
if json.get('error'):
108108
return
109-
data = json['data']
109+
data = json['items']
110+
snippet = data[0]['snippet']
110111
content_details = data[0]['contentDetails']
111112
statistics = data[0]['statistics']
112113

@@ -115,14 +116,14 @@ def youtime(text):
115116

116117
length = isodate.parse_duration(content_details['duration'])
117118
l_sec = int(length.total_seconds())
118-
views = statistics['viewCount']
119+
views = int(statistics['viewCount'])
119120
total = int(l_sec * views)
120121

121122
length_text = timeformat.format_time(l_sec, simple=True)
122123
total_text = timeformat.format_time(total, accuracy=8)
123124

124125
return 'The video \x02{}\x02 has a length of {} and has been viewed {:,} times for ' \
125-
'a total run time of {}!'.format(data['title'], length_text, views,
126+
'a total run time of {}!'.format(snippet['title'], length_text, views,
126127
total_text)
127128

128129

0 commit comments

Comments
 (0)