From bc0eab8d95e35b6e6e34b53e5df07bde51c88840 Mon Sep 17 00:00:00 2001 From: Kyle Spier-Swenson Date: Sun, 16 Aug 2015 05:50:21 -0700 Subject: [PATCH] Delete YTCv4.py --- bot/YTCv4.py | 125 --------------------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 bot/YTCv4.py diff --git a/bot/YTCv4.py b/bot/YTCv4.py deleted file mode 100644 index a486c39b00e7..000000000000 --- a/bot/YTCv4.py +++ /dev/null @@ -1,125 +0,0 @@ -from urllib2 import urlopen -import os -import pickle -from CORE_DATA import directory,no_absolute_paths -global did_tell, no_absolute_paths -no_absolute_paths = True -did_tell = False -def YTCV4(youtube_url,cache=1,debug=0): - global did_tell, no_absolute_paths - Do_not_open = True - __doc__ = "Cache does not affect anything, it's legacy for skibot." - try: - cut_down = youtube_url.split("watch?v=")[1].split("&")[0] - if len(cut_down) > 11: #Longer than normal, presume troll. - youtube_url.replace(cut_down,cut_down[:11]) - elif len(cut_down) < 11: #Shorter than normal - pass - except IndexError: - return "Reflex: Where's the watch?v=?" - first_two = cut_down[0:2] - try: - if no_absolute_paths: - tiedosto = open("YTCache/"+first_two+".tcc","r") - else: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","r") - except: - prev_dict = {} - else: - try: - prev_dict = pickle.load(tiedosto) - except EOFError: # Cache is corrupt - os.remove(directory+tiedosto.name) - print "REMOVED CORRUPT CACHE: "+tiedosto.name - prev_dict = {} - tiedosto.close() # I think this should belong here. - if cut_down in prev_dict.keys(): - return prev_dict[cut_down] - else: - pass - try: - if no_absolute_paths: - tiedosto = open("YTCache/"+first_two+".tcc","w") - else: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") - except IOError,error: - if len(prev_dict.keys()) > 0: - try: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - except IOError: - if did_tell == False: - did_tell = True - return "COULD NOT ACCESS FILE "+first_two+".tcc! The next time you run this link, it checks it through the web" - Do_not_open = False - else: - did_tell = False - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Very odd error occurred: " + str(error) - youtube_url = youtube_url.replace("http//","http://") - if youtube_url.lower()[0:7] != "http://" and youtube_url[0:4] == "www.": - youtube_url = "http://" + youtube_url - if youtube_url.count("/") + youtube_url.count("\\") < 3: - if len(prev_dict.keys()) > 0: - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Reflex: Video cannot exist" - else: - if "http://" in youtube_url[0:12].lower() and youtube_url[0:7].lower() != "http://": - youtube_url = youtube_url[youtube_url.find("http://"):] - if "?feature=player_embedded&" in youtube_url: - youtube_url = youtube_url.replace("?feature=player_embedded&","?") - try: - website = urlopen(youtube_url) - except: - if len(prev_dict.keys()) > 0: - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - else: - pass - return "Reflex: Incorrect link!" - for i in website.readlines(): - if i.count('',contentvar)] - if "&quot;" in result: - result = result.replace("&quot;",'"') - else: - pass - if "&amp;" in result: - result = result.replace("&amp;","&") - else: - pass - if "&#39;" in result: - result = result.replace("&#39;","'") - else: - pass - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - prev_dict[cut_down] = result - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - return result - if Do_not_open == True: - tiedosto = open(directory+"YTCache/"+first_two+".tcc","w") #This is a Just In Case - prev_dict[cut_down] = "No title for video, Removed / Needs Age verification / Does not exist" - pickle.dump(prev_dict,tiedosto) - tiedosto.close() - return "No title for video, Removed / Needs age verification / Does not exist"