diff --git a/SCrawler.YouTube/Controls/VideoOptionsForm.vb b/SCrawler.YouTube/Controls/VideoOptionsForm.vb index 28ceaa7..b8010e9 100644 --- a/SCrawler.YouTube/Controls/VideoOptionsForm.vb +++ b/SCrawler.YouTube/Controls/VideoOptionsForm.vb @@ -433,6 +433,27 @@ Namespace API.YouTube.Controls End Sub #End Region #Region "Footer" + Private _FilePathBeforeItemChange As SFile = Nothing + Private Sub TXT_FILE_ActionSelectedItemBeforeChanged(ByVal Sender As Object, ByVal e As EventArgs, ByVal Item As ListViewItem) Handles TXT_FILE.ActionSelectedItemBeforeChanged + If Not TXT_FILE.Text.IsEmptyString Then _FilePathBeforeItemChange = TXT_FILE.Text Else _FilePathBeforeItemChange = Nothing + End Sub + Private Sub TXT_FILE_ActionSelectedItemChanged(ByVal Sender As Object, ByVal e As EventArgs, ByVal Item As ListViewItem) Handles TXT_FILE.ActionSelectedItemChanged + Try + If Not MyContainer.HasElements Then + Dim currentPath As SFile = _FilePathBeforeItemChange + Dim newPath As SFile = TXT_FILE.Text.CSFileP + If Not currentPath.File.IsEmptyString Then + newPath.Name = currentPath.Name + newPath.Extension = currentPath.Extension + TXT_FILE.Text = newPath + End If + End If + Catch ex As Exception + ErrorsDescriber.Execute(EDP.SendToLog, ex, "[API.YouTube.Controls.VideoOptionsForm.ChangeDestinationPath]") + Finally + _FilePathBeforeItemChange = Nothing + End Try + End Sub Private Sub BTT_BROWSE_MouseDown(sender As Object, e As MouseEventArgs) Handles BTT_BROWSE.MouseDown Dim f As SFile #Disable Warning BC40000 diff --git a/SCrawler.YouTube/Objects/YouTubeMediaContainerBase.vb b/SCrawler.YouTube/Objects/YouTubeMediaContainerBase.vb index 0d2dbc3..cd01870 100644 --- a/SCrawler.YouTube/Objects/YouTubeMediaContainerBase.vb +++ b/SCrawler.YouTube/Objects/YouTubeMediaContainerBase.vb @@ -1060,7 +1060,11 @@ Namespace API.YouTube.Objects If fc.Exists(SFO.Path, False) AndAlso SFile.GetFiles(fc, "*.json",, EDP.ReturnValue).Count > 0 Then Parse(Nothing, fc, IsMusic) XMLPopulateData(Me, x) _MediaStateOnLoad = _MediaState - _Exists = True + If Me.MediaState = UMStates.Downloaded Then + _Exists = File.Exists(IIf(ObjectType = YouTubeMediaType.Single, SFO.File, SFO.Path), False) + Else + _Exists = True + End If If If(x(Name_CheckedElements)?.Count, 0) > 0 Then ApplyElementCheckedValue(x(Name_CheckedElements)) If ArrayMaxResolution <> -10 Then SetMaxResolution(ArrayMaxResolution) End Using diff --git a/SCrawler/API/Base/UserDataBase.vb b/SCrawler/API/Base/UserDataBase.vb index 0a7e17e..b9be328 100644 --- a/SCrawler/API/Base/UserDataBase.vb +++ b/SCrawler/API/Base/UserDataBase.vb @@ -1305,6 +1305,10 @@ BlockNullPicture: DownloadSingleObject_CreateMedia(Data, Token) DownloadSingleObject_Download(Data, Token) DownloadSingleObject_PostProcessing(Data) + Catch oex As OperationCanceledException When Token.IsCancellationRequested + Data.DownloadState = UserMediaStates.Missing + ErrorsDescriber.Execute(EDP.SendToLog, oex, $"{Site} download canceled: {Data.URL}") + Catch dex As ObjectDisposedException When Disposed Catch ex As Exception Data.DownloadState = UserMediaStates.Missing ErrorsDescriber.Execute(EDP.SendToLog, ex, $"{Site} single data downloader error: {Data.URL}") diff --git a/SCrawler/API/Reddit/SiteSettings.vb b/SCrawler/API/Reddit/SiteSettings.vb index 7031469..20c6491 100644 --- a/SCrawler/API/Reddit/SiteSettings.vb +++ b/SCrawler/API/Reddit/SiteSettings.vb @@ -238,7 +238,7 @@ Namespace API.Reddit For i% = 0 To p.Count - 1 If CStr(p(i).Value).IsEmptyString Then wrong.Add(p(i).Name) Next - If wrong.Count > 0 Then + If wrong.Count > 0 And wrong.Count <> 4 Then MsgBoxE({$"You have not completed the following fields: {wrong.ListToString}." & vbCr & "To use OAuth authorization, all authorization fields must be filled in.", "Validate token fields"}, vbCritical) Return False diff --git a/SCrawler/Download/TDownloader.vb b/SCrawler/Download/TDownloader.vb index 740d173..e7ba2fc 100644 --- a/SCrawler/Download/TDownloader.vb +++ b/SCrawler/Download/TDownloader.vb @@ -303,32 +303,40 @@ Namespace DownloadObjects End Sub #End Region #Region "Pool" - Friend Sub ReconfPool() - If Pool.Count = 0 OrElse Not Pool.Exists(Function(j) j.Working Or j.Count > 0) Then - Dim i% - Pool.ListClearDispose - If Settings.Plugins.Count > 0 Then - Pool.Add(New Job(Download.Main)) - For Each p As PluginHost In Settings.Plugins - If p.Settings.IsSeparatedTasks Then - Pool.Add(New Job(Download.Main)) - Pool.Last.AddHost(p.Settings) - ElseIf Not p.Settings.TaskGroupName.IsEmptyString Then - i = -1 - If Pool.Count > 0 Then i = Pool.FindIndex(Function(pt) pt.GroupName = p.Settings.TaskGroupName) - If i >= 0 Then - Pool(i).AddHost(p.Settings) - Else - Pool.Add(New Job(Download.Main, p.Settings.TaskGroupName)) + Friend Sub ReconfPool(Optional ByVal Round As Integer = 0) + Try + If Pool.Count = 0 OrElse Not Pool.Exists(Function(j) j.Working Or j.Count > 0) Then + Dim i% + Pool.ListClearDispose + If Settings.Plugins.Count > 0 Then + Pool.Add(New Job(Download.Main)) + For Each p As PluginHost In Settings.Plugins + If p.Settings.IsSeparatedTasks Then + Pool.Add(New Job(Download.Main)) Pool.Last.AddHost(p.Settings) + ElseIf Not p.Settings.TaskGroupName.IsEmptyString Then + i = -1 + If Pool.Count > 0 Then i = Pool.FindIndex(Function(pt) pt.GroupName = p.Settings.TaskGroupName) + If i >= 0 Then + Pool(i).AddHost(p.Settings) + Else + Pool.Add(New Job(Download.Main, p.Settings.TaskGroupName)) + Pool.Last.AddHost(p.Settings) + End If + Else + Pool(0).AddHost(p.Settings) End If - Else - Pool(0).AddHost(p.Settings) - End If - Next + Next + End If + RaiseEvent Reconfigured() End If - RaiseEvent Reconfigured() - End If + Catch ex As Exception + If Round = 0 Then + ReconfPool(Round + 1) + Else + Throw ex + End If + End Try End Sub #End Region #Region "Thread" diff --git a/SCrawler/MainFrame.vb b/SCrawler/MainFrame.vb index 993bc8c..cd7fa76 100644 --- a/SCrawler/MainFrame.vb +++ b/SCrawler/MainFrame.vb @@ -423,7 +423,19 @@ CloseResume: InfoForm.FormShow(EDP.LogMessageValue) End Sub Private Sub MENU_INFO_SHOW_QUEUE_Click(sender As Object, e As EventArgs) Handles MENU_INFO_SHOW_QUEUE.Click - DownloadQueue.FormShow(EDP.LogMessageValue) + ShowDownloadQueueForm() + End Sub + Private Sub ShowDownloadQueueForm(Optional ByVal Round As Integer = 0) + Try + DownloadQueue.FormShow(EDP.LogMessageValue) + Catch ex As Exception + If Round = 0 Then + If Not DownloadQueue Is Nothing Then DownloadQueue.Dispose() : DownloadQueue = Nothing + ShowDownloadQueueForm(Round + 1) + Else + ErrorsDescriber.Execute(EDP.SendToLog, ex, "ShowDownloadQueueForm") + End If + End Try End Sub Private Sub MENU_INFO_SHOW_MISSING_Click(sender As Object, e As EventArgs) Handles MENU_INFO_SHOW_MISSING.Click MyMissingPosts.FormShow(EDP.LogMessageValue) diff --git a/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb b/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb index d40d84e..5f2de75 100644 --- a/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb +++ b/SCrawler/PluginsEnvironment/Hosts/SettingsHost.vb @@ -331,6 +331,7 @@ Namespace Plugin.Hosts End If Return _AvailableValue Else + If Not Silent Then MsgBoxE({$"Downloading data for the site {Name} has been disabled by you.", $"{Name} downloading disabled"}, vbExclamation) Return False End If End Function