-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
executable file
·23 lines (18 loc) · 895 Bytes
/
example.py
File metadata and controls
executable file
·23 lines (18 loc) · 895 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python3
"""Example usage of YouTube Downloader"""
from ytd.cli import main
import sys
if __name__ == '__main__':
# Example 1: Download a video
print("Example 1: Downloading a video...")
sys.argv = ['ytd', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', '-o', './downloads']
# main() # Uncomment to actually download
# Example 2: Download audio only
print("\nExample 2: Downloading audio only...")
sys.argv = ['ytd', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', '-a', '--audio-format', 'mp3']
# main() # Uncomment to actually download
# Example 3: List formats
print("\nExample 3: Listing available formats...")
sys.argv = ['ytd', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ', '--list-formats']
# main() # Uncomment to list formats
print("\nTo run these examples, uncomment the main() calls in the script!")