Advertisement
Najeebsk

YOUTUB-CHANNEL-SCRAP.py

Mar 14th, 2024
766
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import os
  2. try:
  3.     from pytube import Playlist
  4.     from art import tprint
  5. except ModuleNotFoundError:
  6.     os.system('pip install pytube')
  7.     os.system('pip install art')
  8.     from pytube import Playlist
  9.     from art import tprint
  10.  
  11. tprint("NajeebYTBot")
  12. print("Developed by Najeeb Shah Khan")
  13. print("-------------------------------------")
  14.  
  15. # create a function to get urls from list of playlist
  16. def get_playlist(playlists):
  17.     urls = []
  18.     # iteratively get watch links from playlist
  19.     for playlist in playlists:
  20.         playlist_urls = Playlist(playlist)
  21.         for url in playlist_urls:
  22.             urls.append(url)
  23.     return urls
  24.  
  25. # code driver
  26. playlists = ['https://www.youtube.com/playlist?list=PLCSCKIX4Tq5ZERz4gRsqtEhVhKMiJs-wD',
  27.              'https://www.youtube.com/playlist?list=PLCSCKIX4Tq5a_0XOwL3ygCpLxwi0OVikN']
  28. pl_urls = get_playlist(playlists)
  29.  
  30. with open('plurls.txt', 'w') as f:
  31.     for url in pl_urls:
  32.         f.write(url + '\n')
  33. print("Urls successfully saved into os.getcwd()")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement