2022-12-02 18:43:43 +01:00
|
|
|
|
Imports System.ComponentModel
|
|
|
|
|
Imports System.IO
|
2023-03-29 17:47:33 +02:00
|
|
|
|
Imports System.Runtime.Remoting
|
2022-01-22 11:56:37 +01:00
|
|
|
|
Imports System.Text
|
2022-12-02 18:43:43 +01:00
|
|
|
|
Imports System.Windows.Forms.VisualStyles
|
2022-01-22 11:56:37 +01:00
|
|
|
|
|
|
|
|
|
Module Subfolder
|
2020-12-02 21:01:30 +01:00
|
|
|
|
Public SubFolder_automatic As String = "[automatic by Series and Season]"
|
|
|
|
|
Public SubFolder_automatic2 As String = "[automatic by Series]"
|
2020-12-12 16:24:08 +01:00
|
|
|
|
Public SubFolder_automatic_old As String = "[automatic: Series/Season]"
|
2020-12-02 21:01:30 +01:00
|
|
|
|
Public SubFolder_Nothing As String = "[ ignore subfolder ]"
|
|
|
|
|
|
|
|
|
|
Public SubFolder_Value As String = "[ ignore subfolder ]"
|
|
|
|
|
|
2022-03-25 15:06:31 +01:00
|
|
|
|
Public Function CleanJSON(ByVal JSON As String) As String
|
2022-03-25 15:18:50 +01:00
|
|
|
|
JSON = JSON.Replace("&", "&").Replace("/u0026", "&").Replace("\u002F", "/").Replace("\u0026", "&")
|
2022-03-25 15:06:31 +01:00
|
|
|
|
While CBool(InStr(JSON, "\"))
|
|
|
|
|
Dim index As Integer = InStr(JSON, "\")
|
|
|
|
|
Dim myName As New StringBuilder(JSON)
|
|
|
|
|
myName.Remove(index - 1, 2)
|
|
|
|
|
JSON = myName.ToString
|
|
|
|
|
End While
|
|
|
|
|
Return JSON
|
|
|
|
|
|
|
|
|
|
End Function
|
2020-12-02 21:01:30 +01:00
|
|
|
|
|
2021-04-24 20:51:34 +02:00
|
|
|
|
Public Function UseSubfolder(ByVal Series As String, ByVal Season As String, ByVal Path As String) As String
|
2020-12-08 19:01:35 +01:00
|
|
|
|
Dim newPath As String = Path + "\"
|
2020-12-02 21:01:30 +01:00
|
|
|
|
|
2020-12-12 16:24:08 +01:00
|
|
|
|
If SubFolder_Value = SubFolder_automatic Or SubFolder_Value = SubFolder_automatic_old Then
|
2020-12-02 21:01:30 +01:00
|
|
|
|
|
|
|
|
|
newPath = Path + "\" + Series + "\" + Season + "\"
|
|
|
|
|
|
|
|
|
|
ElseIf SubFolder_Value = SubFolder_automatic2 Then
|
|
|
|
|
|
|
|
|
|
newPath = Path + "\" + Series + "\"
|
|
|
|
|
|
|
|
|
|
ElseIf SubFolder_Value = SubFolder_Nothing Then
|
|
|
|
|
|
2020-12-10 19:18:20 +01:00
|
|
|
|
newPath = Path + "\"
|
2020-12-02 21:01:30 +01:00
|
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
|
|
|
|
|
newPath = Path + "\" + SubFolder_Value + "\"
|
|
|
|
|
|
|
|
|
|
End If
|
2020-12-10 19:18:20 +01:00
|
|
|
|
Debug.WriteLine(newPath)
|
2020-12-02 21:01:30 +01:00
|
|
|
|
|
|
|
|
|
Return newPath.Replace("\\", "\")
|
|
|
|
|
End Function
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
|
|
|
|
|
|
2022-01-22 11:56:37 +01:00
|
|
|
|
Public Sub WriteText(ByVal Pfad As String, ByVal Content As String)
|
|
|
|
|
|
|
|
|
|
If Pfad.Length > 255 Then
|
|
|
|
|
Pfad = "\\?\" + Pfad
|
|
|
|
|
End If
|
|
|
|
|
|
2023-03-29 17:47:33 +02:00
|
|
|
|
Dim utf8WithoutBom2 As New System.Text.UTF8Encoding(False)
|
|
|
|
|
Using sink As New StreamWriter(Pfad, False, utf8WithoutBom2)
|
|
|
|
|
sink.WriteLine(Content)
|
|
|
|
|
End Using
|
|
|
|
|
|
|
|
|
|
'File.WriteAllText(Pfad, Content, Encoding.UTF8)
|
2022-01-22 11:56:37 +01:00
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
2022-11-10 14:31:11 +01:00
|
|
|
|
Public Function ReadText(ByVal Pfad As String) As String
|
|
|
|
|
|
|
|
|
|
If Pfad.Length > 255 Then
|
|
|
|
|
Pfad = "\\?\" + Pfad
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Return File.ReadAllText(Pfad, Encoding.UTF8)
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
Public Function GeräteID() As String
|
|
|
|
|
Dim rnd As New Random
|
|
|
|
|
Dim possible As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
|
|
|
|
Dim HWID As String = Nothing
|
|
|
|
|
|
|
|
|
|
For i As Integer = 0 To 15
|
|
|
|
|
Dim ZufallsZahl As Integer = rnd.Next(1, 33)
|
|
|
|
|
HWID = HWID + possible(ZufallsZahl)
|
|
|
|
|
Next
|
|
|
|
|
Return "CRD-Temp-File-" + HWID
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Public Function GeräteID2() As String
|
|
|
|
|
Dim rnd As New Random
|
|
|
|
|
Dim possible As String = "56789abcdefghijklmnopqrstuvwxyz01234ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
|
|
|
Dim HWID As String = Nothing
|
|
|
|
|
|
|
|
|
|
For i As Integer = 0 To 15
|
|
|
|
|
Dim ZufallsZahl As Integer = rnd.Next(1, 33)
|
|
|
|
|
HWID = HWID + possible(ZufallsZahl)
|
|
|
|
|
Next
|
|
|
|
|
Return "CRD-Temp-File-" + HWID
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
Class TextBoxTraceListener
|
|
|
|
|
Inherits TraceListener
|
|
|
|
|
|
|
|
|
|
Private tBox As RichTextBox
|
|
|
|
|
Dim lastmsg As String = Nothing
|
2022-12-02 18:43:43 +01:00
|
|
|
|
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
Public Sub New(ByVal box As RichTextBox)
|
|
|
|
|
Me.tBox = box
|
|
|
|
|
End Sub
|
|
|
|
|
|
2022-12-02 18:43:43 +01:00
|
|
|
|
Dim WithEvents BG As BackgroundWorker
|
|
|
|
|
|
|
|
|
|
Sub RunBG(ByVal sender As Object, e As DoWorkEventArgs) Handles BG.DoWork
|
|
|
|
|
Dim msg As String = CStr(e.Argument)
|
|
|
|
|
If msg <> lastmsg Then
|
|
|
|
|
lastmsg = msg
|
|
|
|
|
Else
|
|
|
|
|
Exit Sub
|
|
|
|
|
End If
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
Try
|
|
|
|
|
tBox.Parent.Invoke(New MethodInvoker(Sub()
|
2022-12-02 18:43:43 +01:00
|
|
|
|
tBox.AppendText(msg)
|
2021-09-20 20:37:57 +02:00
|
|
|
|
End Sub))
|
|
|
|
|
Catch ex As Exception
|
2022-12-02 18:43:43 +01:00
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
End Try
|
2022-12-02 18:43:43 +01:00
|
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Sub StopBG(sender As Object, e As EventArgs)
|
|
|
|
|
Dim T As Timer = CType(sender, Timer)
|
|
|
|
|
If BG.IsBusy Then
|
|
|
|
|
BG.CancelAsync()
|
|
|
|
|
T.Dispose()
|
|
|
|
|
Else
|
|
|
|
|
T.Dispose()
|
|
|
|
|
End If
|
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Overrides Sub Write(ByVal msg As String)
|
|
|
|
|
|
|
|
|
|
Dim time As New Timer
|
|
|
|
|
AddHandler time.Tick, AddressOf StopBG
|
|
|
|
|
time.Interval = 500
|
|
|
|
|
time.Start()
|
|
|
|
|
BG = New BackgroundWorker
|
|
|
|
|
BG.WorkerSupportsCancellation = True
|
|
|
|
|
BG.RunWorkerAsync(msg)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
End Sub
|
|
|
|
|
|
|
|
|
|
Public Overrides Sub WriteLine(ByVal msg As String)
|
|
|
|
|
Write(msg & vbCrLf)
|
|
|
|
|
End Sub
|
|
|
|
|
End Class
|
2023-02-22 14:50:53 +01:00
|
|
|
|
Public Function ShortingName(ByVal FullPath As String) As String
|
|
|
|
|
|
|
|
|
|
Dim FileName As String = Path.GetFileNameWithoutExtension(FullPath)
|
|
|
|
|
|
|
|
|
|
Dim Segements() As String = FileName.Split(New String() {" "}, System.StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
|
|
|
|
|
Dim ReturnName As String = Nothing
|
|
|
|
|
|
|
|
|
|
For i As Integer = 0 To Segements.Count - 1
|
|
|
|
|
If Segements(i).Count > 5 Then ' 6 chars or more, split at 5
|
|
|
|
|
ReturnName = ReturnName + Segements(i).Substring(0, 3) + ". "
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ElseIf Segements(i).Count > 3 Then ' 4 or 5 can stay
|
|
|
|
|
ReturnName = ReturnName + Segements(i) + " "
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
If ReturnName = Nothing Then
|
|
|
|
|
ReturnName = FullPath
|
|
|
|
|
Else
|
|
|
|
|
ReturnName = Path.GetDirectoryName(FullPath) + "\" + ReturnName + Path.GetExtension(FullPath)
|
|
|
|
|
End If
|
|
|
|
|
|
|
|
|
|
Return ReturnName
|
|
|
|
|
End Function
|
|
|
|
|
Public Function FFMPEG_Audio(ByVal file As String) As Integer
|
|
|
|
|
|
|
|
|
|
Dim proc As New Process
|
|
|
|
|
Dim exepath As String = Application.StartupPath + "\ffmpeg.exe"
|
|
|
|
|
Dim startinfo As New System.Diagnostics.ProcessStartInfo
|
|
|
|
|
Dim sr As StreamReader
|
|
|
|
|
|
|
|
|
|
Dim cmd As String = "-i " + Chr(34) + file + Chr(34) 'start ffmpeg with command strFFCMD string
|
|
|
|
|
Dim ffmpegOutput As String = Nothing
|
|
|
|
|
'all parameters required to run the process
|
|
|
|
|
startinfo.FileName = exepath
|
|
|
|
|
startinfo.Arguments = cmd
|
|
|
|
|
startinfo.UseShellExecute = False
|
|
|
|
|
startinfo.WindowStyle = ProcessWindowStyle.Normal
|
|
|
|
|
startinfo.RedirectStandardError = True
|
|
|
|
|
startinfo.RedirectStandardOutput = True
|
|
|
|
|
startinfo.CreateNoWindow = True
|
|
|
|
|
startinfo.StandardOutputEncoding = Encoding.UTF8
|
|
|
|
|
startinfo.StandardErrorEncoding = Encoding.UTF8
|
|
|
|
|
proc.StartInfo = startinfo
|
|
|
|
|
proc.Start() ' start the process
|
|
|
|
|
sr = proc.StandardError 'standard error is used by ffmpeg
|
|
|
|
|
|
|
|
|
|
Dim start, finish, pau As Double
|
|
|
|
|
start = CSng(Microsoft.VisualBasic.DateAndTime.Timer)
|
|
|
|
|
pau = 5
|
|
|
|
|
finish = start + pau
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Do
|
|
|
|
|
ffmpegOutput = ffmpegOutput + sr.ReadToEnd
|
|
|
|
|
|
|
|
|
|
Loop Until proc.HasExited Or Microsoft.VisualBasic.DateAndTime.Timer < finish
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dim Streams() As String = ffmpegOutput.Split(New String() {"Stream #"}, System.StringSplitOptions.RemoveEmptyEntries)
|
|
|
|
|
|
|
|
|
|
Dim Tracks As Integer = 0
|
|
|
|
|
|
|
|
|
|
For i As Integer = 0 To Streams.Count - 1
|
|
|
|
|
If CBool(InStr(Streams(i), ": Audio:")) Then
|
|
|
|
|
Tracks = Tracks + 1
|
|
|
|
|
|
|
|
|
|
End If
|
|
|
|
|
Next
|
|
|
|
|
|
|
|
|
|
Return Tracks
|
|
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
|
|
|
|
|
|
2021-09-20 20:37:57 +02:00
|
|
|
|
|
2020-12-02 21:01:30 +01:00
|
|
|
|
End Module
|