コード例 #1
0
ファイル: AddVideosForm.cs プロジェクト: strohitv/stfu-save
        private void loadWorker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            var publishTimeCalculators = PathInfos
                                         .Select(p => new ObservationConfiguration(p, FindTemplate(p, Templates)))
                                         .Select(pto => new PublishTimeCalculator(
                                                     pto.PathInfo,
                                                     pto.StartDate,
                                                     pto.Template,
                                                     pto.HasCustomStartDayIndex ? pto.CustomStartDayIndex : null))
                                         .ToList();

            TemplateVideoCreator = new TemplateVideoCreator(publishTimeCalculators, PscContainer);

            AddVideos(Paths);
        }
コード例 #2
0
ファイル: AddVideosForm.cs プロジェクト: strohitv/stfu-save
        private void insertTemplatesButton_Click(object sender, System.EventArgs e)
        {
            SelectTemplateDialog dialog = new SelectTemplateDialog();

            dialog.Templates = Templates;

            var result = dialog.ShowDialog(this);

            if (result == DialogResult.OK)
            {
                var template = dialog.SelectedTemplate;
                foreach (int index in videosListView.SelectedIndices)
                {
                    Videos[index] = TemplateVideoCreator.CreateVideo(Videos[index].Video.Path, new PublishTimeCalculator(null, template));

                    if (videosListView.SelectedIndices.Count == 1)
                    {
                        editVideoInformationGrid.Fill(Videos[videosListView.SelectedIndices[0]].Video, Videos[videosListView.SelectedIndices[0]].NotificationSettings, Account.Access.First().HasSendMailPrivilegue, CategoryContainer, LanguageContainer, PlaylistContainer, PscContainer);
                    }
                }
            }
        }
コード例 #3
0
ファイル: AutomationUploader.cs プロジェクト: StrohiZock/STFU
        private void Start(PublishSettings[] settings)
        {
            IsActive = true;

            ProcessWatcher.AllProcessesCompleted += AllProcessesCompleted;

            Files.Clear();
            Watchers.Clear();

            var publishInfos = new List <PublishInformation>();

            foreach (var pathSetting in settings)
            {
                var newInfo = new PublishInformation(pathSetting.PathInfo, pathSetting.StartDate, pathSetting.Template, pathSetting.CustomStartDayIndex);
                newInfo.IgnorePath    = pathSetting.IgnorePath;
                newInfo.UploadPrivate = pathSetting.UploadPrivate;

                publishInfos.Add(newInfo);
            }

            creator = new TemplateVideoCreator(publishInfos);

            TryConnectAccount();
            if (ActiveAccount.Access?.AccessToken == null)
            {
                Message  = "FEHLER: Verbindung zum Youtube-Account konnte nicht hergestellt werden.";
                Progress = 0;
                return;
            }

            UnfinishedJob = LoadLastJob();
            UploadFilesAsync();

            CreateWatchers(publishInfos.ToArray());

            SearchExistingVideos(publishInfos.ToArray());
        }
コード例 #4
0
ファイル: AutomationUploader.cs プロジェクト: StrohiZock/STFU
        private void UploadVideo(string fileName, TemplateVideoCreator creator)
        {
            Video vid = creator.CreateVideo(fileName);

            bool waitResult = WaitForAccess(fileName);

            if (!waitResult)
            {
                // Video wurde gelöscht.
                return;
            }

            OnUploadStarted(vid.Title);

            Job job = null;

            while (job == null)
            {
                RefreshAccess();
                job = UploadCommunication.PrepareUpload(vid, ActiveAccount);
            }

            UploadJob(job);
        }
