Advertisement
clockworkpc

Extract Video Data From YouTube

Jun 9th, 2013
802
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.29 KB | None | 0 0
  1. #!/usr/bin/python
  2. #/home/clockworkpc/bin/gdata_youtube.py
  3.  
  4. # Released under a GPLv3 Licence by Clockwork PC 2013
  5. # www.clockworkpc.com.au
  6.  
  7. # You are entitled to the following four freedoms:
  8. # Freedom 0: To run this program for any purpose
  9. # Freedom 1: To study how this program works and change it to make it do what you wish
  10. # Freedom 2: To redistribute copies so you can help your neighbour
  11. # Freedom 3: To distribute copies of your modified version to others
  12.  
  13. import os
  14. import re
  15.  
  16. #Fetch video data from YouTube
  17.  
  18. videoFolder = os.getenv("HOME") + "/Videos/tubemixing/"
  19. videoName = raw_input("What is the YouTube file name? ")
  20.  
  21. os.system("cd ~/Videos/tubemixing/ && wget" + " " "http://gdata.youtube.com/feeds/api/videos/" + videoName + " " + "-O" + " " + videoName + ".txt")
  22.  
  23. # Parse video data from YouTube
  24.  
  25. videoFolder2 = os.getenv("HOME") + "/Videos/tubemixing/NamedVideos/"
  26. videoFileName = videoFolder + videoName + ".txt"
  27.  
  28. f = open(videoFileName)
  29. for line in f:
  30.     if "<title type='text'>" in line:
  31.         x = line
  32.         r = re.compile("<title type='text'>(.*?)</title><content")
  33.         m = r.search(x)
  34.         if m:
  35.             titleInfo = m.group(1)
  36.  
  37. # Copy renamed file into separate folder
  38.  
  39. print titleInfo
  40. os.system("cp -v " + videoFolder + videoName + " " + videoFolder2 + "'" + titleInfo + "'")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement