Advertisement
0xCor3

Youtube Extractor

Jul 3rd, 2018
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.09 KB | None | 0 0
  1. import urllib2
  2. import json
  3. import os
  4. import os.path
  5. import sys
  6. import shutil
  7. from time import sleep
  8. os.system("clear")
  9. print """
  10. \t=====================================================
  11. \t     __  __          __       __
  12. \t     \ \/ /__  __ __/ /___ __/ /  ___
  13. \t      \ / _ \/ // / __/ // / _ \/ -_) LINK
  14. \t      /_/\___/\_,_/\__/\_,_/_.__/\__/ __
  15. \t           / __/_ __/ /________ _____/ /____  ____
  16. \t          / _/ \ \ / __/ __/ _ `/ __/ __/ _ \/ __/
  17. \t V:0.1   /___//_\_\\__/_/  \_,_/\__/\__/\___/_/
  18. \t=====================================================
  19. """
  20. channelid = raw_input("Channel ID : ")
  21. api_key = "16b06bd9b738835e2d134fe8d596e9ab0086a985" # MZTRAPIS.OOO
  22. url_api = "http://mztrapis.ooo/v1/ytm4a.php?channelid="+ channelid + "&key=" + api_key
  23. req = urllib2.Request(url_api)
  24. opener = urllib2.build_opener()
  25. data = opener.open(req)
  26. json = json.loads(data.read())
  27.  
  28. print("\n---------------------------------------------\n")
  29. print("Channel Name : " + json[0]['channel'] + "\n")
  30. print("---------------------------------------------\n")
  31. opt = raw_input("Save / Print / Abort / Download ? (s/p/a/d) : ")
  32. print("\n---------------------------------------------\n")
  33. if opt == "p":
  34.     for ytlink in json:
  35.         print("\t" + ytlink['result']['link'])
  36. elif opt == "s":
  37.         if os.path.isfile(json[0]['channel'] + ".txt"):
  38.             os.remove(json[0]['channel'] + ".txt")
  39.             print("Rewriting....")
  40.             sleep(2)
  41.             with open(json[0]['channel']+ ".txt", "w") as output:
  42.                 for ytlink in json:
  43.                     output.write(str(ytlink['result']['link'] + "\n"))
  44.  
  45.         else:
  46.             print("Writing.....")
  47.             with open(json[0]['channel']+ ".txt", "w") as output:
  48.                 for ytlink in json:
  49.                     output.write(str(ytlink['result']['link'] + "\n"))
  50. elif opt == "d":
  51.     for ytlink in json:
  52.         os.system("wget --trust-server-names '" + json['result']['link'] + "'")
  53. else:
  54.     print("Aborting... & Quiting.....")
  55.     sleep(2)
  56.     exit()
  57. print("\n---------------------------------------------")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement