Mbonea commited on
Commit
36e5180
1 Parent(s): 5dd9398

uploader test

Browse files
Files changed (2) hide show
  1. App/Worker.py +38 -0
  2. Dockerfile +11 -2
App/Worker.py CHANGED
@@ -2,6 +2,7 @@ from celery import Celery, chain
2
  import os, shutil, subprocess
3
  import uuid
4
  from urllib.parse import urlparse
 
5
  from App import celery_config, bot
6
  from typing import List
7
  from App.Editor.Schema import EditorRequest, LinkInfo, Assets, Constants
@@ -9,6 +10,18 @@ from celery.signals import worker_process_init
9
  from asgiref.sync import async_to_sync
10
  import json
11
  import os
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  celery = Celery()
14
  celery.config_from_object(celery_config)
@@ -83,6 +96,31 @@ def install_dependencies(directory: str):
83
  os.system("npm install")
84
 
85
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  @celery.task(name="DownloadAssets")
87
  def download_assets(links: List[LinkInfo], temp_dir: str):
88
  public_dir = f"{temp_dir}/public"
 
2
  import os, shutil, subprocess
3
  import uuid
4
  from urllib.parse import urlparse
5
+ from subprocess import run
6
  from App import celery_config, bot
7
  from typing import List
8
  from App.Editor.Schema import EditorRequest, LinkInfo, Assets, Constants
 
10
  from asgiref.sync import async_to_sync
11
  import json
12
  import os
13
+ from pydantic import BaseModel
14
+
15
+ class YouTubeUploadTask(BaseModel):
16
+ filename: str
17
+ title: str = "Default Title"
18
+ description: str = "Default Description"
19
+ category_id: str = "22" # Default to a generic category, update as needed
20
+ privacy: str = "private"
21
+ tags: str = ""
22
+ thumbnail: str = None
23
+
24
+
25
 
26
  celery = Celery()
27
  celery.config_from_object(celery_config)
 
96
  os.system("npm install")
97
 
98
 
99
+ @celery.task(name="uploadTime")
100
+ def upload_video_to_youtube(task_data: dict):
101
+ # Convert dict to Pydantic model
102
+ task = YouTubeUploadTask(**task_data)
103
+
104
+ # Build the command
105
+ command = [
106
+ '/srv/youtube/youtubeuploader', # Adjust the path as needed
107
+ '-filename', task.filename,
108
+ '-title', task.title,
109
+ '-description', task.description,
110
+ '-categoryId', task.category_id,
111
+ '-privacy', task.privacy,
112
+ '-tags', task.tags
113
+ ]
114
+
115
+ if task.thumbnail:
116
+ command.extend(['-thumbnail', task.thumbnail])
117
+
118
+ # Execute the command
119
+ result = run(command, capture_output=True, text=True)
120
+
121
+ return result.stdout
122
+
123
+
124
  @celery.task(name="DownloadAssets")
125
  def download_assets(links: List[LinkInfo], temp_dir: str):
126
  public_dir = f"{temp_dir}/public"
Dockerfile CHANGED
@@ -33,6 +33,17 @@ RUN apt-get install -y \
33
  libxrandr2 \
34
  xdg-utils
35
 
 
 
 
 
 
 
 
 
 
 
 
36
  # Copy the application code
37
  COPY --chown=admin . /srv
38
 
@@ -47,8 +58,6 @@ RUN npm install npm@latest -g && \
47
 
48
 
49
 
50
- RUN echo npm -v
51
- RUN node -v
52
 
53
  #install the stuff
54
  # RUN cd /srv/Remotion-app && npm install
 
33
  libxrandr2 \
34
  xdg-utils
35
 
36
+ # Download youtubeuploader
37
+ ADD https://github.com/porjo/youtubeuploader/releases/download/23.06/youtubeuploader_23.06_Linux_x86_64.tar.gz youtubeuploader.tar.gz
38
+
39
+
40
+ # Create youtube directory and extract youtubeuploader there
41
+ RUN mkdir -p /srv/youtube && \
42
+ tar -zxvf youtubeuploader.tar.gz -C /srv/youtube && \
43
+ rm youtubeuploader.tar.gz && \
44
+ chmod +x /srv/youtube/youtubeuploader
45
+
46
+
47
  # Copy the application code
48
  COPY --chown=admin . /srv
49
 
 
58
 
59
 
60
 
 
 
61
 
62
  #install the stuff
63
  # RUN cd /srv/Remotion-app && npm install