コード例 #5
0
        private void Start(IList <PublishTimeCalculator> infos)
        {
            LOGGER.Info($"Starting auto uploader");
            if (Account == null || Uploader == null)
            {
                LOGGER.Error($"Either the account or the uploader were not set - can't start auto uploader!");
                return;
            }

            State = RunningState.Running;

            WatchedProcesses.ProcessesCompleted += OnProcessesCompleted;

            VideoCreator = new TemplateVideoCreator(infos, PscContainer);

            Uploader.PropertyChanged    += UploaderPropertyChanged;
            Searcher.PropertyChanged    += SearcherPropertyChanged;
            Uploader.StopAfterCompleting = false;

            Searcher.FileFound         += OnFileToUploadOccured;
            DirectoryWatcher.FileAdded += OnFileToUploadOccured;

            foreach (var config in Configuration.Where(c => !c.IgnorePath && Directory.Exists(c.PathInfo.Fullname)))
            {
                LOGGER.Info($"Starting file searcher and directory watcher for configuration for template '{config.Template.Name}' and path '{config.PathInfo.Fullname}'");

                var pathInfo = config.PathInfo;
                Searcher.SearchFilesAsync(pathInfo.Fullname, pathInfo.Filter, pathInfo.SearchRecursively, pathInfo.SearchHidden, pathInfo.SearchOrder);
                DirectoryWatcher.AddWatcher(pathInfo.Fullname, pathInfo.Filter, pathInfo.SearchRecursively);
            }

            LOGGER.Info($"Starting youtube uploader");
            Uploader.StartUploader();

            LOGGER.Info($"Auto uploader was started successfully");
        }
コード例 #6
0
ファイル: AddVideosForm.cs プロジェクト: strohitv/stfu-save
        private void AddVideos(string[] paths)
        {
            var videosWithPaths = paths.Select(p => new FileInfo(p))
                                  .Select(f => new KeyValuePair <FileInfo, IPath>(f, TemplateVideoCreator.FindNearestPath(f.FullName)))
                                  .ToArray();

            var sortedPaths = new Dictionary <IPath, List <FileInfo> >();

            foreach (var videoWithPath in videosWithPaths)
            {
                IPath path = videoWithPath.Value;

                if (path == null)
                {
                    path = new Youtube.Automation.Paths.Path()
                    {
                        Fullname           = videoWithPath.Key.DirectoryName,
                        SelectedTemplateId = 0
                    };
                }

                if (sortedPaths.ContainsKey(path))
                {
                    sortedPaths[path].Add(videoWithPath.Key);
                }
                else
                {
                    sortedPaths.Add(path, new List <FileInfo>(new[] { videoWithPath.Key }));
                }
            }

            foreach (var key in sortedPaths.Keys)
            {
                var sorted = new List <FileInfo>();

                switch (key.SearchOrder)
                {
                case FoundFilesOrderByFilter.NameAsc:
                    sorted = sortedPaths[key].OrderBy(fi => fi.Name).ToList();
                    break;

                case FoundFilesOrderByFilter.NameDsc:
                    sorted = sortedPaths[key].OrderByDescending(fi => fi.Name).ToList();
                    break;

                case FoundFilesOrderByFilter.CreationDateAsc:
                    sorted = sortedPaths[key].OrderBy(fi => fi.CreationTimeUtc).ToList();
                    break;

                case FoundFilesOrderByFilter.CreationDateDsc:
                    sorted = sortedPaths[key].OrderByDescending(fi => fi.CreationTimeUtc).ToList();
                    break;

                case FoundFilesOrderByFilter.ChangedDateAsc:
                    sorted = sortedPaths[key].OrderBy(fi => fi.LastWriteTimeUtc).ToList();
                    break;

                case FoundFilesOrderByFilter.ChangedDateDsc:
                    sorted = sortedPaths[key].OrderByDescending(fi => fi.LastWriteTimeUtc).ToList();
                    break;

                case FoundFilesOrderByFilter.SizeAsc:
                    sorted = sortedPaths[key].OrderBy(fi => fi.Length).ToList();
                    break;

                case FoundFilesOrderByFilter.SizeDsc:
                    sorted = sortedPaths[key].OrderByDescending(fi => fi.Length).ToList();
                    break;
                }

                Videos.AddRange(sorted.Select(fi => TemplateVideoCreator.CreateVideo(fi.FullName, false)));
            }
        }
コード例 #7
0
ファイル: AddVideosForm.cs プロジェクト: strohitv/stfu-save
 private void acceptButton_Click(object sender, System.EventArgs e)
 {
     DialogResult = DialogResult.OK;
     TemplateVideoCreator.SaveNextUploadSuggestions();
     Close();
 }