File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments