Skip to content

Commit 20b2430

Browse files
authored
alternate method
1 parent f99a3ab commit 20b2430

File tree

1 file changed

+6
-27
lines changed

1 file changed

+6
-27
lines changed

youtuber.py

+6-27
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,19 @@
11
import youtube_dl
2-
3-
ydl = youtube_dl.YoutubeDL({'outtmpl': '%(id)s%(ext)s', 'quiet':True,})
4-
video = ""
5-
6-
with ydl:
7-
yt_url=input()
8-
result = ydl.extract_info(yt_url, download=False) #We just want to extract the info
9-
10-
if 'entries' in result:
11-
# Can be a playlist or a list of videos
12-
video = result['entries']
13-
14-
print('| Topic | Video | Presentation |')
15-
print('| ------------- |:-------------:| -----:|')
16-
17-
#loops entries to grab each video_url
18-
for i, item in enumerate(video):
19-
video = result['entries'][i]
20-
# fetch the url and title of video
21-
print('|'+ result['entries'][i]['title'] +'|[Watch Here]('+result['entries'][i]['webpage_url']+')|'+'-|')
22-
23-
#Alternate method
24-
import youtube_dl
252
import os
263

27-
input=' '+input()
4+
# input=' https://www.youtube.com/playlist?list=PLj6h78yzYM2PpmMAnvpvsnR4c27wJePh3'
5+
url=' '+input()
286
start = 1
29-
end = input('Number of videos:')
7+
print("Enter number of videos:")
8+
end = int(input())
309

3110
# For fetching the title of the video in playlist
32-
cmd_code1='py -m youtube_dl -e --playlist-start ' +str(start)+' --playlist-end '+str(end)+input
11+
cmd_code1='py -m youtube_dl -e --playlist-start ' +str(start)+' --playlist-end '+str(end)+url
3312
title = os.popen(cmd_code1).read().splitlines()
3413
#print(title[0])
3514

3615
# For fetching the id of that particular video in playlist
37-
cmd_code2='py -m youtube_dl --get-id --playlist-start ' +str(start)+' --playlist-end '+str(end)+input
16+
cmd_code2='py -m youtube_dl --get-id --playlist-start ' +str(start)+' --playlist-end '+str(end)+url
3817
video_id = os.popen(cmd_code2).read().splitlines()
3918

4019
print('| Topic | Video | Presentation |')

0 commit comments

Comments
 (0)