def downloadYoutubePlaylist(): myyoutubeplaylist = youtubeplaylistlink.get() pl = Playlist(myyoutubeplaylist) pl.download_all(myDirectoryName.get()) saveConfigfile() messagebox.showinfo("Download Youtube Video Playlist", "Task Completed Successfully !")
def main(): # check is user is conncted to internet if not connect(): print('No Internet Connection!\nExiting....') exit() #exit if not else: while True: # url='https://www.youtube.com/watch?v=Edpy1szoG80&list=PL153hDY-y1E00uQtCVCVC8xJ25TYX8yPU' url=input('Enter the Playlist link to Download: ') if urlChecker(url): break else:print('Invalid Url!') while True: temp=pathExistsElseCreate(input('\nEnter Destination Path("." for this dir):')) if temp is not None: SAVE_PATH=temp break else:print('Invalid Path!') print("\nGetting Details of Playlist") pl = Playlist(url) os.system('cls') print("\nDetails for Playlist","\n") print("Title: ",pl.title()) #may not work for some playlist print("\nDownloading...") pl.download_all(SAVE_PATH) print("\nDownload completed!!")
def test(self): """ TODO: - Experimental playlist - Playlist option to combobox type - Playlist regex check -==========================================================================- Currently no way of checking whether it's complete and what the progress is, Possible way to loop over all url so we can get the remaining and progress playlist.populate_video_urls() playlist.video_urls """ playlist_url = self.txt_yt.text() if playlist_url is None or playlist_url == "": print("Empty playlist url") return if playlist_regex.match(playlist_url): savedir = self.open_dir_dialog() if savedir.toString() == "": print("Canceled/closed choosing directory") return playlist = Playlist(playlist_url) # download_all() defaults to highest res so not optimal # No options or configs are available at this time playlist.download_all(savedir.path()) else: print("No matching playlist url")
def ripList(localurl): print('trying rip list....') try: playlist = Playlist(localurl) playlist.download_all(SAVE_PATH) except Exception as e: print('Error: ', e)
def test_resoluton_picker_failure(): passed = False try: test = Playlist(short_test_pl) test.download_all(resolution="1080p") except exceptions.Resolution_Exception: passed = True assert passed is True
def download_video_playlist_using_url_and_save_in_specific_path( play_list_url, path): pl = Playlist(play_list_url) if not os.path.exists(path): os.makedirs(path) pl.download_all(path) else: pl.download_all(path)
def index(request): form = data(request.POST or None) pl = None if form.is_valid(): Playlist = form.cleaned_data['Playlist'] pl = PL(Playlist) pl.download_all() context = {'form': form} return render(request, 'playlist.html', context)
def downloader(): link = str(entry.get()) if var2.get() == 'Single-Video': yt = pytube.YouTube(link) stream = yt.streams.get_by_itag(ok()) stream.download(directory()) if var2.get() == 'Playlist': pl = Playlist(link) pl.download_all(directory())
def download_playlist(path="."): try: playlist = Playlist(pyperclip.paste()) playlist.download_all(path) text.delete(0.0, END) text.insert(END, "Done.") except: text.delete(0.0, END) text.insert(END, "It's not a YouTube playlist link! Maybe a single video?")
def download_playlist(link, path_after): yt = Playlist(link) print("Downloading playlist...") try: yt.download_all(download_path=path_after) except: print("\nSome video is unavailable and crashes the script") print( "\n~You can either try to find a similar playlist or download one by one~\n" ) pass
def best_q_playlist(path): link = input("Enter the youtube video link:") try: pl = Playlist(link) except: print( "ERROR. Check your:\n -connection\n -url is a YouTube url\n\nTry again." ) redo = best_q_single_vid(path) pl.download_all(path) print("task completed") rep_process()
def on_clickDownload(): global pt, pth """ path = v2.get() if(path == "<path if any>") : path = "" """ pt=Entry2.get() if(pt != ""): pl = Playlist(pt) pl.download_all() #v2.set("<path if any>") Entry2.delete(0,END)
def download_youtube_playlist(link, folder=None): p = Playlist(link) title = p.title() if folder: folder = os.path.join(folder, title) else: folder = title print(f"Folder to the playlist - {link}: {folder}") try: os.makedirs(folder) except: pass p.download_all(download_path=folder)
def playlist_download(): root = Tk() root.withdraw() folder_select = filedialog.askdirectory() s = pyspeedtest.SpeedTest() server = 'youtube.com' ytp = Playlist(str(input("Enter the Playlist link: "))) for x in range(1, 5): n = s.ping(server) n = int(n) print("Your network speed:", n, "kb/s") print("Downloading..........") ytp.download_all(folder_select) os.system("cls")
def download_playlist(request): homedir = os.path.expanduser("~") dirs = homedir + '/Downloads/pytube/playlists' if request.method == "POST": url = request.POST.get('link') filename = url.split('=')[1][1:5] dirs = dirs + '/' + filename if os.path.exists(dirs) == False: os.mkdir(dirs) pl = Playlist(url) pl.download_all(dirs) messages.success( request, f'Download completed. Check your "{dirs}" directory!') return render(request, 'pytube/download_playlists.html')
def playlist(): try: global folder destination = input( 'Enter the link of the playlist you want to install: ') folder = input('Enter the folder you want to save it in: ') linked = Playlist(destination) linked.download_all(folder) print('Downloaded your videos too', folder) main() except: print( 'We have managed to download some videos or maybe non at all but have encountered an error try a different playlist' ) main() main()
def get_videos_playlist(self): # Extrai as informação de diretórios do arquivo de configuração. config = SafeConfigParser() config.read('config.conf') input_loc = config.get("input_loc") # Armazena as urls das playlists para download. urls = config.get("lista") for url in urls: print('Inicio do processo') mv = Playlist(url) if not os.path.exists(input_loc): os.makedirs(input_loc) print('Baixando conteudo') mv.download_all(input_loc) print('Finalizado!')
def playlistDownload(llink, output): print('llink') print('Accessing Youtube URL...') try: pl = Playlist(llink) print('Downloading...') if (output is None): pl.download_all() else: print('Your file will save to:', output) pl.download_all(output) delete_last_line() print('Completed') except: print( "ERROR. Check your:\n -connection\n -url is a YouTube url\n\nTry again." )
def download_playlist(url): pl = Playlist(url) user = getpass.getuser() while (True): foldername = input("Enter the folder name") try: path = r'C:\users\{0}\Downloads\{1}'.format(user, foldername) os.mkdir(path) break except FileExistsError: YorN = input( "Folder Exists are you sure to continue in this folder(Y/N)") if (YorN == "Y"): break else: continue pl.download_all(path) return path
def download_videos_of_playlist(playlist_id, videos_dir): """Downloads entire videos in youtube video playlists params: playlist_id: id of youtube playlist to download videos_dir: path to download videos to """ # create video directory if not exist if not os.path.exists(videos_dir): os.makedirs(transcripts_dir, exist_ok=True) playlist = Playlist(playlist_id) playlist.download_all(videos_dir) else: # skip downloading if videos already exists print( "Videos from playlist with id {0} already downloaded, skipping...". format(playlist_id))
def downloadYoutubePlaylistMP3(): myyoutubeplaylist = youtubeplaylistlink.get() pl = Playlist(myyoutubeplaylist) pl.download_all(myDirectoryName.get()) directory = os.fsencode(myDirectoryName.get()) for file in os.listdir(directory): filename = os.fsdecode(file) mp4 = myDirectoryName.get() + '/' + filename mp3 = myDirectoryName.get() + '/' + os.path.splitext( filename)[0] + '.mp3' ffmpeg = ('ffmpeg -i "%s" "%s"' % (mp4, mp3)) subprocess.run(ffmpeg) os.remove(mp4) #messagebox.showinfo("Dateiname",ffmpeg) saveConfigfile() messagebox.showinfo("Download Youtube Playlist as Audio", "Task Completed Successfully !")
def download(link, formatdl, resolution) : #We create a youtube object yt = YouTube(link) #We get the name of the video and add the .mp4 extension title = yt.title + ".mp4" #It may happen that some title got caraters that mess up with the terminal so we delete them title = clean(title) #Here are the different format and resolution try : if formatdl == "sound" : print("%s\n[-] Downloading %s.%s" % (white, title, end)) yt.streams.filter(only_audio = True).first().download(filename = "filename") os.rename("filename.mp4", title) elif formatdl == "playlist" : print("%s\n[-] Downloading the playlist.%s" % (white, end)) try : pl = Playlist(link) pl.download_all() except KeyboardInterrupt : sys.exit("%s [!] Downloading was interrupted. Exiting...%s" % (red, end)) except : sys.exit("%s [!] Error while downloading. Exiting...%s" % (red, end)) elif formatdl == "video" : print("%s\n[-] Downloading %s.%s" % (white, title, end)) #Low quality if resolution == "l" : yt.streams.filter(progressive = True, subtype = "mp4").desc().first().download() #Medium quality elif resolution == "m" : yt.streams.filter(subtype = "mp4", res = "480p").first().download() #Hihgest quality elif resolution == "h" : #Note that it will download the video that has the best quality #It might not be 1080p60fps tho yt.streams.filter().first().download() else : #If you don't specify any resolution then we download the highest quality yt.streams.filter().first().download() return title except KeyboardInterrupt : sys.exit("%s [!] Download was interrupted. Exiting...%s" %(red, end)) except : sys.exit("%s [!] Error while downloading to mp3. Exiting...%s" %(red, end))
def download_playlist(): try: clear_screen() url = input('Link of the Playlist (q to quit): ') check_q(url) url = edit_link(url) pl = Playlist(url) window = Tk() print('\nWhere to Save the Playlist: ') path = filedialog.asksaveasfilename(filetypes=(('Video files', ('*.mp4', '*.webm')), ('All files', '*.*'))) window.destroy() pl.download_all(path) system() except: clear_screen() print('Sorry, your Playlist cannot be Downloaded\n') system()
def playlistDownload(llink, output): print() print(llink) print('Accessing Youtube URL...') try: pl = Playlist(llink) print('Downloading...') if (output is None): pl.download_all() else: print('Your file will save to:', output) pl.download_all(output) delete_last_line() print('Completed') except: print( "ERROR. Check your:\n -connection\n -url is a YouTube url\n" + " -add '' to playlist link, example: python yt.py -l 'youtube playlist link'\n" + " -check your location if you add -o, sometime it's different between systems: Mac, Windows, Linux\n" + "\nTry again.")
def get_fetch(): try: if (var1 == None): print("error") dirname = filedialog.askdirectory(parent=Screen, initialdir="/", title='Please select a directory') if (dirname): try: playlist = Playlist(var1.get()) messagebox.showinfo("Download", "Downloading...") playlist.download_all(dirname) messagebox.showinfo(" Downloading.. ", "Thank You.") except: messagebox.showwarning(" FYI.. ", "Failed") else: messagebox.showwarning(" FYI. ", "Cancelled") except: messagebox.showwarning(" FYI. ", "Cancelled") Screen.destroy sys.exit() import YouTubeScreen
def video(self, url, download_folder, logs): logs_file = open(logs, 'a') x = re.search('list=', url) if x is not None: playList = Playlist(url) if playList is None: playList._video_regex = re.compile( r"\"url\":\"(/watch\?v=[\w-]*)") for playlists_url in playList: try: print('Downloading...' + playlists_url) playList.download_all(download_folder) except Exception as ex: logs_file.write('Unable to download: ' + playlists_url + '\t' + str(ex) + '\n') pass else: try: print('Downloading...' + url) self.__download_file(url, download_folder, False) except Exception as ex: logs_file.write('Unable to download: ' + url + '\t' + str(ex)) logs_file.close()
def DownloadVideo(URL, path): playlist = Playlist(URL) print('Number of videos in playlist: %s' % len(playlist.video_urls)) #Saving Video URLs to txt file with open("video_URLs.txt", "w") as output: for e in playlist.video_urls: output.write("%s\n" % e) if not os.path.exists(path): # Create the folder into the chosen path os.mkdir(path) #Download a playlist from YouTube playlist.download_all(path) print("Successfully downloaded the YouTube playlist...") #Rename files [ os.rename(os.path.join(path, f), os.path.join(path, f).replace(' ', '_')) for f in os.listdir(path) ] [ os.rename(os.path.join(path, f), os.path.join(path, f).replace('-', '_')) for f in os.listdir(path) ] [ os.rename(os.path.join(path, f), os.path.join(path, f).replace('&', '_')) for f in os.listdir(path) ] print("Seccussfully renamed the files...") print("Press a key or ctrl+c in order to continue the process", "\n")
class Series_vid_download: def __init__(self, baseurl, downloadfolder="Downloads", on_progress_callback=None, on_complete_callback=None, isaudio=False): self.baseurl = baseurl self.playlist = Playlist(self.baseurl, on_progress_callback=on_progress_callback, on_complete_callback=on_complete_callback, isaudio=isaudio) if self.playlist.title(): self.title = format_filename(self.playlist.title()) else: self.title = format_filename(self.baseurl) self.downloadfolder = downloadfolder def download(self): folder = os.path.join(self.downloadfolder, self.title) if not os.path.exists(folder): os.mkdir(folder) self.playlist.download_all(folder)
def download_videos(addr): try: p_list = Playlist(addr) # 'list' 문자열을 찾지못하면 에러 except KeyError: print('올바른 주소값을 입력해주십시오') return p_list.download_all('./mp3') print('mp4 파일 다운로드를 완료하였습니다.') index = 0 list_len = len(str(len(p_list))) for link in p_list.parse_links(): index += 1 index_str = len(str(index)) if index_str < list_len: index = '0' * (list_len - index_str) + str(index) else: index = str(index) m_addr = 'youtube.com' + link yt = YouTube(m_addr).streams.filter(mime_type="audio/mp4").first() parent_dir = './mp3' default_filename = index + yt.default_filename new_filename = os.path.splitext(default_filename)[0] + '.mp3' print(f'새로운 파일의 이름은 {new_filename}입니다.') subprocess.call([ 'ffmpeg', '-i', os.path.join(parent_dir, default_filename), '-b:a', '192K', '-vn', os.path.join(parent_dir, new_filename) ]) index = int(index) print('mp3 파일 다운로드를 완료하였습니다. mp4 파일을 삭제합니다.') os.remove(os.path.join(parent_dir, default_filename))
def test_download(): ob = Playlist( 'https://www.youtube.com/watch?v=lByG_AgKS9k&list=' 'PL525f8ds9RvuerPZ3bZygmNiYw2sP4BDk', ) ob.download_all()
(1) Download YouTube Videos manually (2) Download a YouTube Playlist (3) Download YouTube Videos and Convert Into MP3 I am not responsible for your downloads! Go at your own risk! Copyright (c) NeuralNine 2019 ''') choice = input("Choice: ") if choice == '2': link = input("Enter the link of the playlist: ") playlist = Playlist(link) print("Downloading Playlist...") playlist.download_all() print("DOWNLOAD DONE!") elif choice == '1' or choice == '3': print("Enter the links of the videos (end by entering 'STOP'):") links = [] link = "" while link != "STOP": link = input() links.append(link) links.pop() for l in links: yt = pytube.YouTube(l)