From c28c0e1ba3636d0d58261fb43158ad6ae5ae4133 Mon Sep 17 00:00:00 2001 From: Andy <88590076+AAndyProgram@users.noreply.github.com> Date: Sat, 10 Sep 2022 12:28:40 +0300 Subject: [PATCH] 2022.9.10.0 Fixed: missed posts are not saved Fixed memory leaking because of the video --- Changelog.md | 7 + .../My Project/AssemblyInfo.vb | 4 +- SCrawler.Plugin.LPSG/UserData.vb | 3 +- .../My Project/AssemblyInfo.vb | 4 +- SCrawler.Plugin.XVIDEOS/UserData.vb | 3 +- .../My Project/AssemblyInfo.vb | 4 +- .../Objects/PluginUserMedia.vb | 1 + SCrawler/API/Base/Structures.vb | 4 +- SCrawler/API/Base/UserDataBase.vb | 2 +- SCrawler/API/Reddit/UserData.vb | 6 +- SCrawler/Download/AutoDownloader.vb | 4 +- SCrawler/Download/FeedMedia.Designer.vb | 16 -- SCrawler/Download/FeedMedia.resx | 11 -- SCrawler/Download/FeedMedia.vb | 24 +-- SCrawler/Download/FeedVideo.Designer.vb | 168 ++++++++++++++++++ SCrawler/Download/FeedVideo.resx | 126 +++++++++++++ SCrawler/Download/FeedVideo.vb | 73 ++++++++ SCrawler/Download/MissingPostsForm.vb | 36 ++-- SCrawler/My Project/AssemblyInfo.vb | 4 +- SCrawler/SCrawler.vbproj | 68 ++++--- SCrawler/SettingsCLS.vb | 3 +- SCrawler/packages.config | 10 ++ 22 files changed, 471 insertions(+), 110 deletions(-) create mode 100644 SCrawler/Download/FeedVideo.Designer.vb create mode 100644 SCrawler/Download/FeedVideo.resx create mode 100644 SCrawler/Download/FeedVideo.vb create mode 100644 SCrawler/packages.config diff --git a/Changelog.md b/Changelog.md index fa429c9..a19fcd2 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,10 @@ +# 2022.9.10.0 + +*2022-09-10* + +- Fixed + - The memory is still leaking. This time because of the video. *Using WMP was not the best choice.* + # 2022.9.8.1 *2022-09-08* diff --git a/SCrawler.Plugin.LPSG/My Project/AssemblyInfo.vb b/SCrawler.Plugin.LPSG/My Project/AssemblyInfo.vb index be84dec..06b36f3 100644 --- a/SCrawler.Plugin.LPSG/My Project/AssemblyInfo.vb +++ b/SCrawler.Plugin.LPSG/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/SCrawler.Plugin.LPSG/UserData.vb b/SCrawler.Plugin.LPSG/UserData.vb index 7c71a08..6aa6d84 100644 --- a/SCrawler.Plugin.LPSG/UserData.vb +++ b/SCrawler.Plugin.LPSG/UserData.vb @@ -152,7 +152,8 @@ Public Class UserData : Implements IPluginContentProvider If Responser.Client.StatusCode = Net.HttpStatusCode.ServiceUnavailable Then LogProvider.Add("LPSG not available") Else - m.DownloadState = UStates.Skipped + m.DownloadState = UStates.Missing + m.Attempts += 1 End If End Try RaiseEvent ProgressChanged(1) diff --git a/SCrawler.Plugin.XVIDEOS/My Project/AssemblyInfo.vb b/SCrawler.Plugin.XVIDEOS/My Project/AssemblyInfo.vb index 67157ad..557a7a3 100644 --- a/SCrawler.Plugin.XVIDEOS/My Project/AssemblyInfo.vb +++ b/SCrawler.Plugin.XVIDEOS/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/SCrawler.Plugin.XVIDEOS/UserData.vb b/SCrawler.Plugin.XVIDEOS/UserData.vb index 3816f21..3555653 100644 --- a/SCrawler.Plugin.XVIDEOS/UserData.vb +++ b/SCrawler.Plugin.XVIDEOS/UserData.vb @@ -208,7 +208,8 @@ Public Class UserData : Implements IPluginContentProvider m.File = f m.DownloadState = UStates.Downloaded Catch ex As Exception - m.DownloadState = UStates.Skipped + m.DownloadState = UStates.Missing + m.Attempts += 1 End Try TempMediaList(i) = m RaiseEvent ProgressChanged(1) diff --git a/SCrawler.PluginProvider/My Project/AssemblyInfo.vb b/SCrawler.PluginProvider/My Project/AssemblyInfo.vb index 82d2157..0c5f974 100644 --- a/SCrawler.PluginProvider/My Project/AssemblyInfo.vb +++ b/SCrawler.PluginProvider/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/SCrawler.PluginProvider/Objects/PluginUserMedia.vb b/SCrawler.PluginProvider/Objects/PluginUserMedia.vb index 660c9d7..5814fcf 100644 --- a/SCrawler.PluginProvider/Objects/PluginUserMedia.vb +++ b/SCrawler.PluginProvider/Objects/PluginUserMedia.vb @@ -26,5 +26,6 @@ Namespace Plugin Public PostID As String Public PostDate As Date? Public SpecialFolder As String + Public Attempts As Integer End Structure End Namespace \ No newline at end of file diff --git a/SCrawler/API/Base/Structures.vb b/SCrawler/API/Base/Structures.vb index 39998f8..f0f599d 100644 --- a/SCrawler/API/Base/Structures.vb +++ b/SCrawler/API/Base/Structures.vb @@ -52,6 +52,7 @@ Namespace API.Base Post = New UserPost With {.ID = m.PostID, .[Date] = m.PostDate} State = m.DownloadState SpecialFolder = m.SpecialFolder + Attempts = m.Attempts End If End Sub Public Shared Widening Operator CType(ByVal _URL As String) As UserMedia @@ -72,7 +73,8 @@ Namespace API.Base .URL = URL, .SpecialFolder = SpecialFolder, .PostID = Post.ID, - .PostDate = Post.Date + .PostDate = Post.Date, + .Attempts = Attempts } End Function Friend Overloads Function Equals(ByVal Other As UserMedia) As Boolean Implements IEquatable(Of UserMedia).Equals diff --git a/SCrawler/API/Base/UserDataBase.vb b/SCrawler/API/Base/UserDataBase.vb index 85691c6..c0f6827 100644 --- a/SCrawler/API/Base/UserDataBase.vb +++ b/SCrawler/API/Base/UserDataBase.vb @@ -846,7 +846,7 @@ BlockNullPicture: DownloadContent(Token) ThrowIfDisposed() LatestData.ListAddList(_ContentNew.Where(_downContent), LNC) - _ContentList.ListAddList(_ContentNew.Where(_downContent), LNC) + _ContentList.ListAddList(_ContentNew.Where(Function(c) _downContent(c) Or MissingFinder(c)), LNC) If DownloadedTotal(False) > 0 Or EnvirChanged.Invoke Or _ContentList.Exists(MissingFinder) Then If __SaveData Then LastUpdated = Now diff --git a/SCrawler/API/Reddit/UserData.vb b/SCrawler/API/Reddit/UserData.vb index d7908b2..10aef4b 100644 --- a/SCrawler/API/Reddit/UserData.vb +++ b/SCrawler/API/Reddit/UserData.vb @@ -765,7 +765,11 @@ Namespace API.Reddit dCount += 1 End If Catch wex As Exception - If Not IsChannel And Not IsImgurStuff And MissingErrorsAdd Then ErrorDownloading(f, v.URL) + If Not IsChannel Then + If Not IsImgurStuff And MissingErrorsAdd Then ErrorDownloading(f, v.URL) + v.Attempts += 1 + v.State = UStates.Missing + End If End Try If ImgurUrls.Count > 0 Then ImgurUrls.RemoveAt(0) Loop While ImgurUrls.Count > 0 diff --git a/SCrawler/Download/AutoDownloader.vb b/SCrawler/Download/AutoDownloader.vb index a022d58..3c6bf4b 100644 --- a/SCrawler/Download/AutoDownloader.vb +++ b/SCrawler/Download/AutoDownloader.vb @@ -16,9 +16,9 @@ Imports SCrawler.API Imports SCrawler.API.Base Namespace DownloadObjects Friend Class AutoDownloader : Inherits GroupParameters : Implements IEContainerProvider - Friend Shared ReadOnly Property CachePath As SFile + Private Shared ReadOnly Property CachePath As SFile Get - Return "_Cache\" + Return Settings.CachePath End Get End Property Friend Enum Modes As Integer diff --git a/SCrawler/Download/FeedMedia.Designer.vb b/SCrawler/Download/FeedMedia.Designer.vb index a49ee06..8a3356a 100644 --- a/SCrawler/Download/FeedMedia.Designer.vb +++ b/SCrawler/Download/FeedMedia.Designer.vb @@ -27,7 +27,6 @@ Namespace DownloadObjects Dim CONTEXT_SEP_2 As System.Windows.Forms.ToolStripSeparator Dim CONTEXT_SEP_3 As System.Windows.Forms.ToolStripSeparator Dim TP_LBL As System.Windows.Forms.TableLayoutPanel - Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(FeedMedia)) Me.CH_CHECKED = New System.Windows.Forms.CheckBox() Me.LBL_INFO = New System.Windows.Forms.Label() Me.CONTEXT_DATA = New System.Windows.Forms.ContextMenuStrip(Me.components) @@ -39,7 +38,6 @@ Namespace DownloadObjects Me.BTT_CONTEXT_INFO = New System.Windows.Forms.ToolStripMenuItem() Me.BTT_CONTEXT_DELETE = New System.Windows.Forms.ToolStripMenuItem() Me.TP_MAIN = New System.Windows.Forms.TableLayoutPanel() - Me.MyVideo = New AxWMPLib.AxWindowsMediaPlayer() CONTEXT_SEP_1 = New System.Windows.Forms.ToolStripSeparator() CONTEXT_SEP_2 = New System.Windows.Forms.ToolStripSeparator() CONTEXT_SEP_3 = New System.Windows.Forms.ToolStripSeparator() @@ -47,7 +45,6 @@ Namespace DownloadObjects TP_LBL.SuspendLayout() Me.CONTEXT_DATA.SuspendLayout() Me.TP_MAIN.SuspendLayout() - CType(Me.MyVideo, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'CONTEXT_SEP_1 @@ -164,7 +161,6 @@ Namespace DownloadObjects Me.TP_MAIN.ColumnCount = 1 Me.TP_MAIN.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) Me.TP_MAIN.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20.0!)) - Me.TP_MAIN.Controls.Add(Me.MyVideo, 0, 1) Me.TP_MAIN.Controls.Add(TP_LBL, 0, 0) Me.TP_MAIN.Dock = System.Windows.Forms.DockStyle.Fill Me.TP_MAIN.Location = New System.Drawing.Point(0, 0) @@ -176,16 +172,6 @@ Namespace DownloadObjects Me.TP_MAIN.Size = New System.Drawing.Size(146, 146) Me.TP_MAIN.TabIndex = 0 ' - 'MyVideo - ' - Me.MyVideo.Dock = System.Windows.Forms.DockStyle.Fill - Me.MyVideo.Enabled = True - Me.MyVideo.Location = New System.Drawing.Point(3, 28) - Me.MyVideo.Name = "MyVideo" - Me.MyVideo.OcxState = CType(resources.GetObject("MyVideo.OcxState"), System.Windows.Forms.AxHost.State) - Me.MyVideo.Size = New System.Drawing.Size(140, 115) - Me.MyVideo.TabIndex = 1 - ' 'FeedMedia ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -201,7 +187,6 @@ Namespace DownloadObjects TP_LBL.PerformLayout() Me.CONTEXT_DATA.ResumeLayout(False) Me.TP_MAIN.ResumeLayout(False) - CType(Me.MyVideo, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub @@ -213,7 +198,6 @@ Namespace DownloadObjects Private WithEvents BTT_CONTEXT_OPEN_USER_POST As ToolStripMenuItem Private WithEvents BTT_CONTEXT_FIND_USER As ToolStripMenuItem Private WithEvents BTT_CONTEXT_DELETE As ToolStripMenuItem - Private WithEvents MyVideo As AxWMPLib.AxWindowsMediaPlayer Private WithEvents BTT_CONTEXT_OPEN_USER As ToolStripMenuItem Private WithEvents CH_CHECKED As CheckBox Private WithEvents LBL_INFO As Label diff --git a/SCrawler/Download/FeedMedia.resx b/SCrawler/Download/FeedMedia.resx index 8963834..6a1dbbc 100644 --- a/SCrawler/Download/FeedMedia.resx +++ b/SCrawler/Download/FeedMedia.resx @@ -132,15 +132,4 @@ 17, 17 - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w - LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 - ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAtwAAAAIB - AAAAAQAAAAAAAAAAAAAAAKIAAAAAAwAACAAAAAAABQAAAAAAAADwPwMAAAAAAAUAAAAAAAAAAAAIAAIA - AAAAAAMAAQAAAAsA//8DAAAAAAALAP//CAACAAAAAAADADIAAAALAAAACAAKAAAAZgB1AGwAbAAAAAsA - AAALAAAACwD//wsA//8LAAAACAACAAAAAAAIAAIAAAAAAAgAAgAAAAAACAACAAAAAAALAAAA4g4AAE0M - AAAL - - \ No newline at end of file diff --git a/SCrawler/Download/FeedMedia.vb b/SCrawler/Download/FeedMedia.vb index ec45637..881383c 100644 --- a/SCrawler/Download/FeedMedia.vb +++ b/SCrawler/Download/FeedMedia.vb @@ -11,7 +11,6 @@ Imports System.ComponentModel Imports PersonalUtilities.Forms Imports PersonalUtilities.Tools Imports SCrawler.API.Base -Imports AxWMPLib Imports UserMediaD = SCrawler.DownloadObjects.TDownloader.UserMediaD Namespace DownloadObjects @@ -20,6 +19,7 @@ Namespace DownloadObjects Private Const VideoHeight As Integer = 450 Private WithEvents MyPicture As PictureBox Private ReadOnly MyImage As ImageRenderer + Private ReadOnly MyVideo As FeedVideo Friend ReadOnly Property Exists As Boolean Get Return Not MyPicture Is Nothing Or Not MyVideo Is Nothing @@ -106,16 +106,12 @@ Namespace DownloadObjects .Padding = New Padding(0), .ContextMenuStrip = CONTEXT_DATA } - TP_MAIN.Controls.Remove(MyVideo) - MyVideo.Dispose() - MyVideo = Nothing TP_MAIN.Controls.Add(MyPicture, 0, 1) BTT_CONTEXT_OPEN_MEDIA.Text &= " picture" BTT_CONTEXT_DELETE.Text &= " picture" Case UserMedia.Types.Video - MyVideo.Tag = File + MyVideo = New FeedVideo(File) With {.Tag = File, .Dock = DockStyle.Fill, .ContextMenuStrip = CONTEXT_DATA} TP_MAIN.Controls.Add(MyVideo, 0, 1) - MyVideo.URL = File.ToString BTT_CONTEXT_OPEN_MEDIA.Text &= " video" BTT_CONTEXT_DELETE.Text &= " video" h = VideoHeight @@ -158,6 +154,7 @@ Namespace DownloadObjects Private Sub FeedImage_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed If Not MyImage Is Nothing Then MyImage.Dispose() If Not MyPicture Is Nothing Then MyPicture.Dispose() + If Not MyVideo Is Nothing Then MyVideo.Dispose() End Sub #End Region #Region "LBL" @@ -172,21 +169,6 @@ Namespace DownloadObjects Private Sub MyPicture_DoubleClick(sender As Object, e As EventArgs) Handles MyPicture.DoubleClick Try : Process.Start(File) : Catch : End Try End Sub - Private VideoPaused As Boolean = False - Private Sub MyVideo_PlayStateChange(sender As Object, e As _WMPOCXEvents_PlayStateChangeEvent) Handles MyVideo.PlayStateChange - Try - If Not VideoPaused Then - With MyVideo - If .playState = WMPLib.WMPPlayState.wmppsPlaying Then - .Ctlcontrols.currentPosition = 1 - .Ctlcontrols.pause() - VideoPaused = True - End If - End With - End If - Catch - End Try - End Sub #End Region #Region "Context" Private Sub BTT_CONTEXT_OPEN_MEDIA_Click(sender As Object, e As EventArgs) Handles BTT_CONTEXT_OPEN_MEDIA.Click diff --git a/SCrawler/Download/FeedVideo.Designer.vb b/SCrawler/Download/FeedVideo.Designer.vb new file mode 100644 index 0000000..2240a87 --- /dev/null +++ b/SCrawler/Download/FeedVideo.Designer.vb @@ -0,0 +1,168 @@ +' Copyright (C) 2022 Andy +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY +Namespace DownloadObjects + + Partial Public Class FeedVideo : Inherits System.Windows.Forms.UserControl + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + Private components As System.ComponentModel.IContainer + + Private Sub InitializeComponent() + Dim TP_MAIN As System.Windows.Forms.TableLayoutPanel + Dim TP_BUTTONS As System.Windows.Forms.TableLayoutPanel + Me.MyVideo = New LibVLCSharp.WinForms.VideoView() + Me.TR_POSITION = New System.Windows.Forms.TrackBar() + Me.BTT_PLAY = New System.Windows.Forms.Button() + Me.BTT_PAUSE = New System.Windows.Forms.Button() + Me.BTT_STOP = New System.Windows.Forms.Button() + Me.TR_VOLUME = New System.Windows.Forms.TrackBar() + TP_MAIN = New System.Windows.Forms.TableLayoutPanel() + TP_BUTTONS = New System.Windows.Forms.TableLayoutPanel() + TP_MAIN.SuspendLayout() + CType(Me.MyVideo, System.ComponentModel.ISupportInitialize).BeginInit() + CType(Me.TR_POSITION, System.ComponentModel.ISupportInitialize).BeginInit() + TP_BUTTONS.SuspendLayout() + CType(Me.TR_VOLUME, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'TP_MAIN + ' + TP_MAIN.ColumnCount = 1 + TP_MAIN.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + TP_MAIN.Controls.Add(Me.MyVideo, 0, 0) + TP_MAIN.Controls.Add(Me.TR_POSITION, 0, 1) + TP_MAIN.Controls.Add(TP_BUTTONS, 0, 2) + TP_MAIN.Dock = System.Windows.Forms.DockStyle.Fill + TP_MAIN.Location = New System.Drawing.Point(0, 0) + TP_MAIN.Margin = New System.Windows.Forms.Padding(0) + TP_MAIN.Name = "TP_MAIN" + TP_MAIN.RowCount = 3 + TP_MAIN.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + TP_MAIN.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + TP_MAIN.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 28.0!)) + TP_MAIN.Size = New System.Drawing.Size(180, 160) + TP_MAIN.TabIndex = 0 + ' + 'MyVideo + ' + Me.MyVideo.BackColor = System.Drawing.Color.Black + Me.MyVideo.Dock = System.Windows.Forms.DockStyle.Fill + Me.MyVideo.Location = New System.Drawing.Point(1, 1) + Me.MyVideo.Margin = New System.Windows.Forms.Padding(1) + Me.MyVideo.MediaPlayer = Nothing + Me.MyVideo.Name = "MyVideo" + Me.MyVideo.Size = New System.Drawing.Size(178, 105) + Me.MyVideo.TabIndex = 0 + ' + 'TR_POSITION + ' + Me.TR_POSITION.Dock = System.Windows.Forms.DockStyle.Fill + Me.TR_POSITION.Location = New System.Drawing.Point(3, 110) + Me.TR_POSITION.Name = "TR_POSITION" + Me.TR_POSITION.Size = New System.Drawing.Size(174, 19) + Me.TR_POSITION.TabIndex = 1 + ' + 'TP_BUTTONS + ' + TP_BUTTONS.ColumnCount = 5 + TP_BUTTONS.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + TP_BUTTONS.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + TP_BUTTONS.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 25.0!)) + TP_BUTTONS.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + TP_BUTTONS.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 100.0!)) + TP_BUTTONS.Controls.Add(Me.BTT_PLAY, 0, 0) + TP_BUTTONS.Controls.Add(Me.BTT_PAUSE, 1, 0) + TP_BUTTONS.Controls.Add(Me.BTT_STOP, 2, 0) + TP_BUTTONS.Controls.Add(Me.TR_VOLUME, 4, 0) + TP_BUTTONS.Dock = System.Windows.Forms.DockStyle.Fill + TP_BUTTONS.Location = New System.Drawing.Point(1, 133) + TP_BUTTONS.Margin = New System.Windows.Forms.Padding(1) + TP_BUTTONS.Name = "TP_BUTTONS" + TP_BUTTONS.RowCount = 1 + TP_BUTTONS.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100.0!)) + TP_BUTTONS.Size = New System.Drawing.Size(178, 26) + TP_BUTTONS.TabIndex = 2 + ' + 'BTT_PLAY + ' + Me.BTT_PLAY.BackgroundImage = Global.SCrawler.My.Resources.Resources.StartPic_01_Green_16 + Me.BTT_PLAY.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.BTT_PLAY.Dock = System.Windows.Forms.DockStyle.Fill + Me.BTT_PLAY.Location = New System.Drawing.Point(1, 1) + Me.BTT_PLAY.Margin = New System.Windows.Forms.Padding(1) + Me.BTT_PLAY.Name = "BTT_PLAY" + Me.BTT_PLAY.Size = New System.Drawing.Size(23, 24) + Me.BTT_PLAY.TabIndex = 0 + Me.BTT_PLAY.UseVisualStyleBackColor = True + ' + 'BTT_PAUSE + ' + Me.BTT_PAUSE.BackgroundImage = Global.SCrawler.My.Resources.Resources.Pause_Blue_16 + Me.BTT_PAUSE.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.BTT_PAUSE.Dock = System.Windows.Forms.DockStyle.Fill + Me.BTT_PAUSE.Location = New System.Drawing.Point(26, 1) + Me.BTT_PAUSE.Margin = New System.Windows.Forms.Padding(1) + Me.BTT_PAUSE.Name = "BTT_PAUSE" + Me.BTT_PAUSE.Size = New System.Drawing.Size(23, 24) + Me.BTT_PAUSE.TabIndex = 1 + Me.BTT_PAUSE.UseVisualStyleBackColor = True + ' + 'BTT_STOP + ' + Me.BTT_STOP.BackgroundImage = Global.SCrawler.My.Resources.Resources.Delete + Me.BTT_STOP.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom + Me.BTT_STOP.Dock = System.Windows.Forms.DockStyle.Fill + Me.BTT_STOP.Location = New System.Drawing.Point(51, 1) + Me.BTT_STOP.Margin = New System.Windows.Forms.Padding(1) + Me.BTT_STOP.Name = "BTT_STOP" + Me.BTT_STOP.Size = New System.Drawing.Size(23, 24) + Me.BTT_STOP.TabIndex = 2 + Me.BTT_STOP.UseVisualStyleBackColor = True + ' + 'TR_VOLUME + ' + Me.TR_VOLUME.Dock = System.Windows.Forms.DockStyle.Fill + Me.TR_VOLUME.Location = New System.Drawing.Point(81, 3) + Me.TR_VOLUME.Name = "TR_VOLUME" + Me.TR_VOLUME.Size = New System.Drawing.Size(94, 20) + Me.TR_VOLUME.TabIndex = 3 + ' + 'FeedVideo + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.Controls.Add(TP_MAIN) + Me.Name = "FeedVideo" + Me.Size = New System.Drawing.Size(180, 160) + TP_MAIN.ResumeLayout(False) + TP_MAIN.PerformLayout() + CType(Me.MyVideo, System.ComponentModel.ISupportInitialize).EndInit() + CType(Me.TR_POSITION, System.ComponentModel.ISupportInitialize).EndInit() + TP_BUTTONS.ResumeLayout(False) + TP_BUTTONS.PerformLayout() + CType(Me.TR_VOLUME, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + + End Sub + Private WithEvents MyVideo As LibVLCSharp.WinForms.VideoView + Private WithEvents TR_POSITION As TrackBar + Private WithEvents BTT_PLAY As Button + Private WithEvents BTT_PAUSE As Button + Private WithEvents BTT_STOP As Button + Private WithEvents TR_VOLUME As TrackBar + End Class +End Namespace \ No newline at end of file diff --git a/SCrawler/Download/FeedVideo.resx b/SCrawler/Download/FeedVideo.resx new file mode 100644 index 0000000..9ff4749 --- /dev/null +++ b/SCrawler/Download/FeedVideo.resx @@ -0,0 +1,126 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + + False + + \ No newline at end of file diff --git a/SCrawler/Download/FeedVideo.vb b/SCrawler/Download/FeedVideo.vb new file mode 100644 index 0000000..909c98f --- /dev/null +++ b/SCrawler/Download/FeedVideo.vb @@ -0,0 +1,73 @@ +' Copyright (C) 2022 Andy +' This program is free software: you can redistribute it and/or modify +' it under the terms of the GNU General Public License as published by +' the Free Software Foundation, either version 3 of the License, or +' (at your option) any later version. +' +' This program is distributed in the hope that it will be useful, +' but WITHOUT ANY WARRANTY +Imports LibVLCSharp +Imports System.ComponentModel +Imports PersonalUtilities.Tools +Imports PersonalUtilities.Tools.WEB +Namespace DownloadObjects + + Public Class FeedVideo + Private WithEvents MediaPlayer As [Shared].MediaPlayer + Private ReadOnly TimeChange As Action = Sub() + Dim v# = DivideWithZeroChecking(MediaPlayer.Time, MediaPlayer.Length) * 10 + If v > 10 Then TR_POSITION.Value = 10 Else TR_POSITION.Value = v + End Sub + Private ReadOnly MyImage As ImageRenderer + Public Sub New() + InitializeComponent() + End Sub + Friend Sub New(ByVal File As SFile) + InitializeComponent() + Dim debugLogs As Boolean = False +#If DEBUG Then + debugLogs = True +#End If + MediaPlayer = New [Shared].MediaPlayer(New [Shared].Media(New [Shared].LibVLC(enableDebugLogs:=debugLogs), New Uri(File.ToString))) + MyVideo.MediaPlayer = MediaPlayer + TR_VOLUME.Value = MediaPlayer.Volume / 10 + If Settings.UseM3U8 Then + Dim f As SFile = $"{Settings.CachePath.PathWithSeparator}FeedSnapshots\{File.GetHashCode}.png" + If Not f.Exists Then f = FFMPEG.TakeSnapshot(File, f, Settings.FfmpegFile, TimeSpan.FromSeconds(1)) + If f.Exists Then + MyImage = New ImageRenderer(f, EDP.None) + If Not MyImage.HasError Then + MyVideo.BackgroundImage = MyImage + MyVideo.BackgroundImageLayout = ImageLayout.Zoom + End If + End If + End If + End Sub + Private Sub FeedVideo_Disposed(sender As Object, e As EventArgs) Handles Me.Disposed + If Not MediaPlayer Is Nothing Then MediaPlayer.Dispose() + If Not MyImage Is Nothing Then MyImage.Dispose() + End Sub + Private Sub BTT_PLAY_Click(sender As Object, e As EventArgs) Handles BTT_PLAY.Click + Try : MediaPlayer.Play() : Catch : End Try + End Sub + Private Sub BTT_PAUSE_Click(sender As Object, e As EventArgs) Handles BTT_PAUSE.Click + Try : MediaPlayer.Pause() : Catch : End Try + End Sub + Private Sub BTT_STOP_Click(sender As Object, e As EventArgs) Handles BTT_STOP.Click + Try : MediaPlayer.Stop() : Catch : End Try + End Sub + Private Sub MediaPlayer_TimeChanged(sender As Object, e As [Shared].MediaPlayerTimeChangedEventArgs) Handles MediaPlayer.TimeChanged + If TR_POSITION.InvokeRequired Then TR_POSITION.Invoke(TimeChange) Else TimeChange.Invoke + End Sub + Private Sub TR_POSITION_MouseUp(sender As Object, e As MouseEventArgs) Handles TR_POSITION.MouseUp + Try : MediaPlayer.Time = (MediaPlayer.Length / 100) * (TR_POSITION.Value * 10) : Catch : End Try + End Sub + Private Sub TR_VOLUME_MouseUp(sender As Object, e As MouseEventArgs) Handles TR_VOLUME.MouseUp + Try : MediaPlayer.Volume = TR_VOLUME.Value * 10 : Catch : End Try + End Sub + Private Sub MediaPlayer_Stopped(sender As Object, e As EventArgs) Handles MediaPlayer.Stopped + Dim a As Action = Sub() TR_POSITION.Value = TR_POSITION.Maximum + If TR_POSITION.InvokeRequired Then TR_POSITION.Invoke(a) Else a.Invoke + End Sub + End Class +End Namespace \ No newline at end of file diff --git a/SCrawler/Download/MissingPostsForm.vb b/SCrawler/Download/MissingPostsForm.vb index 3eeb106..c2b33d6 100644 --- a/SCrawler/Download/MissingPostsForm.vb +++ b/SCrawler/Download/MissingPostsForm.vb @@ -112,24 +112,24 @@ Namespace DownloadObjects #End Region #Region "Post actions" Private Sub BTT_DOWN_Click(sender As Object, e As EventArgs) Handles BTT_DOWN.Click - Try - If LIST_DATA.SelectedItems.Count > 0 Then - Dim users As List(Of IUserData) = LIST_DATA.SelectedItems.ToObjectsList.ListCast(Of ListViewItem)(). - Select(Function(d) Settings.GetUser(CStr(d.Group.Tag))).ListWithRemove(Function(d) d Is Nothing) - If users.ListExists Then - If MsgBoxE({"The following users will be added to the download queue:" & vbCr & vbCr & - users.Select(Function(u) u.ToString).ListToString(vbNewLine), "Download users"},,,, {"Process", "Cancel"}) = 0 Then - users.ForEach(Sub(u) u.DownloadMissingOnly = True) - Downloader.AddRange(users) - users.Clear() - End If - End If - Else - MsgBoxE("No selected posts") - End If - Catch ex As Exception - ErrorsDescriber.Execute(EDP.SendInLog, ex, "[DownloadObjects.MissingPostsForm.Download]") - End Try + 'Try + ' If LIST_DATA.SelectedItems.Count > 0 Then + ' Dim users As List(Of IUserData) = LIST_DATA.SelectedItems.ToObjectsList.ListCast(Of ListViewItem)(). + ' Select(Function(d) Settings.GetUser(CStr(d.Group.Tag))).ListWithRemove(Function(d) d Is Nothing) + ' If users.ListExists Then + ' If MsgBoxE({"The following users will be added to the download queue:" & vbCr & vbCr & + ' users.Select(Function(u) u.ToString).ListToString(vbNewLine), "Download users"},,,, {"Process", "Cancel"}) = 0 Then + ' users.ForEach(Sub(u) u.DownloadMissingOnly = True) + ' Downloader.AddRange(users) + ' users.Clear() + ' End If + ' End If + ' Else + ' MsgBoxE("No selected posts") + ' End If + 'Catch ex As Exception + ' ErrorsDescriber.Execute(EDP.SendInLog, ex, "[DownloadObjects.MissingPostsForm.Download]") + 'End Try End Sub Private Sub BTT_OPEN_POST_Click(sender As Object, e As EventArgs) Handles BTT_OPEN_POST.Click Try diff --git a/SCrawler/My Project/AssemblyInfo.vb b/SCrawler/My Project/AssemblyInfo.vb index 4cb5618..47735d3 100644 --- a/SCrawler/My Project/AssemblyInfo.vb +++ b/SCrawler/My Project/AssemblyInfo.vb @@ -32,6 +32,6 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/SCrawler/SCrawler.vbproj b/SCrawler/SCrawler.vbproj index a94e89e..596e4ac 100644 --- a/SCrawler/SCrawler.vbproj +++ b/SCrawler/SCrawler.vbproj @@ -29,6 +29,8 @@ 1.0.0.%2a false true + + 10.0 @@ -111,10 +113,29 @@ My Project\app.manifest + + ..\packages\LibVLCSharp.3.6.6\lib\net40\LibVLCSharp.dll + + + ..\packages\LibVLCSharp.WinForms.3.6.6\lib\net40\LibVLCSharp.WinForms.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll + + + ..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll + + + + ..\packages\System.ValueTuple.4.5.0\lib\net461\System.ValueTuple.dll + @@ -181,6 +202,12 @@ UserControl + + FeedVideo.vb + + + UserControl + @@ -372,6 +399,9 @@ FeedMedia.vb + + FeedVideo.vb + GroupEditorForm.vb @@ -428,6 +458,7 @@ Settings.Designer.vb + @@ -477,33 +508,14 @@ false - - - {6BF52A50-394A-11D3-B153-00C04F79FAA6} - 1 - 0 - 0 - aximp - False - - - {00020430-0000-0000-C000-000000000046} - 2 - 0 - 0 - primary - False - True - - - {6BF52A50-394A-11D3-B153-00C04F79FAA6} - 1 - 0 - 0 - tlbimp - False - True - - + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file diff --git a/SCrawler/SettingsCLS.vb b/SCrawler/SettingsCLS.vb index 3d0c27a..a3f4d7d 100644 --- a/SCrawler/SettingsCLS.vb +++ b/SCrawler/SettingsCLS.vb @@ -29,6 +29,7 @@ Friend Class SettingsCLS : Implements IDisposable Return OS64 And FfmpegExists End Get End Property + Friend ReadOnly Property CachePath As SFile = "_Cache\" Friend ReadOnly Plugins As List(Of PluginHost) Friend ReadOnly Property Users As List(Of IUserData) Friend ReadOnly Property UsersList As List(Of UserInfo) @@ -555,7 +556,7 @@ Friend Class SettingsCLS : Implements IDisposable DeleteCachePath() End If If Not Automation Is Nothing Then Automation.Dispose() - AutoDownloader.CachePath.Delete(SFO.Path, SFODelete.DeletePermanently, EDP.None) + CachePath.Delete(SFO.Path, SFODelete.DeletePermanently, EDP.None) Plugins.Clear() Users.ListClearDispose UsersList.Clear() diff --git a/SCrawler/packages.config b/SCrawler/packages.config new file mode 100644 index 0000000..ac4353d --- /dev/null +++ b/SCrawler/packages.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file