here2share

# Tk_youtube_WL_links.py

Aug 4th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.91 KB | None | 0 0
  1. ...# Tk_youtube_WL_links.py
  2.  
  3. import tempfile
  4. import webbrowser
  5.  
  6. from Tkinter import *
  7. import re
  8. root = Tk()
  9. cpb = root.clipboard_get()
  10. cpb = cpb.encode("utf-8")
  11.  
  12. rrr = re.findall(r'''(data-title=".+" data-video-id=".+)data-set-video-id''', cpb)
  13. print len(rrr)
  14.  
  15. r2 = re.findall(r'''" (data-video-id=".+" data-title=".+)data-set-video-id''', cpb)
  16. print len(r2)
  17.  
  18. rrr+=r2
  19. s=[]
  20. for r in rrr:
  21.     a = r.split('data-title="')[-1]
  22.     a = a.split('"')[0]
  23.     a = a.replace(""",'"')
  24.     a = ''.join([z if ord(z)<127 else "'" for z in a])
  25.     a = re.sub("'+", "'", a)
  26.     b = r.split('data-video-id="')[-1]
  27.     b = b.split('"')[0]
  28.     print b
  29.     s+= [a+'<br>https://www.youtube.com/watch?v='+b+"<br>*"]
  30. #
  31. s = list(set(s))
  32. s.sort()
  33. print len(s)
  34. s='<br>'.join(s)
  35.  
  36. tmp=tempfile.NamedTemporaryFile()
  37. path=tmp.name+'.html'
  38.  
  39. f=open(path, 'w')
  40. f.write("<html><body>"+s+"</body></html>")
  41. f.close()
  42. webbrowser.open('file://' + path)
Add Comment
Please, Sign In to add comment