Check out example codes for "downloading youtube playlists using youtube-dl in highest quality". It will help you in understanding the concepts better.

Code Example 1

youtube-dl -f best 'http://www.youtube.com/watch?v=P9pzm5b6FFY'

Code Example 2

youtube-dl -f 22 'http://www.youtube.com/watch?v=P9pzm5b6FFY'

Code Example 3

[youtube] Setting language
[youtube] P9pzm5b6FFY: Downloading webpage
[youtube] P9pzm5b6FFY: Downloading video info webpage
[youtube] P9pzm5b6FFY: Extracting video information
[info] Available formats for P9pzm5b6FFY:
format code extension resolution  note 
140         m4a       audio only  DASH audio , [email protected] (worst)
160         mp4       144p        DASH video , video only
133         mp4       240p        DASH video , video only
134         mp4       360p        DASH video , video only
135         mp4       480p        DASH video , video only
136         mp4       720p        DASH video , video only
17          3gp       176x144     
36          3gp       320x240     
5           flv       400x240     
43          webm      640x360     
18          mp4       640x360     
22          mp4       1280x720    (best)

Learn ReactJs, React Native from akashmittal.com