Welcome, guest | Sign In | My Account | Store | Cart
#!/usr/bin/python

# Name: youParse.py
# Author: pantuts
# Email: pantuts@gmail.com
# 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 on your extent
# with credits to author.
# Usage: python3 youParse.py youtubeURLhere

import re
import urllib.request
import sys

def crawl(url):
    amp = 0
    cPL = 0
    if 'PL' in url:
        amp = url.index('L') + 1
        cPL = url[amp]
    else:
        print('Incorrect Playlist.\nSample playlist at the end of url: PL1894B2B763FBC580')
        exit(1)
    
    try:
        yTUBE = urllib.request.urlopen(url).read()
        sTUBE = str(yTUBE)
    except urllib.error.HTTPerror as e:
        print(e)
        
    mat = re.findall(r'watch\S+list=\w.' + str(cPL), sTUBE)
    if mat[0] == mat[1]:
        mat.remove(mat[0]) #if there is duplicate, remove
    print('Videos in Playlist: ' + str(len(mat)))
    for PL in mat:
        yPL = str(PL)
        if '&' in yPL:
            yPL_amp = yPL.index('&')
        print('[+] http://www.youtube.com/' + yPL[:yPL_amp])
        
if len(sys.argv) < 2 or len(sys.argv) > 2:
    print('USAGE: python youParse.py YOUTUBEurl')
    exit(1)
else:
    url = sys.argv[1]
    crawl(url)

Diff to Previous Revision

--- revision 2 2012-10-12 12:30:19
+++ revision 3 2012-10-12 12:31:22
@@ -40,7 +40,7 @@
         print('[+] http://www.youtube.com/' + yPL[:yPL_amp])
         
 if len(sys.argv) < 2 or len(sys.argv) > 2:
-    print('USAGE: python youtubePL.py YOUTUBEurl')
+    print('USAGE: python youParse.py YOUTUBEurl')
     exit(1)
 else:
     url = sys.argv[1]

History