jdepoix / youtube-transcript-api

This is a python API which allows you to get the transcript/subtitles for a given YouTube video. It also works for automatically generated subtitles and it does not require an API key nor a headless browser, like other selenium based solutions do!
MIT License
2.55k stars 280 forks source link

Access Denied error when trying to save subtitle through a cmd command run via c# app #194

Closed FurkanGozukara closed 1 year ago

FurkanGozukara commented 1 year ago

Here my entire code. I am getting access denied error

        private void btnSubtitles_Click(object sender, RoutedEventArgs e)
        {
            string srVideoId = "m-UVVY_syP0";
            string srBaseFolder = "C:\\style teaching\\subtitles";
            List<string> lstLanguages = new List<string>{"de", "fr"};

            foreach (var vrLang in lstLanguages)
            {
                string srSaveFiled = srBaseFolder + "\\" + "subtitle_" + vrLang + ".vtt";
                string srCmd = @$"/k youtube_transcript_api {srVideoId} --languages en --translate {vrLang} --format webvtt > ""{srBaseFolder}""";
                directExecuteCommand(srCmd);
            }

        }
        private void directExecuteCommand(string cmd)
        {

            System.Diagnostics.ProcessStartInfo processInfo = new System.Diagnostics.ProcessStartInfo("CMD.exe", cmd);
            processInfo.Verb = "runas"; // This sets the process to run as administrator
            System.Diagnostics.Process.Start(processInfo);
        }

image

I am using same strategy in whisper transcribe and it works very well

When I remove --format webvtt > ""{srBaseFolder}"" it works very well and prints translation

FurkanGozukara commented 1 year ago

@jdepoix

jdepoix commented 1 year ago

Since removing --format webvtt > ""{srBaseFolder}"" fixes it, it sounds like you don't have access to the folder you are trying to write the result to.

I will close this as this is not an issue with the module.