Skip to content

Commit d4b8986

Browse files
committed
- Add updates
1 parent 533ec6a commit d4b8986

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

youtool/cli.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,46 @@
22

33

44
def main():
5+
<<<<<<< HEAD
56
parser = argparse.ArgumentParser()
67
parser.add_argument("--api-key")
78
subparsers = parser.add_subparsers(required=True, dest="command")
9+
=======
10+
"""Main function for the YouTube CLI Tool.
11+
>>>>>>> 7133ae0 (- Add updates)
812
913
api_key = args.api_key or os.environ.get("YOUTUBE_API_KEY")
1014
15+
<<<<<<< HEAD
1116
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)")
1217
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)")
1318
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)")
1419
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)")
1520
cmd_video_comments = subparsers.add_parser("video-comments", help="Get comments from a video ID, generate CSV output (same schema for `comment` dicts)")
1621
cmd_video_livechat = subparsers.add_parser("video-livechat", help="Get comments from a video ID, generate CSV output (same schema for `chat_message` dicts)")
1722
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)
1845

1946
args = parser.parse_args()
2047

0 commit comments

Comments
 (0)