Release of old sources

This commit is contained in:
Andrew 2026-02-08 16:05:45 +07:00
commit f3e1fa4222
6 changed files with 214 additions and 0 deletions

67
hivod.py Normal file
View file

@ -0,0 +1,67 @@
import os
import argparse
import youtube_dl
from api import get_authenticated_service, initialize_upload
from settings import Categories, Privacy
SIMULATE = False
def generate_metadata(title: str, description: str, tags: list, category_id: int, privacy_status: str) -> dict:
return {
"snippet": {
"title": title,
"description": description,
"tags": tags,
"categoryId": category_id
},
"status": {
"privacyStatus": privacy_status
}
}
def main(args):
ydl_opts = {"simulate": SIMULATE}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
result = ydl.extract_info(args.vod, download=True)
title = "[VOD] {}".format(result["title"])
u_date = result["upload_date"]
description = "Date: {}.{}.{}\n".format(u_date[6:], u_date[4:6], u_date[:4]) + \
"Streamer: {}\n".format(result["uploader"]) + \
"Support streamer: https://www.twitch.tv/{}\n\n".format(result["uploader_id"]) + \
"VIDEO IS MONETISED NOT BY ME"
fname = "./" + ydl.prepare_filename(result)
if args.title:
title = args.title
if args.description:
description = args.description
print("=====File will be uploaded with this parameters=====")
print("Filename:", fname)
print("Title:", title)
print("Description:", description)
print("====================================================")
metadata = generate_metadata(title, description, [], Categories.ENTERTAINMENT, Privacy.PUBLIC)
video_path = os.path.abspath(fname)
try:
video_id = initialize_upload(get_authenticated_service(), metadata, video_path)
except Exception as e:
print(e)
else:
print("Uploaded video id:", video_id)
print("Removing video file...", end="")
os.unlink(video_path)
print("done")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="High velocity VOD uploader")
parser.add_argument("vod", type=str, help="link to VOD")
parser.add_argument("--title", type=str, help="custom video title")
parser.add_argument("--description", type=str, help="custom video description")
main(parser.parse_args())