def YTD_1v(link): if cnet != True: print(rd + "\n[" + yl + "!" + rd + "]" + yl + " Please Check Your Internet Connection " + rd + "!!!") exit(1) print(gr + "\n[" + wi + "~" + gr + "]" + wi + " Download Vedio In Progress " + gr + "....") try: title = get_title(link) except IndexError: title = "Unknown Video Title !!!" print(gr + " [" + wi + "+" + gr + "]" + wi + " Video Title: " + yl + title) try: YT(link).streams.first().download("output/") print(gr + " [" + wi + "+" + gr + "]" + wi + " Download " + gr + "Complete :)") print(gr + " [" + wi + "~" + gr + "]" + wi + " Saved In: " + gr + "output/" + yl) except KeyboardInterrupt: print(" ") exit(1) except EOFError: print(" ") exit(1)
def index(request): form = data(request.POST or None) v = None if form.is_valid(): Video = form.cleaned_data['Video'] YT(Video).streams.first().download() context = {'form': form} return render(request, 'single.html', context)
async def ytvidxxx(message): url = utils.get_arg(message) try: await message.edit("<i>Downloading..</i>") vid = YT(url).streams.first().download() await message.edit("<i>Uploading..</i>") await message.client.send_file(message.chat_id, vid, supports_streaming=True) await message.delete() os.remove(vid) except exceptions.RegexMatchError: await message.edit("<i>Link might be wrong cuz nothin' found</i>")
def YTD_flst(flst): try: flstop = open(flst, "r").readlines() except IOError: print(rd + "\n[" + yl + "!" + rd + "]" + yl + "Error: No such File: [" + rd + flst + yl + "]" + rd + " !!!") exit(1) if cnet == True: # Connected :) print(gr + "\n[" + wi + "~" + gr + "]" + wi + " Download All Videos From File List" + gr + "[~]") loop = 1 for link in flstop: link = str(link).strip() try: print(wi + "[" + gr + str(loop) + wi + "]" + gr + " Downloading Video_Url[ " + wi + str(link) + gr + " ]") try: title = get_title(link) except IndexError: title = "Unknown Video Title !!!" print(gr + " [" + wi + "+" + gr + "]" + wi + " Video Title: " + yl + title) fname = "{}({})".format(title, str(loop)) YT(link).streams.first().download("output/", filename=str(fname)) print(gr + " [" + wi + str(loop) + gr + "]" + wi + " Video Download " + gr + "Complete ") print(gr + " [" + wi + "~" + gr + "]" + wi + " Saved In: " + gr + "output/" + fname) print(" ") except KeyboardInterrupt: print(" ") exit(1) except EOFError: print(" ") exit(1) except Exception as e: print(rd + " [" + yl + "!" + rd + "]" + yl + " Check Video Link In Line[" + rd + str(loop) + yl + "] In File List " + rd + "!!!\n") loop += 1 else: print(rd + "\n[" + yl + "!" + rd + "]" + yl + " Please Check Your Internet Connection " + rd + "!!!") exit(1)
def __init__(self,link): self.link = link self.video = YT(link)
rep += 1 url += rep * [0] yt += rep * [0] format = int( input( " 1 = Retorno de videos com imagem\n 2 = Retorno de video somente com audio (Ocupa menos espaço de armazenamento)\n -> " )) #RECEBE LINKS DO YOUTUBE E EXIBIR INFORMAÇÕES i = 1 for i in range(rep - 1): print("\n-----------------------------------------\n") url[i] = str(input("\tEntre com URL_%d_: " % (i))) yt[i] = YT(url[i]) print("") print(" (%d) Titulo: %s" % (i, yt[i].title)) temp = yt[i].length h = temp / 3600 min = temp / 60 s = temp print(" Duração: %d h =~ %d min =~ %d segs" % (h, min, s)) #RETIRAR LIVE E AO VIVO if (s == 0): yt.pop(i) #RETIRAR MAIORES QUE 4H
def plyre(url): if not "list=" in str(url): print(rd + "\n[" + yl + "!" + rd + "]" + yl + " Error: Incorrect Playlist URL " + rd + "!!!\n[" + yl + "!" + rd + "]" + yl + " Please Check Your Playlist URL" + rd + "!") exit(1) if cnet != True: print(rd + "\n[" + yl + "!" + rd + "]" + yl + " Please Check Your Internet Connection " + rd + "!!!") exit(1) req = url.rfind('=') + 1 ply = url[req:] try: response = requests.get(url).text except Exception: print(rd + "[" + yl + "!" + rd + "]" + yl + " Error: Please Check Your YouTube PlayList URL " + rd + "!!!") exit(1) repl = re.compile(r'watch\?v=\S+?list=' + ply) found = re.findall(repl, response) urls = [] if found: for ur in found: if '&' in ur: vurl = ur.index('&') urls.append('http://www.youtube.com/' + ur[:vurl]) checked = [] videos_URLS = [] for i in urls: if i in checked: continue videos_URLS.append(i) checked.append(i) loop = 1 print(gr + "\n[" + wi + "~" + gr + "]" + wi + " Download PlayList In Progress" + gr + "....") hmany = len(videos_URLS) print(wi + " [" + gr + "*" + wi + "]" + gr + " Total Videos In PlayList <" + yl + str(hmany) + gr + ">") print(wi + "-------------------------------------") for link in videos_URLS: if not link.strip(): continue link = link.strip() try: print(wi + " [" + gr + str(loop) + wi + "]" + gr + " Downloading Video_Url[ " + wi + str(link) + gr + " ]") try: title = get_title(link) except IndexError: title = "Unknown Video Title !!!" print(gr + " [" + wi + "+" + gr + "]" + wi + " Video Title: " + yl + title) fname = "{}({})".format(title, str(loop)) YT(link).streams.first().download("output/", filename=str(fname)) print(gr + " [" + yl + str(loop) + gr + "]" + wi + " Video Download " + gr + "Complete ") print(gr + " [" + wi + "~" + gr + "]" + wi + " Saved In: " + gr + "output/" + fname) print(pu + "========") except KeyboardInterrupt: print(" ") exit(1) except EOFError: print(" ") exit(1) except Exception as e: print(rd + " [" + yl + "!" + rd + "]" + yl + " Error: In Video Number[" + rd + str(loop) + yl + "] In PlayList " + rd + "!!!\n") loop += 1 else: print(rd + "[" + yl + "!" + rd + "]" + yl + " No videos Was Found In This PlayList " + rd + "!!!") exit(1)
from pytube import YouTube as YT import time URL = input("Enter YouTube URL: ") Video = YT(URL) print("\n\nVideo Title: ", Video.title, "\n\nVideo Views: ", Video.views, "\n\nVideo length: ", Video.length, "seconds\n\nVideo rating: ", Video.rating) print("\n\n", Video.streams.filter(progressive=True), "\n\n") VideoStreams = Video.streams.get_highest_resolution() print("Downloading") VideoStreams.download() print("Download is Done") time.sleep(10) #exec("""\nfrom pytube import YouTube as YT\nimport time\nURL = input("Enter YouTube URL: ")\nVideo = YT(URL)\n\nprint("\\n\\nVideo Title: ", Video.title,"\\n\\nVideo Views: ", Video.views,"\\n\\nVideo length: ", Video.length,"seconds\\n\\nVideo rating: ", Video.rating)\n\nprint("\\n\\n",Video.streams.filter(progressive=True),"\\n\\n")\n\nVideoStreams = Video.streams.get_highest_resolution()\n\nprint("Downloading")\nVideoStreams.download()\nprint("Download is Done")\ntime.sleep(10)""")
# This project currently only downloads MP4 videos # Importing library from pytube import YouTube as YT # Download path download_Path = 'C://Users//Vaibhav Saran//Downloads//' # Get the YouTube video Link from user Link = input("Enter the Link to the video: ") # Create an object of Youtube class to access the functions needed to download the video try: yt_obj = YT(Link) # Creates the object and passes the link through constructor except: print("Object Creation Failed !!!!") # Filetering the files with MP4 extention mp4_video = yt_obj.streams.filter(progressive=True, file_extension='mp4') # Sorting by the resolution in descending order yt_obj.streams.order_by('resolution') yt_obj.streams.desc() yt_obj.streams.first().download(download_Path)
def converter(file_download): file_in = file_download for symbol in symbols: file_in = file_in.replace(symbol, '_') if file_in != file_download: os.rename(file_download, file_in) file_out = f"{file_in[:file_in.index('.')]}.mp4" print('[INFO]', file_in, file_out, '[END INFO]', sep='\n') os.system(f"ffmpeg -i {file_in} {os.path.join(path_out, file_out)}") if url != '': # not Enter try: YT(url, on_progress_callback=on_progress ).streams.get_highest_resolution().download(path_in) # print(YT(url).streams) # print(YT(url).streams.filter(subtype='mp4', progressive=True).all()) except Exception as e: print('[ERROR]', e) else: time.sleep(3) print('\n') file_download = os.listdir(path_in)[0] if file_download[file_download.index('.'):] == '.mkv': converter(file_download) else: for file_download in os.listdir(path_in): converter(file_download) time.sleep(3)
def descarga(request, video_url, video_id): if request.user.is_authenticated: YT("www.youtube.com/watch?v=" + video_url).streams.first().download() return redirect('inicio') else: return redirect('loguearse')
print('Loading necessary modules...\n') import re import pandas as pd import numpy as np from pytube import YouTube as YT import os try: url = input(':: Please input the YouTube video url:\n > ') while not url == '': print('\nGetting video information...\n') yt = YT(url) title = yt.title.replace('/', '-') title = yt.title.replace('\\', '-') title = yt.title.replace('|', '-') print("Getting english captions for '{}'...\n".format(title)) captions = yt.captions.get_by_language_code('en') if captions is not None: print('Converting captions to SRT...\n') captions_srt = (captions.generate_srt_captions()) with open(r'{}.txt'.format(title), 'w') as file: file.write(re.sub(r'<.+?>', '', captions_srt)) word_list = list() with open(r'{}.txt'.format(title), 'r') as file: for line in file: if not line.isspace():