-
Notifications
You must be signed in to change notification settings - Fork 0
/
ytscratch.py
24 lines (19 loc) · 778 Bytes
/
ytscratch.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import os
from pytube import Playlist
from pytube import YouTube
def get_playlist(playlists):
urls = []
for playlist in playlists:
playlist_urls = Playlist(playlist)
for playlistUrl in playlist_urls:
urls.append(playlistUrl)
return urls
playlists = ["https://www.youtube.com/playlist?list=PLvEI0iOxif001QPlAAQhg688Za2PAfzB-"]
pl_urls = get_playlist(playlists)
for i in range(len(pl_urls)):
pl_urls[i] = pl_urls[i].split("/")[3].split("=")[1]
with open('ytTracks.md', 'w') as w:
for url in pl_urls:
correctURL = "https://www.youtube.com/watch?v=" + url
yt = YouTube(correctURL)
w.writelines("[![Alt text](https://img.youtube.com/vi/" + url + "/0.jpg)](" + correctURL + " \"" + yt.title + "\"" + ")\n")