Palash Goel
commited on
Commit
·
7b27fb4
1
Parent(s):
d625b83
Added an option to show a list of available vidoes in cli. #65
Browse files- pytube/__main__.py +9 -1
pytube/__main__.py
CHANGED
@@ -23,6 +23,8 @@ def main():
|
|
23 |
dest="path", help=("The path to save the video to."))
|
24 |
parser.add_argument("--filename", "-f", dest="filename", help=(
|
25 |
"The filename, without extension, to save the video in."))
|
|
|
|
|
26 |
|
27 |
args = parser.parse_args()
|
28 |
|
@@ -32,11 +34,17 @@ def main():
|
|
32 |
for i, video in enumerate(yt.get_videos()):
|
33 |
ext = video.extension
|
34 |
res = video.resolution
|
35 |
-
videos.append("{} {}".format(ext, res))
|
36 |
except PytubeError:
|
37 |
print("Incorrect video URL.")
|
38 |
sys.exit(1)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
if args.filename:
|
41 |
yt.set_filename(args.filename)
|
42 |
|
|
|
23 |
dest="path", help=("The path to save the video to."))
|
24 |
parser.add_argument("--filename", "-f", dest="filename", help=(
|
25 |
"The filename, without extension, to save the video in."))
|
26 |
+
parser.add_argument("--show_available", "-s", action='store_true',
|
27 |
+
dest='show_available', help=("Prints a list of available formats for download."))
|
28 |
|
29 |
args = parser.parse_args()
|
30 |
|
|
|
34 |
for i, video in enumerate(yt.get_videos()):
|
35 |
ext = video.extension
|
36 |
res = video.resolution
|
37 |
+
videos.append("{:<15} {:<15}".format(ext, res))
|
38 |
except PytubeError:
|
39 |
print("Incorrect video URL.")
|
40 |
sys.exit(1)
|
41 |
|
42 |
+
if args.show_available:
|
43 |
+
print("{:<15} {:<15}".format("Resolution", "Extension"))
|
44 |
+
print("-"*25)
|
45 |
+
print("\n".join(videos))
|
46 |
+
sys.exit(0)
|
47 |
+
|
48 |
if args.filename:
|
49 |
yt.set_filename(args.filename)
|
50 |
|