File tree 1 file changed +5
-3
lines changed
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):
29
29
result ["tags" ] = ', ' .join ([ meta .attrs .get ("content" ) for meta in soup .find_all ("meta" , {"property" : "og:video:tag" }) ])
30
30
# number of likes
31
31
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' ])
33
34
# 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' ])
35
37
36
38
# channel details
37
39
channel_tag = soup .find ("yt-formatted-string" , {"class" : "ytd-channel-name" }).find ("a" )
@@ -66,4 +68,4 @@ def get_video_info(url):
66
68
print (f"\n Description: { data ['description' ]} \n " )
67
69
print (f"\n Channel Name: { data ['channel' ]['name' ]} " )
68
70
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