Advertisement
Najeebsk

YOUTUB-CHANNEL-SCRAP2.py

Mar 14th, 2024 (edited)
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.40 KB | None | 0 0
  1. import os
  2. from tkinter import Tk, Label, Button, Text, Entry, messagebox
  3. from pytube import Playlist
  4. from art import *
  5.  
  6. def install_missing_modules():
  7.     try:
  8.         from pytube import Playlist
  9.         from art import tprint
  10.     except ModuleNotFoundError:
  11.         os.system('pip install pytube')
  12.         os.system('pip install art')
  13.         messagebox.showinfo("Modules Installed", "Required modules have been installed. Please restart the application.")
  14.         exit()
  15.  
  16. def save_playlist_urls(playlists):
  17.     urls = []
  18.     for playlist in playlists:
  19.         playlist_urls = Playlist(playlist)
  20.         for url in playlist_urls:
  21.             urls.append(url)
  22.     with open('plurls.txt', 'w') as f:
  23.         for url in urls:
  24.             f.write(url + '\n')
  25.     messagebox.showinfo("Success", "URLs successfully saved to plurls.txt")
  26.  
  27. def get_playlist():
  28.     playlists = entry.get().split(',')
  29.     save_playlist_urls(playlists)
  30.  
  31. def on_closing():
  32.     if messagebox.askokcancel("Quit", "Do you want to quit?"):
  33.         root.destroy()
  34.  
  35. # GUI setup
  36. root = Tk()
  37. root.title("Najeeb Youtube Channel Urls Scraping")
  38. root.protocol("WM_DELETE_WINDOW", on_closing)
  39.  
  40. label = Label(root, text="Enter playlist URLs (comma separated):")
  41. label.pack()
  42.  
  43. entry = Entry(root, width=50)
  44. entry.pack()
  45.  
  46. button = Button(root, text="Save to Youtube.txt", command=get_playlist)
  47. button.pack()
  48.  
  49. root.mainloop()
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement