|
2 | 2 |
|
3 | 3 |
|
4 | 4 | def main(): |
| 5 | +<<<<<<< HEAD |
5 | 6 | parser = argparse.ArgumentParser() |
6 | 7 | parser.add_argument("--api-key") |
7 | 8 | subparsers = parser.add_subparsers(required=True, dest="command") |
| 9 | +======= |
| 10 | + """Main function for the YouTube CLI Tool. |
| 11 | +>>>>>>> 7133ae0 (- Add updates) |
8 | 12 |
|
9 | 13 | api_key = args.api_key or os.environ.get("YOUTUBE_API_KEY") |
10 | 14 |
|
| 15 | +<<<<<<< HEAD |
11 | 16 | cmd_channel_id = subparsers.add_parser("channel-id", help="Get channel IDs from a list of URLs (or CSV filename with URLs inside), generate CSV output (just the IDs)") |
12 | 17 | cmd_channel_info = subparsers.add_parser("channel-info", help="Get channel info from a list of IDs (or CSV filename with IDs inside), generate CSV output (same schema for `channel` dicts)") |
13 | 18 | cmd_video_info = subparsers.add_parser("video-info", help="Get video info from a list of IDs or URLs (or CSV filename with URLs/IDs inside), generate CSV output (same schema for `video` dicts)") |
14 | 19 | cmd_video_search = subparsers.add_parser("video-search", help="Get video info from a list of IDs or URLs (or CSV filename with URLs/IDs inside), generate CSV output (simplified `video` dict schema or option to get full video info after)") |
15 | 20 | cmd_video_comments = subparsers.add_parser("video-comments", help="Get comments from a video ID, generate CSV output (same schema for `comment` dicts)") |
16 | 21 | cmd_video_livechat = subparsers.add_parser("video-livechat", help="Get comments from a video ID, generate CSV output (same schema for `chat_message` dicts)") |
17 | 22 | cmd_video_transcriptions = subparsers.add_parser("video-transcription", help="Download video transcriptions based on language code, path and list of video IDs or URLs (or CSV filename with URLs/IDs inside), download files to destination and report results") |
| 23 | +======= |
| 24 | + Finally, the function executes the appropriate command based on the parsed arguments. If an exception occurs |
| 25 | + during the execution of the command, it is caught and raised as an argparse error for proper handling. |
| 26 | +
|
| 27 | + Raises: |
| 28 | + argparse.ArgumentError: If the YouTube API key is not provided. |
| 29 | + argparse.ArgumentError: If there is an error during the execution of the command. |
| 30 | + """ |
| 31 | + parser = argparse.ArgumentParser(description="CLI Tool for managing YouTube videos add playlists") |
| 32 | + parser.add_argument("--api-key", type=str, help="YouTube API Key", dest="api_key") |
| 33 | + parser.add_argument("--debug", type=bool, help="Debug mode", dest="debug") |
| 34 | + |
| 35 | + subparsers = parser.add_subparsers(required=True, dest="command", title="Command", help="Command to be executed") |
| 36 | + |
| 37 | + # cmd_video_search = subparsers.add_parser("video-search", help="Get video info from a list of IDs or URLs (or CSV filename with URLs/IDs inside), generate CSV output (simplified `video` dict schema or option to get full video info after)") |
| 38 | + # cmd_video_comments = subparsers.add_parser("video-comments", help="Get comments from a video ID, generate CSV output (same schema for `comment` dicts)") |
| 39 | + # cmd_video_livechat = subparsers.add_parser("video-livechat", help="Get comments from a video ID, generate CSV output (same schema for `chat_message` dicts)") |
| 40 | + # cmd_video_transcriptions = subparsers.add_parser("video-transcription", help="Download video transcriptions based on language code, path and list of video IDs or URLs (or CSV filename with URLs/IDs inside), download files to destination and report results") |
| 41 | + |
| 42 | + for command in COMMANDS: |
| 43 | + command.parse_arguments(subparsers) |
| 44 | +>>>>>>> 7133ae0 (- Add updates) |
18 | 45 |
|
19 | 46 | args = parser.parse_args() |
20 | 47 |
|
|
0 commit comments