-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathposter.py
37 lines (31 loc) · 1.13 KB
/
poster.py
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
from enum import Enum
from api import ChannelApi
from util import clean_filename
from util import open_video_info
class VideoPoster:
"""Handles posting videos to youtube channel."""
class Privacy(Enum):
PRIVATE = 'private',
PUBLIC = 'public',
UNLISTED = 'unlisted'
def __init__(self, privacy: Privacy):
self.api = ChannelApi()
self.privacy = privacy
def post_video(self, title, folder, video_extension):
"""
Posts video to youtube channel.
:param title: Video title.
:param folder: Folder to get video data from.
:param video_extension: Extension of video file.
"""
print(f"Posting {title}")
print(f"{folder}\\data.json")
video_data = open_video_info(f"{folder}\\"
f"data.json")
print(f"{video_data}")
video_path = f"{folder}\\"\
f"{clean_filename(title)}.{video_extension}"
print(f"{video_path}")
print(f"{self.privacy}")
self.api.initialize_upload(video_data, video_path, self.privacy)
print(f"Posted {title}")