12/22/2020

get YouTube video url from channel name, python youtube-dl library

 

install youtube-dl package first.

pip install YouTube-dl


<code>

import subprocess
direct_output = subprocess.check_output('youtube-dl --get-id https://www.youtube.com/channel/UCAwWYtU_DEdRFxEHl9879dRYBfQ/videos --no-check-certificate', shell=True)
Lines = direct_output.decode()
idv = Lines.split('\n')
play_url_list = []
for idv in Lines.split('\n'):
if idv == '':
continue
print(idv)
play_url_list.append( 'https://www.youtube.com/watch?v={}'.format(idv) )

</code>


Thank you.