Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ...# Tk_youtube_WL_links.py
- import tempfile
- import webbrowser
- from Tkinter import *
- import re
- root = Tk()
- cpb = root.clipboard_get()
- cpb = cpb.encode("utf-8")
- rrr = re.findall(r'''(data-title=".+" data-video-id=".+)data-set-video-id''', cpb)
- print len(rrr)
- r2 = re.findall(r'''" (data-video-id=".+" data-title=".+)data-set-video-id''', cpb)
- print len(r2)
- rrr+=r2
- s=[]
- for r in rrr:
- a = r.split('data-title="')[-1]
- a = a.split('"')[0]
- a = a.replace(""",'"')
- a = ''.join([z if ord(z)<127 else "'" for z in a])
- a = re.sub("'+", "'", a)
- b = r.split('data-video-id="')[-1]
- b = b.split('"')[0]
- print b
- s+= [a+'<br>https://www.youtube.com/watch?v='+b+"<br>*"]
- #
- s = list(set(s))
- s.sort()
- print len(s)
- s='<br>'.join(s)
- tmp=tempfile.NamedTemporaryFile()
- path=tmp.name+'.html'
- f=open(path, 'w')
- f.write("<html><body>"+s+"</body></html>")
- f.close()
- webbrowser.open('file://' + path)
Add Comment
Please, Sign In to add comment