@@ -92,9 +92,7 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
9292 return fmt .Errorf ("error building OAuth client: %w" , err )
9393 }
9494
95- upload := & youtube.Video {}
96-
97- videoMeta , err := LoadVideoMeta (config , upload )
95+ videoMeta , uploadVideo , err := LoadVideoMeta (config )
9896 if err != nil {
9997 return fmt .Errorf ("error loading video meta data: %w" , err )
10098 }
@@ -111,28 +109,28 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
111109 }
112110
113111 var option googleapi.MediaOption
114- var video * youtube.Video
112+ var resultVideo * youtube.Video
115113
116114 option = googleapi .ChunkSize (config .Chunksize )
117115
118- call := service .Videos .Insert ([]string {"snippet" , "status" , "recordingDetails" }, upload )
116+ call := service .Videos .Insert ([]string {"snippet" , "status" , "localizations" , " recordingDetails" }, uploadVideo )
119117 if config .SendFileName && config .Filename != "-" {
120118 filetitle := filepath .Base (config .Filename )
121119 slog .Debug ("adding file name to request" , "file" , filetitle )
122120 call .Header ().Set ("Slug" , filetitle )
123121 }
124- video , err = call .NotifySubscribers (config .NotifySubscribers ).Media (videoReader , option ).Do ()
122+ resultVideo , err = call .NotifySubscribers (config .NotifySubscribers ).Media (videoReader , option ).Do ()
125123 if err != nil {
126- if video != nil {
127- return fmt .Errorf ("error making YouTube API call: %w, %v" , err , video .HTTPStatusCode )
124+ if resultVideo != nil {
125+ return fmt .Errorf ("error making YouTube API call: %w, %v" , err , resultVideo .HTTPStatusCode )
128126 } else {
129127 return fmt .Errorf ("error making YouTube API call: %w" , err )
130128 }
131129 }
132- fmt .Printf ("\n Upload successful! Video ID: %v\n " , video .Id )
130+ fmt .Printf ("\n Upload successful! Video ID: %v\n " , resultVideo .Id )
133131
134132 if config .MetaJSONOut != "" {
135- JSONOut , _ := json .Marshal (video )
133+ JSONOut , _ := json .Marshal (resultVideo )
136134 err = os .WriteFile (config .MetaJSONOut , JSONOut , 0666 )
137135 if err != nil {
138136 return fmt .Errorf ("error writing to video metadata file %q: %w" , config .MetaJSONOut , err )
@@ -142,7 +140,7 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
142140
143141 if thumbReader != nil {
144142 fmt .Printf ("Uploading thumbnail %q...\n " , config .Thumbnail )
145- _ , err = service .Thumbnails .Set (video .Id ).Media (thumbReader ).Do ()
143+ _ , err = service .Thumbnails .Set (resultVideo .Id ).Media (thumbReader ).Do ()
146144 if err != nil {
147145 return fmt .Errorf ("error making YouTube API call: %w" , err )
148146 }
@@ -154,7 +152,7 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
154152 captionObj := & youtube.Caption {
155153 Snippet : & youtube.CaptionSnippet {},
156154 }
157- captionObj .Snippet .VideoId = video .Id
155+ captionObj .Snippet .VideoId = resultVideo .Id
158156 captionObj .Snippet .Language = config .Language
159157 captionObj .Snippet .Name = config .Language
160158 captionInsert := service .Captions .Insert ([]string {"snippet" }, captionObj ).Sync (true )
@@ -169,15 +167,15 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
169167 }
170168
171169 plx := & Playlistx {}
172- if upload .Status .PrivacyStatus != "" {
173- plx .PrivacyStatus = upload .Status .PrivacyStatus
170+ if uploadVideo .Status .PrivacyStatus != "" {
171+ plx .PrivacyStatus = uploadVideo .Status .PrivacyStatus
174172 }
175173
176174 if len (videoMeta .PlaylistIDs ) > 0 {
177175 plx .Title = ""
178176 for _ , pid := range videoMeta .PlaylistIDs {
179177 plx .Id = pid
180- err = plx .AddVideoToPlaylist (service , video .Id )
178+ err = plx .AddVideoToPlaylist (service , resultVideo .Id )
181179 if err != nil {
182180 return fmt .Errorf ("error adding video to playlist: %w" , err )
183181 }
@@ -188,7 +186,7 @@ func Run(ctx context.Context, transport *limiter.LimitTransport, config Config,
188186 plx .Id = ""
189187 for _ , title := range videoMeta .PlaylistTitles {
190188 plx .Title = title
191- err = plx .AddVideoToPlaylist (service , video .Id )
189+ err = plx .AddVideoToPlaylist (service , resultVideo .Id )
192190 if err != nil {
193191 return fmt .Errorf ("error adding video to playlist: %w" , err )
194192 }
0 commit comments