I have a problem with my script to the automatic youtube channel. I have many small errors but I have one big. I can not find solution for Youtube API I have problem with quota
My full code:
import urllibimport refrom random import randintimport pytubefrom pytube.__main__ import YouTube from pytube.streams import Streamimport osfrom Google import Create_Servicefrom googleapiclient.http import MediaFileUploadimport glob, osimport randomurls_page =[ "https://www.youtube.com/watch?v=Y2NkuFIlLEo", ] url_to_download = 0 number_of_link = 0while True: number = 0 #Random words generator WORDS = ("satisfying","satisfying video","the most satisfying","most oddly satisfying","satisfying videos","the most satisfying video in the world","oddly satisfying videos","sand and slime","ASMR vertical","best oddly satisfying","best oddly satisfying video","satisfying video for sleep","oddly satisfying video to help you sleep","stress relief","satisfaction","no music satisfying","slime","satisfying video to make you sleep","original resource","funny videos") word = random.choice(WORDS) #URL adress finder #video_number = number of video for one searching words video_number = 0 print("video searching start ") value = randint(0, 20) if 11<value>17: video_number = + 1 elif value == 7: video_number = +2 else: video_number = 0 try: search_keyword= word html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + search_keyword +"&sp=EgIwAQ%253D%253D") video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode()) video_url = ('https://www.youtube.com/watch?v='+ video_ids[video_number]) print("video searching finished ") except Exception: finished_string = "+".join(word.split()) +"+" html = urllib.request.urlopen("https://www.youtube.com/results?search_query=" + finished_string +"&sp=EgIwAQ%253D%253D") video_ids = re.findall(r"watch\?v=(\S{11})", html.read().decode()) video_url = ('https://www.youtube.com/watch?v='+ video_ids[video_number]) print("video searching finished ") print(finished_string) #Script on the compare video_url with urls page while True: if video_url == urls_page[number_of_link]: break else: print("video is not it") number_of_link +=1 if sum(isinstance(v, str) for v in urls_page) == number_of_link: urls_page.append(video_url) urls_page = urls_page stoper = 0 print("compare video finished ") break print(video_url) def downloadVideo(link): video = pytube.YouTube(link) video.streams.get_highest_resolution().download() try: os.rename(video.streams.get_highest_resolution().default_filename, word +".mp4" ) except Exception: os.rename(video.streams.get_highest_resolution().default_filename, finished_string +".mp4" ) # pass the youtube video link to download downloadVideo(video_url) print("video is downloaded") #Ubscale Video try: os.system("ffmpeg -i "+ word +".mp4"+" -vf crop=405:720" +" input.mp4") except Exception: os.system("ffmpeg -i "+ finished_string +".mp4"+" -vf crop=405:720" +" input.mp4") #Cut video os.system("ffmpeg -i "+"input.mp4" +" -c copy -map 0 -segment_time 00:00:30 -f segment -reset_timestamps 1 output%03d.mp4 ") CLIENT_SECRET_FILE = ('client_secret.json') API_NAME = 'youtube' API_VERSION = 'v3' SCOPES = ['https://www.googleapis.com/auth/youtube.upload'] service = Create_Service(CLIENT_SECRET_FILE, API_NAME, API_VERSION, SCOPES) WORDS = ("satisfying","satisfying video","the most satisfying","most oddly satisfying","satisfying videos","the most satisfying video in the world","oddly satisfying videos","sand and slime","ASMR vertical","best oddly satisfying","best oddly satisfying video","satisfying video for sleep","oddly satisfying video to help you sleep","stress relief,satisfaction","no music satisfying","slime","satisfying video to make you sleep","original resource","funny videos") name = random.choice(WORDS) WORDS = ("satisfying","satisfying video","the most satisfying","most oddly satisfying","satisfying videos","the most satisfying video in the world","oddly satisfying videos","sand and slime","ASMR vertical","best oddly satisfying","best oddly satisfying video","satisfying video for sleep","oddly satisfying video to help you sleep","stress relief,satisfaction","no music satisfying","slime","satisfying video to make you sleep","original resource","funny videos") name2 = random.choice(WORDS) title = (name+"|"+name2+"|"+"#Shorts") list = [] os.chdir(r"C:\Users\Lukas\Desktop\auto youtube channel") for file in glob.glob("*.mp4"): list.append(file) temp = sum(isinstance(v, str) for v in list) temp -= 2 while True: temps =0 request_body = {'snippet': {'categoryI': 19,'title': title ,'description': '#Shorts shorts,satisfying,satisfying video,the most satisfying,most oddly satisfying,satisfying videos,the most satisfying video in the world,oddly satisfying videos,sand and slime,ASMR,best oddly satisfying,best oddly satisfying video,satisfying video for sleep,oddly satisfying video to help you sleep,stress relief,satisfaction,no music satisfying,slime,satisfying video to make you sleep,original resource,#shorts,try not to laugh,funny videos 2021','tags': ["satisfying","satisfying video","the most satisfying","most oddly satisfying","satisfying videos","the most satisfying video in the world","oddly satisfying videos","sand and slime","ASMR vertical","best oddly satisfying","best oddly satisfying video","satisfying video for sleep","oddly satisfying video to help you sleep","stress relief,satisfaction","no music satisfying","slime","satisfying video to make you sleep","original resource","funny videos"] },'status': {'privacyStatus': 'private','selfDeclaredMadeForKids': False, },'notifySubscribers': False } mediaFile = MediaFileUpload("output"+ f'{temps:03}'+".mp4") response_upload = service.videos().insert( part='snippet,status', body=request_body, media_body=mediaFile ).execute() temps +=1 if temps == 2: break os.remove("*mp4")
And Here are My errors
input.mp4: No such file or directoryclient_secret.json-youtube-v3-(['https://www.googleapis.com/auth/youtube.upload'],)['https://www.googleapis.com/auth/youtube.upload']youtube service created successfullyTraceback (most recent call last):File "c:/Users/Lukas/Desktop/auto youtube channel/auto youtube channel .py", line 155, in mediaFile = MediaFileUpload("output"+ f'{temps:03}'+".mp4")File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient_helpers.py", line 131, in positional_wrapperreturn wrapped(*args, **kwargs)File "C:\Users\Lukas\AppData\Local\Programs\Python\Python38\lib\site-packages\googleapiclient\http.py", line 593, in initself._fd = open(self._filename, "rb")FileNotFoundError: [Errno 2] No such file or directory: 'output000.mp4'
Have anybody a solution for Uploading videos on Youtube without Youtube API ?
PS: Datakund no It is not working