Created
October 11, 2021 05:33
-
-
Save akamhy/12699fe91aaed699283593382ca78bd4 to your computer and use it in GitHub Desktop.
YouTube PlayList Duration from command-line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import requests | |
def playlist_data(search_string): | |
end_point = "https://ytplaylist-len.herokuapp.com" | |
params = {"search_string": search_string.strip()} | |
text = requests.post(end_point, data=params).text | |
number_of_videos = ( | |
re.search(r"<p>No of videos : ([0-9]*?)</p>", text).group(1).strip() | |
) | |
average_length_of_video = ( | |
re.search(r"<p>Average length of video :(.*?)</p>", text).group(1).strip() | |
) | |
total_length_of_playlist = ( | |
re.search(r"<p>Total length of playlist :(.*?)</p>", text).group(1).strip() | |
) | |
return (number_of_videos, average_length_of_video, total_length_of_playlist) | |
if __name__ == "__main__": | |
search_string = input("Enter Playlist Id : ").strip() | |
playlist_data(search_string) | |
number_of_videos, average_length_of_video, total_length_of_playlist = playlist_data( | |
search_string | |
) | |
print(" TOTAL VIDEOS : ", number_of_videos) | |
print(" AVERAGE DURATION : ", average_length_of_video) | |
print(" TOTAL DURATION : ", total_length_of_playlist) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
alias plistdur="/home/akamhy/.pyenv/versions/3.9.1/bin/python /home/akamhy/projects/youtube_playlist_duration.py"