Beispiel #1
0
        private void TryConnectAccount()
        {
            // Es muss sichergestellt sein, dass ein Account verbunden ist.
            for (int i = 0; i < 3 && ActiveAccount.Access?.AccessToken == null; i++)
            {
                for (int j = 0; j < 30 && i > 0; j++)
                {
                    Message = $"Verbindung zum Youtube-Account konnte nicht hergestellt werden. Erneuter Versuch in {30 - j} Sekunden...";
                    Thread.Sleep(1000);
                }

                Message       = $"Stelle Verbindung zum Youtube-Account her - Versuch {i + 1} von 3...";
                ActiveAccount = AccountCommunication.RefreshAccess(ActiveAccount);
            }
        }
Beispiel #2
0
        public void GetVideoIdsForPlaylist(string rToken, string playlistId)
        {
            var acc = AccountCommunication.RefreshAccess(new Account()
            {
                Access = new Authentification()
                {
                    RefreshToken = rToken
                }
            });
            var videoIdList = WebService.GetPlaylistItems(acc.Access.AccessToken, playlistId);

            foreach (var videoId in videoIdList)
            {
                Trace.WriteLine(videoId);
            }
        }
Beispiel #3
0
        private void UploadJob(Job job)
        {
            if (!File.Exists(job.SelectedVideo.Path))
            {
                DeleteLastJobFile();
                return;
            }

            SaveCurrentJob(job);

            UploadCommunication.ProgressChanged += ReactToProgressChanged;
            while (!UploadCommunication.Upload(ref job, ref shouldCancel))
            {
                job.UploadingAccount = AccountCommunication.RefreshAccess(job.UploadingAccount);
            }

            UploadCommunication.ProgressChanged -= ReactToProgressChanged;

            if (!shouldCancel)
            {
                OnUploadFinished(job.SelectedVideo.Title);
                DeleteLastJobFile();

                // Datei umbenennen, damit der Uploader nicht erneut versucht, sie hochzuladen.
                var movedPath = Path.GetDirectoryName(job.SelectedVideo.Path)
                                + "\\_" + Path.GetFileNameWithoutExtension(job.SelectedVideo.Path).Remove(0, 1)
                                + Path.GetExtension(job.SelectedVideo.Path);

                try
                {
                    File.Move(job.SelectedVideo.Path, movedPath);
                }
                catch (IOException)
                {
                }
            }
        }
Beispiel #4
0
 private void RefreshAccess()
 {
     ActiveAccount = AccountCommunication.RefreshAccess(ActiveAccount);
 }