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