How to extract file size from youtube-dl in python script?
Question: I'm new to python programming. I want to extract a video/audio size ( any
youtube video) before downloading it ??


Answer: 
    >>> from youtube_dl import YoutubeDL
    >>> url = 'https://www.youtube.com/watch?v=PSYxT9GM0fQ'
    >>> ytdl = YoutubeDL()
    >>> info = ytdl.extract_info(url, download=False)
    [youtube] PSYxT9GM0fQ: Downloading webpage
    [youtube] PSYxT9GM0fQ: Downloading video info webpage
    [youtube] PSYxT9GM0fQ: Extracting video information
    [youtube] PSYxT9GM0fQ: Downloading DASH manifest
    >>> formats = info['formats']
    

formats is a list of dictionaries, pick the format you are looking for

    
    
    >>> format = formats[0]
    >>> format['filesize']
    2594621
    

In general

    
    
    >>> info.keys()
    dict_keys(['extractor_key', 'upload_date', 'thumbnail', 'playlist_index', 'format_id', 'width', 'display_id', 'is_live', 'dislike_count', 'thumbnails', 'annotations', 'age_limit', 'formats', 'id', 'playlist', 'subtitles', 'average_rating', 'player_url', 'height', 'requested_subtitles', 'like_count', 'extractor', 'uploader_id', 'ext', 'automatic_captions', 'format', 'webpage_url', 'end_time', 'uploader', 'webpage_url_basename', 'duration', 'start_time', 'view_count', 'title', 'http_headers', 'description', 'url', 'tags', 'categories'])
    

are the different keys you can use to gain information about the youtube link

