From 08ce6d053036a3ced50dce28472b90ab8ce7ce62 Mon Sep 17 00:00:00 2001 From: moisesmcardona Date: Mon, 4 May 2020 19:53:17 -0400 Subject: [PATCH] v1.16: Bug fixes. --- .gitignore | 3 +- opus_gui/Form1.Designer.vb | 2 +- opus_gui/Form1.vb | 50 ++++++++++++++++++----------- opus_gui/My Project/AssemblyInfo.vb | 4 +-- opus_gui/opus_gui.vbproj | 24 +++++++------- opus_gui/packages.config | 8 ++--- 6 files changed, 53 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 3c4efe2..d588c95 100644 --- a/.gitignore +++ b/.gitignore @@ -258,4 +258,5 @@ paket-files/ # Python Tools for Visual Studio (PTVS) __pycache__/ -*.pyc \ No newline at end of file +*.pyc +/Screenshots diff --git a/opus_gui/Form1.Designer.vb b/opus_gui/Form1.Designer.vb index 8de611f..eaf707a 100644 --- a/opus_gui/Form1.Designer.vb +++ b/opus_gui/Form1.Designer.vb @@ -162,7 +162,7 @@ Partial Class Form1 Me.Label6.Name = "Label6" Me.Label6.Size = New System.Drawing.Size(34, 13) Me.Label6.TabIndex = 12 - Me.Label6.Text = "v1.15" + Me.Label6.Text = "v1.16" ' 'OpusVersionLabel ' diff --git a/opus_gui/Form1.vb b/opus_gui/Form1.vb index 1414c41..1358c72 100644 --- a/opus_gui/Form1.vb +++ b/opus_gui/Form1.vb @@ -1,6 +1,7 @@ Imports System.IO.Pipes Public Class Form1 + Private AudioFormats As New List(Of String) Private opusenc_version As String = String.Empty Private ffmpeg_version As String = String.Empty Public Running As Boolean = False @@ -52,7 +53,7 @@ Public Class Form1 End Sub Private Function GetOutputPath(OutputFolder As String, Item As String) As String - Dim outputPath As String = String.Empty + Dim outputPath As String If Not String.IsNullOrEmpty(OutputFolder) Then outputPath = OutputTxt.Text + "\" + IO.Path.GetFileNameWithoutExtension(Item) + ".opus" Else @@ -81,7 +82,8 @@ Public Class Form1 For Each File In Items If Not String.IsNullOrEmpty(OutputTxt.Text) Then If Not IO.File.Exists(OutputTxt.Text + "\" + My.Computer.FileSystem.GetName(File)) Then - If Not IgnoreFilesWithExtensions.Contains(IO.Path.GetExtension(File)) Then + Dim FileFormat As String = IO.Path.GetExtension(File) + If Not IgnoreFilesWithExtensions.Contains(FileFormat) And AudioFormats.Contains(FileFormat) Then ItemsToProcess.Add(File) Else If Item_Type = 0 Then @@ -109,7 +111,7 @@ Public Class Form1 Else args = {ItemsToProcess(Counter), 0, GetOutputPath(OutputTxt.Text, ItemsToProcess(Counter)), IO.Path.GetExtension(ItemsToProcess(Counter)), My.Settings.Bitrate} End If - If Not IO.File.Exists(args(1)) Then + If Not IO.File.Exists(args(2)) Then If EncOpusenc.Checked Then tasks.Add(Function() Run_opus(args, "opusenc", "opusenc")) ElseIf EncFfmpeg1.Checked Then @@ -118,14 +120,19 @@ Public Class Form1 tasks.Add(Function() Run_opus(args, "ffmpeg2", "ffmpeg")) End If Else - FileAlreadyExist.Add(args(1)) + FileAlreadyExist.Add(args(2)) End If Next Parallel.Invoke(New ParallelOptions With {.MaxDegreeOfParallelism = CPUThreads.Value}, tasks.ToArray()) Else For Counter As Integer = 0 To ItemsToProcess.Count - 1 - Dim args As Array = {ItemsToProcess(Counter), GetOutputPath(OutputTxt.Text, ItemsToProcess(Counter)), My.Settings.Bitrate} - If Not IO.File.Exists(args(1)) Then + Dim args As Array + If GoogleDrive Then + args = {GDriveItemIDs(Counter), 1, GetOutputPath(OutputTxt.Text, ItemsToProcess(Counter)), My.Settings.Bitrate} + Else + args = {ItemsToProcess(Counter), 0, GetOutputPath(OutputTxt.Text, ItemsToProcess(Counter)), My.Settings.Bitrate} + End If + If Not IO.File.Exists(args(2)) Then If EncOpusenc.Checked Then Run_opus(args, "opusenc", "opusenc") ElseIf EncFfmpeg1.Checked Then @@ -134,7 +141,7 @@ Public Class Form1 Run_opus(args, "ffmpeg2", "ffmpeg") End If Else - FileAlreadyExist.Add(args(1)) + FileAlreadyExist.Add(args(2)) End If Next End If @@ -262,11 +269,26 @@ Public Class Form1 Catch End Try Next - - InputPipe.Flush() - InputPipe.Dispose() + Try + InputPipe.Flush() + InputPipe.Dispose() + Catch + End Try + End Sub + Private Sub TrimAudioFormats(AudioFormatsList As IEnumerable(Of String)) + For Each Format As String In AudioFormatsList + AudioFormats(AudioFormats.IndexOf(Format)) = Format.Trim + Next End Sub Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load + If IO.File.Exists("audioformats.txt") Then + AudioFormats.AddRange(IO.File.ReadAllText("audioformats.txt").Trim.Split(Environment.NewLine)) + For item As Integer = 0 To AudioFormats.Count - 1 + AudioFormats(item) = AudioFormats(item).Trim + Next + Else + AudioFormats.AddRange({".flac", ".wav", ".mp3", ".mp4", ".m4a", ".ogg", ".opus", ".wma"}) + End If CPUThreads.Maximum = Environment.ProcessorCount If My.Settings.CPUThreads = 0 Then CPUThreads.Value = CPUThreads.Maximum Else CPUThreads.Value = My.Settings.CPUThreads BitrateNumberBox.Value = My.Settings.Bitrate @@ -323,14 +345,6 @@ Public Class Form1 End Try End Sub - Private Function OpusEncExists() As Boolean 'Currently not used - If IO.File.Exists("opusenc.exe") Then - Return True - Else - Return False - End If - End Function - Private Sub NumericUpDown1_ValueChanged(sender As Object, e As EventArgs) Handles BitrateNumberBox.ValueChanged My.Settings.Bitrate = BitrateNumberBox.Value My.Settings.Save() diff --git a/opus_gui/My Project/AssemblyInfo.vb b/opus_gui/My Project/AssemblyInfo.vb index a65d322..1d1feac 100644 --- a/opus_gui/My Project/AssemblyInfo.vb +++ b/opus_gui/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' by using the '*' as shown below: ' - - + + diff --git a/opus_gui/opus_gui.vbproj b/opus_gui/opus_gui.vbproj index 03b7b2d..7c8e8ce 100644 --- a/opus_gui/opus_gui.vbproj +++ b/opus_gui/opus_gui.vbproj @@ -58,23 +58,23 @@ 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036 - - ..\packages\Google.Apis.1.43.0\lib\net45\Google.Apis.dll + + ..\packages\Google.Apis.1.45.0\lib\net45\Google.Apis.dll - - ..\packages\Google.Apis.Auth.1.43.0\lib\net45\Google.Apis.Auth.dll + + ..\packages\Google.Apis.Auth.1.45.0\lib\net45\Google.Apis.Auth.dll - - ..\packages\Google.Apis.Auth.1.43.0\lib\net45\Google.Apis.Auth.PlatformServices.dll + + ..\packages\Google.Apis.Auth.1.45.0\lib\net45\Google.Apis.Auth.PlatformServices.dll - - ..\packages\Google.Apis.Core.1.43.0\lib\net45\Google.Apis.Core.dll + + ..\packages\Google.Apis.Core.1.45.0\lib\net45\Google.Apis.Core.dll - - ..\packages\Google.Apis.Drive.v3.1.43.0.1807\lib\net45\Google.Apis.Drive.v3.dll + + ..\packages\Google.Apis.Drive.v3.1.45.0.1922\lib\net45\Google.Apis.Drive.v3.dll - - ..\packages\Google.Apis.1.43.0\lib\net45\Google.Apis.PlatformServices.dll + + ..\packages\Google.Apis.1.45.0\lib\net45\Google.Apis.PlatformServices.dll ..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll diff --git a/opus_gui/packages.config b/opus_gui/packages.config index 55a5ad5..489fae3 100644 --- a/opus_gui/packages.config +++ b/opus_gui/packages.config @@ -1,8 +1,8 @@  - - - - + + + + \ No newline at end of file