– Extract URLs from youtube playlist

youParse simply extracts URLs from Youtube user’s playlist (not favorites playlist). This little python3 script can be used to integrate its output to other tools like clive to download all videos. Sample usage:

python3 ""
# to use with clive
python3 "" | clive -f best

Copy the code below and save it as or download from here.

[code lang="python"]
# Name:
# Version: 1.5
# Author: pantuts
# Email:
# Description: Parse URLs in Youtube User's Playlist (Video Playlist not Favorites)
# Use python3 and later
# Agreement: You can use, modify, or redistribute this tool under
# the terms of GNU General Public License (GPLv3).
# This tool is for educational purposes only. Any damage you make will not affect the author.
# Usage: python3 youtubeURLhere

import re
import urllib.request
import urllib.error
import sys
import time

def crawl(url):
sTUBE = ''
cPL = ''
amp = 0
final_url = []

if 'list=' in url:
eq = url.rfind('=') + 1
cPL = url[eq:]

print('Incorrect Playlist.')

yTUBE = urllib.request.urlopen(url).read()
sTUBE = str(yTUBE)
except urllib.error.URLError as e:

tmp_mat = re.compile(r'watch\?v=\S+?list=' + cPL)
mat = re.findall(tmp_mat, sTUBE)

if mat:

for PL in mat:
yPL = str(PL)
if '&' in yPL:
yPL_amp = yPL.index('&')
final_url.append('' + yPL[:yPL_amp])

all_url = list(set(final_url))

i = 0
while i < len(all_url):
sys.stdout.write(all_url[i] + '\n')
i = i + 1

print('No videos found.')

if len(sys.argv) < 2 or len(sys.argv) > 2:
print('USAGE: python3 YOUTUBEurl')

url = sys.argv[1]
if 'http' not in url:
url = 'http://' + url