File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ def get_video_info(url):
2929 result ["tags" ] = ', ' .join ([ meta .attrs .get ("content" ) for meta in soup .find_all ("meta" , {"property" : "og:video:tag" }) ])
3030 # number of likes
3131 text_yt_formatted_strings = soup .find_all ("yt-formatted-string" , {"id" : "text" , "class" : "ytd-toggle-button-renderer" })
32- result ["likes" ] = int ('' .join ([ c for c in text_yt_formatted_strings [0 ].attrs .get ("aria-label" ) if c .isdigit () ]))
32+ result ["likes" ] = '' .join ([ c for c in text_yt_formatted_strings [0 ].attrs .get ("aria-label" ) if c .isdigit () ])
33+ result ["likes" ] = 0 if result ['likes' ] == '' else int (result ['likes' ])
3334 # number of dislikes
34- result ["dislikes" ] = int ('' .join ([ c for c in text_yt_formatted_strings [1 ].attrs .get ("aria-label" ) if c .isdigit () ]))
35+ result ["dislikes" ] = '' .join ([ c for c in text_yt_formatted_strings [1 ].attrs .get ("aria-label" ) if c .isdigit () ])
36+ result ['dislikes' ] = 0 if result ['dislikes' ] == '' else int (result ['dislikes' ])
3537
3638 # channel details
3739 channel_tag = soup .find ("yt-formatted-string" , {"class" : "ytd-channel-name" }).find ("a" )
@@ -66,4 +68,4 @@ def get_video_info(url):
6668 print (f"\n Description: { data ['description' ]} \n " )
6769 print (f"\n Channel Name: { data ['channel' ]['name' ]} " )
6870 print (f"Channel URL: { data ['channel' ]['url' ]} " )
69- print (f"Channel Subscribers: { data ['channel' ]['subscribers' ]} " )
71+ print (f"Channel Subscribers: { data ['channel' ]['subscribers' ]} " )
You can’t perform that action at this time.
0 commit comments