|
1 | 1 | 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 |
25 | 2 | import os
|
26 | 3 |
|
27 |
| -input=' '+input() |
| 4 | +# input=' https://www.youtube.com/playlist?list=PLj6h78yzYM2PpmMAnvpvsnR4c27wJePh3' |
| 5 | +url=' '+input() |
28 | 6 | start = 1
|
29 |
| -end = input('Number of videos:') |
| 7 | +print("Enter number of videos:") |
| 8 | +end = int(input()) |
30 | 9 |
|
31 | 10 | # 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 |
33 | 12 | title = os.popen(cmd_code1).read().splitlines()
|
34 | 13 | #print(title[0])
|
35 | 14 |
|
36 | 15 | # 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 |
38 | 17 | video_id = os.popen(cmd_code2).read().splitlines()
|
39 | 18 |
|
40 | 19 | print('| Topic | Video | Presentation |')
|
|
0 commit comments