-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
executable file
·221 lines (177 loc) · 6.67 KB
/
cli.py
File metadata and controls
executable file
·221 lines (177 loc) · 6.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/usr/bin/env python3
"""
Command-line interface for dual-platform video uploader
For NoblePort Systems
"""
import sys
import argparse
from youtube_uploader import YouTubeUploader, YOUTUBE_CATEGORIES
from dtube_uploader import DtubeUploader, check_ipfs_daemon
from config import CopyrightPolicy
import json
def print_banner():
"""Print application banner"""
print("="*70)
print(" Dual-Platform Video Uploader - CLI")
print(" NoblePort Systems")
print(" YouTube & DTube Upload Tool")
print("="*70)
print()
def show_copyright_comparison():
"""Display copyright policy comparison"""
comparison = CopyrightPolicy.get_comparison()
print("\n" + "="*70)
print("COPYRIGHT POLICY COMPARISON")
print("="*70)
# YouTube
yt = comparison['youtube']
print(f"\nYOUTUBE:")
print(f" Risk Level: {yt['risk_level']}")
print(f" Enforcement: {yt['enforcement']}")
print(f" Automated Scanning: {'Yes' if yt['automated_scanning'] else 'No'}")
print(f" Strictness: {yt['strictness']}")
# DTube
dt = comparison['dtube']
print(f"\nDTUBE:")
print(f" Risk Level: {dt['risk_level']}")
print(f" Enforcement: {dt['enforcement']}")
print(f" Automated Scanning: {'Yes' if dt['automated_scanning'] else 'No'}")
print(f" Strictness: {dt['strictness']}")
# Summary
print(f"\nRECOMMENDATIONS:")
summary = comparison['summary']
for key, value in summary.items():
print(f" {key.replace('_', ' ').title()}: {value}")
print("="*70 + "\n")
def upload_to_youtube(args):
"""Upload video to YouTube"""
print("\nInitializing YouTube upload...")
uploader = YouTubeUploader()
# Authenticate
print("Authenticating with YouTube...")
try:
uploader.authenticate()
channel = uploader.get_channel_info()
if channel:
print(f"Authenticated as: {channel['title']}")
except Exception as e:
print(f"Authentication failed: {e}")
return False
# Upload video
result = uploader.upload_video(
file_path=args.video,
title=args.title,
description=args.description or '',
category=args.category,
privacy=args.privacy,
tags=args.tags.split(',') if args.tags else [],
check_copyright=not args.skip_warnings
)
if result['success']:
print(f"\n{'='*70}")
print("UPLOAD SUCCESSFUL!")
print(f"{'='*70}")
print(f"Platform: YouTube")
print(f"Video ID: {result['video_id']}")
print(f"URL: {result['url']}")
print(f"{'='*70}\n")
return True
else:
print(f"\nUpload failed: {result['error']}\n")
return False
def upload_to_dtube(args):
"""Upload video to DTube"""
print("\nInitializing DTube upload...")
# Check IPFS daemon
if not check_ipfs_daemon():
print("\nERROR: IPFS daemon must be running for DTube uploads.")
print("Please start IPFS daemon with: ipfs daemon")
return False
uploader = DtubeUploader()
# Upload video
result = uploader.upload_video(
file_path=args.video,
title=args.title,
description=args.description or '',
tags=args.tags.split(',') if args.tags else [],
check_copyright=not args.skip_warnings
)
if result['success']:
print(f"\n{'='*70}")
print("UPLOAD SUCCESSFUL!")
print(f"{'='*70}")
print(f"Platform: DTube")
print(f"IPFS Hash: {result['ipfs_hash']}")
print(f"DTube URL: {result['url']}")
print(f"IPFS Gateway: {result['ipfs_gateway']}")
if 'note' in result:
print(f"\nNote: {result['note']}")
print(f"{'='*70}\n")
return True
else:
print(f"\nUpload failed: {result['error']}\n")
return False
def main():
"""Main CLI function"""
parser = argparse.ArgumentParser(
description='Dual-Platform Video Uploader for YouTube and DTube',
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Upload to YouTube
python cli.py upload --platform youtube --video myvideo.mp4 --title "My Video"
# Upload to DTube
python cli.py upload --platform dtube --video myvideo.mp4 --title "My Video"
# Upload to both platforms
python cli.py upload --platform both --video myvideo.mp4 --title "My Video"
# Show copyright comparison
python cli.py compare
# List YouTube categories
python cli.py categories
"""
)
subparsers = parser.add_subparsers(dest='command', help='Commands')
# Upload command
upload_parser = subparsers.add_parser('upload', help='Upload video to platform(s)')
upload_parser.add_argument('--video', required=True, help='Path to video file')
upload_parser.add_argument('--title', required=True, help='Video title')
upload_parser.add_argument('--description', help='Video description')
upload_parser.add_argument('--tags', help='Comma-separated tags')
upload_parser.add_argument('--platform', choices=['youtube', 'dtube', 'both'],
default='youtube', help='Upload platform')
upload_parser.add_argument('--privacy', choices=['public', 'private', 'unlisted'],
default='private', help='YouTube privacy setting')
upload_parser.add_argument('--category', default='22',
help='YouTube category ID (default: 22 = People & Blogs)')
upload_parser.add_argument('--skip-warnings', action='store_true',
help='Skip copyright warnings')
# Compare command
subparsers.add_parser('compare', help='Show copyright policy comparison')
# Categories command
subparsers.add_parser('categories', help='List YouTube categories')
# IPFS check command
subparsers.add_parser('check-ipfs', help='Check IPFS daemon status')
args = parser.parse_args()
print_banner()
if args.command == 'upload':
success = True
if args.platform in ['youtube', 'both']:
success = upload_to_youtube(args) and success
if args.platform in ['dtube', 'both']:
success = upload_to_dtube(args) and success
sys.exit(0 if success else 1)
elif args.command == 'compare':
show_copyright_comparison()
elif args.command == 'categories':
print("\nYouTube Categories:")
print("="*70)
for cat_id, cat_name in sorted(YOUTUBE_CATEGORIES.items(), key=lambda x: int(x[0])):
print(f" {cat_id:>3}: {cat_name}")
print("="*70 + "\n")
elif args.command == 'check-ipfs':
print("\nChecking IPFS daemon status...")
check_ipfs_daemon()
else:
parser.print_help()
if __name__ == '__main__':
main()