elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


  Mostrar Mensajes
Páginas: 1 ... 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 [1008] 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 ... 1236
10071  Programación / Scripting / Re: Acciones sobre archivos de texto. [Batch] en: 3 Diciembre 2012, 10:07 am
Exacto, pero puedes cortar lo que no te interesa, como solo necesitas cortar lineas... :

(PD: Acabo de descubrir que precisamente había un fallo en la función de cortar las últimas líneas XD, pero ya lo he corregido)

Código
  1. @Echo OFF
  2.  
  3. Call :TEXTMAN L- 2 "Archivo.txt"
  4. Pause&Exit
  5.  
  6. REM ACCIONES:
  7. REM  L-  = LINE_LESS          * CORTAR LAS ÚLTIMAS  "X" LÍNEAS
  8.  
  9. :TEXTMAN
  10. :L-
  11. (FOR /F %%X IN ('TYPE "%~3"') DO (CALL SET /A "TOTAL_LINES+=1")) & (CALL SET /A "TOTAL_LINES-=%~2-1") & (For /F "usebackq tokens=*" %%@ in ("%~3") DO (Call Set /A "LINE+=1" & Call echo "%%LINE%%!!|@%%TOTAL_LINES%%" >NUL) && (CALL :RENAMER "%~3" && GOTO:EOF) || (Echo %%@ >> "%~nx3.NEW"))
  12. :RENAMER
  13. (REN "%~1" "%~nx1.BAK") & (MOVE /Y "%~nx1.BAK" "%TEMP%\" >NUL) & (REN "%~nx1.NEW" "%~nx1") & (GOTO:EOF)
10072  Programación / Scripting / Re: Acciones sobre archivos de texto. [Batch] en: 2 Diciembre 2012, 17:34 pm
necesito quitar las ultimas dos lineas de un texto desde un .bat

> [BATCH] [APORTE] Rutina TEXTMAN para manipular archivos de texto

Código
  1. @Echo OFF
  2. Call :TEXTMAN L- 2 "Archivo.txt"
  3. Pause&Exit

Saludos.
10073  Sistemas Operativos / Windows / Re: [APORTE] Mega-Pack de "tips" para Windows 7 x64. en: 1 Diciembre 2012, 17:24 pm
@Moonshenite

Gracias por comentar, pero debes fijarte en la fecha de los posts xD.

En WinXP es posible porque sencillamente la seguridad del SO es una basura,
la tecnología "anti-crackers" ha avanzado mucho... obviamente no puedes craquear Windows 7 con un archivo de registro, estariamos apañaos, si eso fuera posible, ¿para que se iba a molestar Microsoft en lanzar a la venta el producto?, en el registro se puede hacer lo que Windows te permite hacer, nada más.

Por otro lado es fácil activar los Windows usando solamente un comando con el archivo slmgr, pero no es lo mismo usar una clave de activación, que crackear el SO, para eso necesitas activadores.
Saludos.

PD: Si algún mod ve esto pido que cierre este post plz. gracias.
10074  Programación / .NET (C#, VB.NET, ASP) / Mi form se cuelga al iniciar un thread... en: 29 Noviembre 2012, 19:36 pm
Para los que no lo sepan, estoy diseñando un programa, y tenía un problema, la app se colgaba al darle al botón "start", hasta que "el proceso" finalizaba no podía tocar nada.
...
...
Después de estar días para conseguir meter una función en un thread separado, ahora que lo he conseguido ...no hay ninguna diferencia... hasta que no finaliza "el proceso" no puedo mover el form por la pantalla, ni pulsar cualquier botón del form, ni nada, solo puedo esperar hasta que acabe...

...Espero alguna ayuda, porqué yo ya no sé que más intentar para que no se me cuelgue, no sé lo que he hecho mal.



Hasta que no se terminan de mostrar todas las líneas del richtextbox no me deja tocar NADA.

...Muchas gracias por leer.




El form:

Código
  1. Imports System.IO
  2. Imports System.Threading
  3. Imports System.Runtime.InteropServices
  4. Imports System.ComponentModel
  5. Imports Ookii.Dialogs
  6.  
  7. Public Class Form1
  8.  
  9. #Region "Declarations"
  10.  
  11.    ' MediaInfo
  12.    Dim MI As MediaInfo
  13.  
  14.    ' Others
  15.    Dim NameOfDirectory As String = Nothing
  16.    Dim aFile As FileInfo
  17.  
  18. #End Region
  19.  
  20. #Region "Properties"
  21. #End Region
  22.  
  23. #Region "Load / Close"
  24.  
  25.    ' Load
  26.    Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  27.  
  28.        ' MediaInfo Instance
  29.        MI = New MediaInfo
  30.  
  31.    End Sub
  32.  
  33. #End Region
  34.  
  35. #Region "Get Total files Function"
  36. #End Region
  37.  
  38. #Region "Option checkboxes"
  39. #End Region
  40.  
  41. #Region "Folder buttons"
  42. #End Region
  43.  
  44.  
  45. #Region "Append text function"
  46.  
  47.    ' Append Text
  48.    Public Sub AppendText(box As RichTextBox, color As Color, text As String)
  49.  
  50.        Control.CheckForIllegalCrossThreadCalls = False
  51.  
  52.        Dim start As Integer = box.TextLength
  53.        box.AppendText(text)
  54.        Dim [end] As Integer = box.TextLength
  55.  
  56.        ' Textbox may transform chars, so (end-start) != text.Length
  57.        box.[Select](start, [end] - start)
  58.        If True Then
  59.            box.SelectionColor = color
  60.            ' could set box.SelectionBackColor, box.SelectionFont too.
  61.        End If
  62.        box.SelectionLength = 0
  63.        ' clear
  64.    End Sub
  65.  
  66. #End Region
  67.  
  68.  
  69. #Region "Thread"
  70.  
  71.    Public _WaitHandle_FirstThreadDone As New System.Threading.AutoResetEvent(False)
  72.  
  73.    Public Sub ThreadProc(ByVal aDir As DirectoryInfo)
  74.  
  75.        Dim aFile As FileInfo
  76.  
  77.        For Each aFile In aDir.GetFiles()
  78.  
  79.            If accepted_extensions.ToLower.Contains(aFile.Extension.ToLower) Then
  80.  
  81.                ' print output
  82.                AppendText(consolebox, Color.Yellow, "Processing: ")
  83.                AppendText(consolebox, Color.White, aFile.ToString() + vbNewLine)
  84.                consolebox.ScrollToCaret()
  85.                processedfiles += 1
  86.                totalfiles_label.Text = "Processed " + processedfiles.ToString() + " of " + totalfiles.ToString() + " total video files"
  87.  
  88.                ' Attributes
  89.                If attribs = True Then
  90.                    aFile.Attributes = (aFile.Attributes And Not FileAttributes.ReadOnly And Not FileAttributes.Hidden And Not FileAttributes.System And Not FileAttributes.Archive)
  91.                End If
  92.  
  93.                ' Rename to Word-Case
  94.                If wordcase = True Then
  95.                    Dim renamestr As String = StrConv(aFile.Name, VbStrConv.ProperCase)
  96.                    My.Computer.FileSystem.RenameFile(aFile.FullName, renamestr + "_FILMEN")
  97.                    My.Computer.FileSystem.RenameFile(aFile.FullName + "_FILMEN", renamestr)
  98.                End If
  99.  
  100.                ' Rename to Lower-Case
  101.                If lowercase = True Then
  102.                    Dim renamestr As String = StrConv(aFile.Name, VbStrConv.Lowercase)
  103.                    My.Computer.FileSystem.RenameFile(aFile.FullName, renamestr + "_FILMEN")
  104.                    My.Computer.FileSystem.RenameFile(aFile.FullName + "_FILMEN", renamestr)
  105.                End If
  106.  
  107.                ' Playlists
  108.                If playlist = True Then
  109.                    Using writer As StreamWriter = New StreamWriter(aFile.DirectoryName.ToString() & "\" & aDir.Name & ".m3u", True, System.Text.Encoding.UTF8)
  110.                        writer.WriteLine(aFile.FullName.ToString())
  111.                    End Using
  112.                End If
  113.  
  114.                ' MEDIAINFO:  (ac3, dts, wav and multitrack)
  115.                If ac3 = True Or dts = True Or wav = True Or multitrack = True Then
  116.  
  117.                    MI.Open(aFile.FullName)
  118.  
  119.                    Dim Pos As Integer = 0
  120.                    To_Display = Nothing
  121.  
  122.                    ' multitrack
  123.                    If multitrack = True Then
  124.                        If MI.Count_Get(StreamKind.Audio) > 1 Then
  125.                            results_box.AppendText("Multi Track: " + aFile.FullName.ToString() + vbNewLine)
  126.                            results_box.SelectionStart = results_box.Text.Length
  127.                            results_box.ScrollToCaret()
  128.                            problems += 1
  129.                            problems_label.Text = problems.ToString() + " problems found"
  130.                        End If
  131.                    End If
  132.  
  133.                    While Pos < MI.Count_Get(StreamKind.Audio)
  134.  
  135.                        ' AC-3
  136.                        If ac3 = True Then
  137.                            If MI.Get_(StreamKind.Audio, Pos, "Format").ToString() = "AC-3" Then
  138.                                results_box.AppendText("AC3 Track: " + aFile.FullName.ToString() + vbNewLine)
  139.                                results_box.SelectionStart = results_box.Text.Length
  140.                                results_box.ScrollToCaret()
  141.                                problems += 1
  142.                                problems_label.Text = problems.ToString() + " problems found"
  143.                            End If
  144.                        End If
  145.  
  146.                        ' DTS
  147.                        If dts = True Then
  148.                            If MI.Get_(StreamKind.Audio, Pos, "Format").Contains("DTS") Then
  149.                                results_box.AppendText("DTS Track: " + aFile.FullName.ToString() + vbNewLine)
  150.                                results_box.SelectionStart = results_box.Text.Length
  151.                                results_box.ScrollToCaret()
  152.                                problems += 1
  153.                                problems_label.Text = problems.ToString() + " problems found"
  154.                            End If
  155.                        End If
  156.  
  157.                        ' WAV
  158.                        If wav = True Then
  159.                            If MI.Get_(StreamKind.Audio, Pos, "Format").Contains("PCM") Then
  160.                                results_box.AppendText("WAV Track: " + aFile.FullName.ToString() + vbNewLine)
  161.                                results_box.SelectionStart = results_box.Text.Length
  162.                                results_box.ScrollToCaret()
  163.                                problems += 1
  164.                                problems_label.Text = problems.ToString() + " problems found"
  165.                            End If
  166.                        End If
  167.  
  168.                        System.Math.Max(System.Threading.Interlocked.Increment(Pos), Pos - 1)
  169.                    End While
  170.                End If
  171.  
  172.                If metadata = True Then
  173.                    Dim ffmpeg_process As New Process()
  174.                    Dim ffmpeg_startinfo As New ProcessStartInfo()
  175.                    ffmpeg_startinfo.FileName = "cmd.exe "
  176.                    ffmpeg_startinfo.Arguments = "/C ffmpeg.exe -y -i " & ControlChars.Quote & aFile.FullName.ToString() & ControlChars.Quote & " -f ffmetadata " & ControlChars.Quote & "%TEMP%\" & aFile.Name.ToString() & "_metadata.txt" & ControlChars.Quote & " >NUL 2>&1 && Type " & ControlChars.Quote & "%TEMP%\" & aFile.Name.ToString() & "_metadata.txt" & ControlChars.Quote & "| FINDSTR /I " & ControlChars.Quote & "^INAM ^title" & ControlChars.Quote & " >NUL && Echo FOUND && EXIT || Echo NOT FOUND && Exit"
  177.                    ffmpeg_startinfo.UseShellExecute = False
  178.                    ffmpeg_startinfo.CreateNoWindow = True
  179.                    ffmpeg_startinfo.RedirectStandardOutput = True
  180.                    ffmpeg_startinfo.RedirectStandardError = True
  181.                    ffmpeg_process.EnableRaisingEvents = True
  182.                    ffmpeg_process.StartInfo = ffmpeg_startinfo
  183.                    ffmpeg_process.Start()
  184.                    ffmpeg_process.WaitForExit()
  185.  
  186.                    Dim readerStdOut As IO.StreamReader = ffmpeg_process.StandardOutput
  187.                    Dim FINDstdOut As String = ffmpeg_process.StandardOutput.ReadToEnd
  188.  
  189.                    If FINDstdOut.Contains("FOUND") Then
  190.                        AppendText(consolebox, Color.Red, "TAGS FOUND! Removing tags, please wait..." & vbNewLine)
  191.                        Dim relative_dir As String = aDir.FullName.ToString().Replace(aDir.Root.ToString(), "\")
  192.                        Dim ffmpegconvert_process As New Process()
  193.                        Dim ffmpegconvert_startinfo As New ProcessStartInfo()
  194.                        ffmpegconvert_startinfo.FileName = "cmd.exe "
  195.                        ffmpegconvert_startinfo.Arguments = "/C MKDIR " & ControlChars.Quote & userSelectedFolderPathmetadata & relative_dir & ControlChars.Quote & " 2>NUL & ffmpeg.exe -y -i " & ControlChars.Quote & aFile.FullName.ToString() & ControlChars.Quote & " -c copy -map_metadata -1 " & ControlChars.Quote & userSelectedFolderPathmetadata & relative_dir & "\" & aFile.Name.ToString() & ControlChars.Quote & " >NUL 2>&1 & Exit"
  196.                        ffmpegconvert_startinfo.UseShellExecute = False
  197.                        ffmpegconvert_startinfo.CreateNoWindow = True
  198.                        ffmpegconvert_startinfo.RedirectStandardOutput = True
  199.                        ffmpegconvert_startinfo.RedirectStandardError = True
  200.                        ffmpegconvert_process.EnableRaisingEvents = True
  201.                        ffmpegconvert_process.StartInfo = ffmpegconvert_startinfo
  202.                        ffmpegconvert_process.Start()
  203.                        ffmpegconvert_process.WaitForExit()
  204.                        'Dim ffmpegconvertreaderStdOut As IO.StreamReader = ffmpegconvert_process.StandardOutput
  205.                    End If
  206.  
  207.                    Do While readerStdOut.EndOfStream = False
  208.                        consolebox.AppendText(readerStdOut.ReadLine() + vbNewLine)
  209.                        consolebox.SelectionStart = consolebox.Text.Length
  210.                        consolebox.ScrollToCaret()
  211.                    Loop
  212.  
  213.                End If
  214.            End If
  215.        Next
  216.  
  217.        _WaitHandle_FirstThreadDone.Set()
  218.    End Sub
  219.  
  220.  
  221. #End Region
  222.  
  223.  
  224. #Region "Organize function"
  225.  
  226.    Public Sub MediaInfo(Directory)
  227.        Dim MyDirectory As DirectoryInfo
  228.        MyDirectory = New DirectoryInfo(NameOfDirectory)
  229.        MediaInfoWorkWithDirectory(MyDirectory)
  230.    End Sub
  231.  
  232.    Public Sub MediaInfoWorkWithDirectory(ByVal aDir As DirectoryInfo)
  233.        Dim nextDir As DirectoryInfo
  234.        Dim t As New Threading.Thread(AddressOf ThreadProc)
  235.        t.Start(aDir)
  236.        _WaitHandle_FirstThreadDone.WaitOne()
  237.        For Each nextDir In aDir.GetDirectories
  238.            If playlist = True Then
  239.                Using writer As StreamWriter = New StreamWriter(aDir.FullName & "\" & nextDir.Name & "\" & nextDir.Name & ".m3u", False, System.Text.Encoding.UTF8)
  240.                    'overwrite existing playlist
  241.                End Using
  242.            End If
  243.            MediaInfoWorkWithDirectory(nextDir)
  244.        Next
  245.    End Sub
  246.  
  247. #End Region
  248.  
  249.  
  250. #Region "Action buttons"
  251.  
  252.    ' start button
  253.    Public Sub Button2_Click(sender As Object, e As EventArgs) Handles start_button.Click
  254.  
  255.        If metadata = True And metadatatextbox.Text = "Select a folder to save the converted videos without metadata..." Then
  256.            MsgBox("You must select a folder for the saved metadata videos...", , "Filmen v1.0")
  257.        Else
  258.            If ac3 = False And dts = False And wav = False And multitrack = False And playlist = False And attribs = False And wordcase = False And metadata = False And lowercase = False Then
  259.                MsgBox("You must select at least one option...", , "Filmen v1.0")
  260.            Else
  261.  
  262.                consolebox.Clear()
  263.  
  264.                ' pause / cancel button ON
  265.                pause_button.Enabled = True
  266.                cancel_button.Enabled = True
  267.  
  268.                ' Total files label
  269.                processedfiles = 0
  270.                totalfiles_label.Text = totalfiles.ToString() + " Total video files"
  271.  
  272.                ' Problems label
  273.                problems = 0
  274.                problems_label.Text = "0 problems found"
  275.  
  276.                ' Organization process
  277.                NameOfDirectory = userSelectedFolderPath
  278.                MediaInfo(NameOfDirectory)
  279.                consolebox.AppendText(vbNewLine + "[+] Organization finalized!" + vbNewLine)
  280.                consolebox.Refresh()
  281.                consolebox.SelectionStart = consolebox.Text.Length
  282.                consolebox.ScrollToCaret()
  283.  
  284.                ' pause / cancel button OFF
  285.                pause_button.Enabled = False
  286.                cancel_button.Enabled = False
  287.  
  288.            End If
  289.        End If
  290.    End Sub
  291.  
  292. #End Region
  293.  
  294. End Class
  295.  
10075  Media / Multimedia / Re: [MOD] Busco editor de video. en: 29 Noviembre 2012, 18:58 pm
AviDemux es liviano y cumple con todo lo que pides, menos lo de cortar varias escenas, hay que cortarlas una a una.

Saludos!
10076  Programación / .NET (C#, VB.NET, ASP) / [SOURCE] PlayLists en: 29 Noviembre 2012, 18:47 pm
Bueno,
es una caca de programa porqué es el segundo programa que he hecho, y no he conseguido dejar bien la transparencia del programa ni meter la barra de progreso en un thread, pero está decente para usarse y cumple las condiciones necesarias, y me quedo satisfecho al ver la diferencia entre Batch y Winform XD

El programa sirve para seleccionar una o varias carpetas y añadirlas a la lista de reproducción del reproductor multimedia, ni más, ni menos. (Buena tool para bindearla a un "hot-corner" de la pantalla del PC)

     


Source: http://exoshare.com/download.php?uid=EJJTGEXN





Aquí dejo el "boceto" en Batch por si le sirve a alguien:

Código
  1. @echo off
  2. Title Winamp Auto Playlist Menu v0.1
  3.  
  4. :: Auto-redimensionado
  5. color 07
  6. Nircmd win center ititle "Winamp Auto Playlist Menu" >NUL 2>&1
  7. PUSHD "%~dp0"
  8. Set /a Lines=5
  9. Mode con cols=50 lines=%LINES%
  10. For /D %%# in (*) Do (Call Set /A "Lines+=2" & call Mode con cols=60 lines=%%LINES%%)
  11.  
  12. :Menu
  13. CLS
  14. SET "SELECT=" & SET "NUM="
  15. For /D %%# in (*) Do (Call Set /A "Num+=1" & Call Set "Folder%%NUM%%=%%#" & Call Set "List=%%LIST%%!!%%NUM%%" & Call Echo [%%Num%%] %%# | MORE)
  16. Echo [0] * REPRODUCIR TODO * | MORE
  17. Echo: Seleccione una carpeta para reproducirla...
  18. Set /P select=^>^>
  19. Echo "%SELECT%" | FINDSTR /I "[A-Z]" >NUL && (Goto :Menu) || (Echo "%List%" | FIND ";%SELECT% " >NUL || (Goto :Menu))
  20. If "%SELECT%" equ "0" (Goto :todo)
  21.  
  22. :Play
  23. CLS
  24. Call Echo Carpeta seleccionada: "%%Folder%SELECT%%%" | MORE
  25. Call Echo: [+] Iniciando Winamp...
  26. Call Start /B /D "%ProgramFiles(x86)%\Winamp\" winamp.exe "%CD%\%%Folder%SELECT%%%"
  27. Timeout /T 5 & Exit
  28.  
  29. :TODO
  30. CLS
  31. Call Echo Carpeta seleccionada: * TODAS * | MORE
  32. Call Echo: [+] Iniciando Winamp...
  33. For /D %%# in (*) Do (Call Set "ARG=%%arg%% ^"%CD%\%%#^"")
  34. Call Start /B /D "%ProgramFiles(x86)%\Winamp\" winamp.exe %%arg%%
  35. Timeout /T 10 & Exit
10077  Programación / .NET (C#, VB.NET, ASP) / (Solucionado) Problema con mi thread... en: 29 Noviembre 2012, 18:05 pm
EDITO: Lo he resuelto creando nuevas instancias del thread dentro del loop

Tengo este thread:

Código
  1. Public Sub ThreadProc(ByVal aDir As DirectoryInfo)
  2.    Dim i As Integer
  3.    For i = 1 To 3
  4.        MsgBox(i)
  5.        Thread.Sleep(500)
  6.    Next
  7.    _WaitHandle_FirstThreadDone.Set()
  8. End Sub
  9.  

Y tengo un búcle que hace esto:

Código
  1.   loop...
  2.    t.Start(aDir)
  3.    _WaitHandle_FirstThreadDone.WaitOne()
  4.   next...

El problema es que solo se ejecuta el thread una sola vez, cuando intenta iniciarse la siguiente vez me dice el debugger: "Subproceso en ejecución o terminado, no se pudo reiniciar",
y no lo entiendo, creo que le estoy indicando al thread que se "setee" como finalizado, y el loop espera a que finalize el thread.. así que no sé donde estará el problema, de verdad no lo entiendo!
10078  Programación / Scripting / Re: [RUBY] GameTracker ServerList en: 29 Noviembre 2012, 12:28 pm
GameTracker ha cambiado el sistema de búsqueda y ha aumentado un poco la seguridad (Ahora la localización del país es "Case-Sensitive"), así que la versión anterior queda obsoleta, he hecho una nueva versión.

Y como extra, la tool ahora genera un archivo de favoritos para reemplazar el archivo dentro de la carpeta del juego y no tener que ir metiendo las ips dentro del juego:

Ejemplo:

serverbrowser_hist.vdf
Código:
"Filters"
{
"favorites"
{
"1"
{
"name" "89.44.246.123:27015"
"address" "89.44.246.123:27015"
"lastplayed" "1256267351"
"appID" "0"
}
"2"
{
"name" "89.44.246.14:27015"
"address" "89.44.246.14:27015"
"lastplayed" "1256267351"
"appID" "0"

etc.
etc..
etc...


Executable: http://exoshare.com/download.php?uid=QNKEUJXB


GTSL.rb:
Código
  1.  
  2. # GameTracker ServerList v1.2
  3. #
  4. # By Elektro H@cker
  5.  
  6.  
  7. # Description:
  8. # -----------
  9. # This tool retreives the servers list of a game from GameTracker site,
  10. # and generates a favorite gameserver steam list.
  11.  
  12.  
  13. # How to use:
  14. # ----------
  15. #
  16. # GTSL.rb help
  17. #
  18. # GTSL.rb (game) (location) (output file)
  19. #
  20. # Or change the default values...
  21. #
  22. # Default values:
  23. $game     = "cs"
  24. $location = "ES"
  25. # # # # # # # #
  26.  
  27. require 'net/http'
  28.  
  29. exit if Object.const_defined?(:Ocra)
  30.  
  31. $url = "http://www.gametracker.com/search/#{$game}/#{$location.upcase}/?searchipp=50&searchpge=1#search"
  32.  
  33. def logo()
  34. puts '
  35.  GameTracker Server List
  36.  
  37.  By Elektro H@cker
  38. '
  39. end
  40.  
  41.  
  42. def help()
  43.  
  44.  puts '
  45.  
  46.  Options:
  47.  _______
  48.  
  49.  /? (or) help (or) -h (or) -help | Shows this help.
  50.  
  51.  
  52.  Parameters:
  53.  __________        
  54.  
  55.  (game)      | The game kind.
  56.  
  57.  (locacion)  | The geo-location of servers.
  58.  
  59.  (file)      | The output file.  
  60.  
  61.  
  62.  How to use:
  63.  __________
  64.  
  65.  GTSL.rb -help
  66.  
  67.  GTSL.rb (game) (location) (output file)
  68.  
  69.  PS: Or change the two default values near the start line inside the script...
  70.  
  71.  
  72.  Examples:
  73.  ________
  74.  
  75.  GTSL CS UK
  76.  [+] Gets all the UK servers for Counter-Strike 1.6
  77.      and save it in the default generated file.
  78.  
  79.  
  80.  GTSL HL ES "servers.txt"
  81.  [+] Gets all the Spanish servers for Half-life
  82.      and save it in the custom file ("servers.txt").
  83.  '
  84.  
  85.  # game value list
  86.  puts "\n
  87.  Game values:
  88.  ___________\n"
  89.  puts Net::HTTP.get_response(URI.parse($url)).body.split('<option value="_all">All Games</option>').last.split('</select>').first.gsub('<option value="', "").gsub('</option>', "").gsub(' selected="selected"', "").gsub('" >', " = ").gsub(" ", "  ")
  90.  
  91.  # location value list
  92.  puts "\n
  93.  Location values:
  94.  _______________\n"
  95.  puts Net::HTTP.get_response(URI.parse($url)).body.split('<optgroup label="Search by country">').last.split('</optgroup>').first.gsub('<option value="', "").gsub('</option>', "").gsub(' selected', "").gsub('" >', " = ").gsub(" ", "  ")
  96.  
  97.  exit
  98.  
  99. end
  100.  
  101.  
  102. def args()
  103.  if ARGV[0] =~ /help/i or ARGV[0] =~ /-help/i or ARGV[0] =~ /-h/i or ARGV[0] == "/?" then help()    end
  104.  if not ARGV[0].nil?   then $game     = ARGV[0] end
  105.  if not ARGV[1].nil?   then $location = ARGV[1] end
  106.  if not ARGV[2].nil?   then $file     = ARGV[2] else $file = ".\\#{$game}-#{$location.upcase} servers.txt" end
  107. end
  108.  
  109.  
  110. def info()
  111.  puts "
  112.  Game    : #{$game}
  113.  Location: #{$location.upcase}
  114.  Pages   : #{$pag}
  115.  Servers : #{$pag*50} (approx.)
  116.  
  117.  "
  118. end
  119.  
  120.  
  121. def get_pages()
  122.  $pag = 0
  123.  $url = "http://www.gametracker.com/search/#{$game}/#{$location.upcase}/?searchipp=50&searchpge=1&sort=c_name&order=ASC"
  124.  Net::HTTP.get_response(URI.parse($url)).body.each_line do |line|
  125.    if (line[/;order=ASC#search">NEXT<\/a>/]) then break  end
  126.    if (line[/^\s+<a href="\/search\/.+\/.+\/?searchipp=50&amp;searchpge=[0-9]+&amp;sort=c_name&amp;order=ASC#search">[0-9]+<\/a>\s+$/])
  127.      if $pag < line.split("</a>").first.split('>').last.to_i
  128.         $pag = line.split("</a>").first.split('>').last.to_i
  129.      end
  130.    end
  131.  end
  132. end
  133.  
  134.  
  135. def show_ips()
  136.  a = 0
  137.  
  138.  print "[+] Parsing pages "
  139.  
  140.  File.open('serverbrowser_hist.vdf', 'a+') do |favorites|
  141.    favorites.puts '"Filters"'
  142.    favorites.puts '{'
  143.    favorites.puts '"favorites"'
  144.    favorites.puts '{'
  145.  end
  146.  
  147.  for i in 1..$pag do
  148.    print "#{i}/#{$pag}..."
  149.    $url = "http://www.gametracker.com/search/#{$game}/#{$location.upcase}/?searchipp=50&searchpge=#{i}#search"
  150.    Net::HTTP.get_response(URI.parse($url)).body.each_line do |line|
  151.  
  152.      # puts line.split("/")[2] if (line["server_info"])
  153.  
  154.      File.open($file, 'a+') do |f|
  155.        f.puts line.split("/")[2] if (line["server_info"])
  156.      end
  157.  
  158.      File.open('serverbrowser_hist.vdf', 'a+') do |favorites|
  159.        a = a+1 if (line["server_info"])
  160.        favorites.puts "\"#{a}\""                              if (line["server_info"])
  161.        favorites.puts "{"                                     if (line["server_info"])
  162.        favorites.puts "\"name\" \"#{line.split("/")[2]}\""    if (line["server_info"])
  163.        favorites.puts "\"address\" \"#{line.split("/")[2]}\"" if (line["server_info"])
  164.        favorites.puts "\"lastplayed\" \"1256267351\""         if (line["server_info"])
  165.        favorites.puts "\"appID\" \"0\""                       if (line["server_info"])
  166.        favorites.puts "}"                                     if (line["server_info"])
  167.      end
  168.  
  169.    end
  170.  end
  171.  
  172.  File.open('serverbrowser_hist.vdf', 'a+') do |favorites|
  173.    favorites.puts '}'
  174.    favorites.puts '"History"'
  175.    favorites.puts '{'
  176.    favorites.puts '}'
  177.    favorites.puts '}'
  178.  end
  179.  
  180. end
  181.  
  182.  
  183. logo()
  184. args()
  185. get_pages()
  186. info()
  187. show_ips()
  188.  
  189.  
  190. exit
10079  Programación / Scripting / Re: pasar parametros a otra consola...no a un segundo bat en: 29 Noviembre 2012, 09:42 am
Código
  1. @Echo OFF
  2.  
  3. set /p X=ingrese la unidad que va a boteear %2
  4.  
  5. (
  6. echo select disk %X% %3
  7. echo clean %4
  8. echo create partition primary %5
  9. echo select partition 1 %6
  10. echo active %7
  11. echo format fs=fat32 quick %8
  12. echo assign %9
  13. )> "%TEMP%\diskpart.txt"
  14.  
  15. Diskpart /S "%TEMP%\diskpart.txt"
10080  Programación / .NET (C#, VB.NET, ASP) / Re: Como puedo interrumpir el thread en un For while? en: 29 Noviembre 2012, 00:27 am
De verdad, llevo todo el día sin poder progresar con mi form, no consigo meter los subs de "organize function" region en un nuevo thread para que no me bloquee la app.

Estoy harto de hacer borrón y cuenta nueva, sin ayuda no puedo hacer esto...

He leido decenas de ejemplos, pero en ninguno tratan un caso parecido al mío, solo son threads con un "FOR" y eso no me sirve para nada,
Entiendo más o menos como funciona el backgroundworker, pero como son 3 subs, es que me pierdo porque necesito pasarle un argumento al thread, al trasladar la region a un nuevo thread...

Espero la bondad de alguien para que me inserte toda la region de "organize function" para que trabaje en un nuevo thread



Este es el form completo:

PD: Hay un thread por ahí suelto en el form, pero solo lo puse para tenerlo a mano, para hacer mis experimentos  :xD

Al pinchar en el start button llama a la función de "organize function", que como ya digo, son 3 subs.



Código
  1. Imports System.IO
  2. Imports System.Threading
  3. Imports System.Runtime.InteropServices
  4. Imports System.ComponentModel
  5. Imports Ookii.Dialogs
  6.  
  7.  
  8.  
  9.  
  10.    Public Class Form1
  11.  
  12. #Region "Declarations"
  13.  
  14.        ' Extensions
  15.        Dim accepted_extensions As String = ".264 .3gp .asf .asx .avi .avc .bsf .bdmv .divx .dv .evo .f4v .flv .hdmov .m1v .m2t .m2ts .m2v .m4v .mkv .mov .mp4 .mpeg .mpg .mpv4 .mts .ogm .ogv .qt .rmvb .swf .ts .vob .webm .wmv"
  16.  
  17.        ' Options
  18.        Dim attribs As Boolean
  19.        Dim playlist As Boolean
  20.        Dim multitrack As Boolean
  21.        Dim metadata As Boolean
  22.        Dim wordcase As Boolean
  23.        Dim lowercase As Boolean
  24.        Dim ac3 As Boolean
  25.        Dim dts As Boolean
  26.        Dim wav As Boolean
  27.  
  28.        ' Outputs
  29.        Dim output As String
  30.        Dim To_Display As String
  31.  
  32.        ' MediaInfo
  33.        Dim MI As MediaInfo
  34.  
  35.        ' Backgroundworker
  36.        Dim paused As Boolean = False
  37.  
  38.        ' Others
  39.        Dim processedfiles As Integer = Nothing
  40.        Dim totalfiles As Integer = Nothing
  41.        Dim problems As Integer = Nothing
  42.        Dim NameOfDirectory As String = Nothing
  43.        Dim aFile As FileInfo
  44.  
  45.        'Highlighted ranges
  46.        Dim a As Integer
  47.    Dim b As Integer
  48.  
  49.  
  50.  
  51. #End Region
  52.  
  53.  
  54.    Dim t As New Thread(AddressOf ThreadProc)
  55.  
  56.    Public Sub ThreadProc()
  57.        Dim i As Integer
  58.        For i = 0 To 90
  59.            If paused = True Then MsgBox("SUSPEND")
  60.            MsgBox(i)
  61.            ' Yield the rest of the time slice.
  62.            Thread.Sleep(1500)
  63.        Next
  64.    End Sub
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72. #Region "Properties"
  73.  
  74.        ' Folder textbox
  75.        Public Property userSelectedFolderPath() As String
  76.            Get
  77.                Return foldertextbox.Text
  78.            End Get
  79.            Set(value As String)
  80.                foldertextbox.Text = value
  81.            End Set
  82.        End Property
  83.  
  84.        ' Metadata textbox
  85.        Public Property userSelectedFolderPathmetadata() As String
  86.            Get
  87.                Return metadatatextbox.Text
  88.            End Get
  89.            Set(value As String)
  90.                metadatatextbox.Text = value
  91.            End Set
  92.        End Property
  93.  
  94.        ' Paused backgroundworker
  95.        Public Property IsPaused() As Boolean
  96.            Get
  97.                Return paused
  98.            End Get
  99.            Set(value As Boolean)
  100.                paused = value
  101.            End Set
  102.        End Property
  103.  
  104. #End Region
  105.  
  106. #Region "Load / Close"
  107.  
  108.        ' Load
  109.        Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  110.  
  111.            ' Options checkboxes
  112.            If My.Settings.delattribs Then attrib_checkbox.Checked = True
  113.            If My.Settings.genplaylists Then playlist_checkbox.Checked = True
  114.            If My.Settings.findmultitracks Then multitrack_checkbox.Checked = True
  115.            If My.Settings.findac3 Then ac3_checkbox.Checked = True
  116.            If My.Settings.finddts Then dts_checkbox.Checked = True
  117.            If My.Settings.findwav Then wav_checkbox.Checked = True
  118.            If My.Settings.findmetadata Then metadata_checkbox.Checked = True
  119.            If My.Settings.renwordcase Then wordcase_checkbox.Checked = True
  120.            If My.Settings.renlowercase Then lowercase_checkbox.Checked = True
  121.  
  122.            ' Folder button
  123.            If Not My.Computer.FileSystem.DirectoryExists(My.Settings.folderpath) Then
  124.                foldertextbox.Text = "Select a folder..."
  125.                My.Settings.folderpath = Nothing
  126.                My.Settings.Save()
  127.            Else
  128.                foldertextbox.Text = My.Settings.folderpath
  129.                start_button.Enabled = True
  130.                ' Total files label
  131.                NameOfDirectory = userSelectedFolderPath
  132.                gettotalfiles(NameOfDirectory)
  133.                totalfiles_label.Text = totalfiles.ToString() + " Total video files"
  134.            End If
  135.  
  136.            If Not My.Computer.FileSystem.DirectoryExists(My.Settings.metadatafolder) Then
  137.                metadatatextbox.Text = "Select a folder to save the converted videos without metadata..."
  138.                My.Settings.metadatafolder = Nothing
  139.                My.Settings.Save()
  140.            Else
  141.                metadatatextbox.Text = My.Settings.metadatafolder
  142.            End If
  143.  
  144.            ' MediaInfo Instance
  145.            MI = New MediaInfo
  146.  
  147.        End Sub
  148.  
  149. #End Region
  150.  
  151. #Region "Get Total files Function"
  152.  
  153.        Public Sub gettotalfiles(Directory)
  154.            totalfiles = 0
  155.            Dim MyDirectory As DirectoryInfo
  156.            MyDirectory = New DirectoryInfo(NameOfDirectory)
  157.            gettotalfilesWorkWithDirectory(MyDirectory)
  158.        End Sub
  159.  
  160.        Public Sub gettotalfilesWorkWithDirectory(ByVal aDir As DirectoryInfo)
  161.            Dim nextDir As DirectoryInfo
  162.            gettotalfilesWorkWithFilesInDir(aDir)
  163.            For Each nextDir In aDir.GetDirectories
  164.                gettotalfilesWorkWithDirectory(nextDir)
  165.            Next
  166.        End Sub
  167.  
  168.        Public Sub gettotalfilesWorkWithFilesInDir(ByVal aDir As DirectoryInfo)
  169.            Dim aFile As FileInfo
  170.            For Each aFile In aDir.GetFiles()
  171.                If accepted_extensions.ToLower.Contains(aFile.Extension.ToLower) Then totalfiles += 1
  172.            Next
  173.        End Sub
  174.  
  175. #End Region
  176.  
  177. #Region "Option checkboxes"
  178.        ' attributtes checkbox
  179.        Private Sub attrib_button_CheckedChanged(sender As Object, e As EventArgs) Handles attrib_checkbox.CheckedChanged
  180.            If attrib_checkbox.Checked = True Then
  181.                attribs = True
  182.                My.Settings.delattribs = True
  183.            Else
  184.                attribs = False
  185.                My.Settings.delattribs = False
  186.            End If
  187.            My.Settings.Save()
  188.        End Sub
  189.  
  190.        ' playlist checkbox
  191.        Private Sub playlist_button_CheckedChanged(sender As Object, e As EventArgs) Handles playlist_checkbox.CheckedChanged
  192.            If playlist_checkbox.Checked = True Then
  193.                playlist = True
  194.                My.Settings.genplaylists = True
  195.            Else
  196.                playlist = False
  197.                My.Settings.genplaylists = False
  198.            End If
  199.            My.Settings.Save()
  200.        End Sub
  201.  
  202.        ' multitrack checkbox
  203.        Private Sub multitrack_button_CheckedChanged(sender As Object, e As EventArgs) Handles multitrack_checkbox.CheckedChanged
  204.            If multitrack_checkbox.Checked = True Then
  205.                multitrack = True
  206.                My.Settings.findmultitracks = True
  207.            Else
  208.                multitrack = False
  209.                My.Settings.findmultitracks = False
  210.            End If
  211.            My.Settings.Save()
  212.        End Sub
  213.  
  214.        ' AC-3 checkbox
  215.        Private Sub ac3_button_CheckedChanged(sender As Object, e As EventArgs) Handles ac3_checkbox.CheckedChanged
  216.            If ac3_checkbox.Checked = True Then
  217.                ac3 = True
  218.                My.Settings.findac3 = True
  219.            Else
  220.                ac3 = False
  221.                My.Settings.findac3 = False
  222.            End If
  223.            My.Settings.Save()
  224.        End Sub
  225.  
  226.        ' DTS checkbox
  227.        Private Sub dts_button_CheckedChanged(sender As Object, e As EventArgs) Handles dts_checkbox.CheckedChanged
  228.            If dts_checkbox.Checked = True Then
  229.                dts = True
  230.                My.Settings.finddts = True
  231.            Else
  232.                dts = False
  233.                My.Settings.finddts = False
  234.            End If
  235.            My.Settings.Save()
  236.        End Sub
  237.  
  238.        ' WAV checkbox
  239.        Private Sub wav_button_CheckedChanged(sender As Object, e As EventArgs) Handles wav_checkbox.CheckedChanged
  240.            If wav_checkbox.Checked = True Then
  241.                wav = True
  242.                My.Settings.findwav = True
  243.            Else
  244.                wav = False
  245.                My.Settings.findwav = False
  246.            End If
  247.            My.Settings.Save()
  248.        End Sub
  249.  
  250.        ' Metadata checkbox
  251.        Private Sub metadata_checkbox_CheckedChanged(sender As Object, e As EventArgs) Handles metadata_checkbox.CheckedChanged
  252.            If metadata_checkbox.Checked = True Then
  253.                metadatatextbox.Enabled = True
  254.                metadatabutton.Enabled = True
  255.                metadata = True
  256.                My.Settings.findmetadata = True
  257.            Else
  258.                metadatatextbox.Enabled = False
  259.                metadatabutton.Enabled = False
  260.                metadata = False
  261.                My.Settings.findmetadata = False
  262.            End If
  263.            My.Settings.Save()
  264.        End Sub
  265.  
  266.        ' Word-case
  267.        Private Sub wordcase_checkbox_CheckedChanged(sender As Object, e As EventArgs) Handles wordcase_checkbox.CheckedChanged
  268.            If wordcase_checkbox.Checked = True Then
  269.                wordcase = True
  270.                lowercase = False
  271.                lowercase_checkbox.Checked = False
  272.                My.Settings.renwordcase = True
  273.            Else
  274.                wordcase = False
  275.                My.Settings.renwordcase = False
  276.            End If
  277.            My.Settings.Save()
  278.        End Sub
  279.  
  280.        ' Lower-case
  281.        Private Sub lowercase_checkbox_CheckedChanged(sender As Object, e As EventArgs) Handles lowercase_checkbox.CheckedChanged
  282.            If lowercase_checkbox.Checked = True Then
  283.                lowercase = True
  284.                wordcase = False
  285.                wordcase_checkbox.Checked = False
  286.                My.Settings.renlowercase = True
  287.            Else
  288.                lowercase = False
  289.                My.Settings.renlowercase = False
  290.            End If
  291.            My.Settings.Save()
  292.        End Sub
  293.  
  294. #End Region
  295.  
  296. #Region "Folder buttons"
  297.  
  298.        ' Folder button
  299.        Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click
  300.            Dim folderselect As New VistaFolderBrowserDialog
  301.            folderselect.ShowNewFolderButton = True
  302.            If folderselect.ShowDialog.ToString() = "OK" Then
  303.                userSelectedFolderPath = folderselect.SelectedPath
  304.                My.Settings.folderpath = folderselect.SelectedPath
  305.                My.Settings.Save()
  306.                NameOfDirectory = userSelectedFolderPath
  307.                gettotalfiles(NameOfDirectory)
  308.                totalfiles_label.Text = totalfiles.ToString() + " Total video files"
  309.                start_button.Enabled = True
  310.            End If
  311.        End Sub
  312.  
  313.        ' Metadata folder button
  314.        Public Sub metadatabutton_Click(sender As Object, e As EventArgs) Handles metadatabutton.Click
  315.            Dim metadatafolderselect As New VistaFolderBrowserDialog
  316.            metadatafolderselect.ShowNewFolderButton = True
  317.            If metadatafolderselect.ShowDialog.ToString() = "OK" Then
  318.                userSelectedFolderPathmetadata = metadatafolderselect.SelectedPath
  319.                My.Settings.metadatafolder = metadatafolderselect.SelectedPath
  320.                My.Settings.Save()
  321.            End If
  322.        End Sub
  323.  
  324. #End Region
  325.  
  326. #Region "Append text function"
  327.  
  328.        ' Append Text
  329.        Private Sub AppendText(box As RichTextBox, color As Color, text As String)
  330.            Dim start As Integer = box.TextLength
  331.            box.AppendText(text)
  332.            Dim [end] As Integer = box.TextLength
  333.  
  334.            ' Textbox may transform chars, so (end-start) != text.Length
  335.            box.[Select](start, [end] - start)
  336.            If True Then
  337.                box.SelectionColor = color
  338.                ' could set box.SelectionBackColor, box.SelectionFont too.
  339.            End If
  340.            box.SelectionLength = 0
  341.            ' clear
  342.        End Sub
  343.  
  344. #End Region
  345.  
  346.  
  347.  
  348.  
  349. #Region "Organize function"
  350.  
  351.        Public Sub MediaInfo(Directory)
  352.            Dim MyDirectory As DirectoryInfo
  353.            MyDirectory = New DirectoryInfo(NameOfDirectory)
  354.            MediaInfoWorkWithDirectory(MyDirectory)
  355.        End Sub
  356.  
  357.        Public Sub MediaInfoWorkWithDirectory(ByVal aDir As DirectoryInfo)
  358.            Dim nextDir As DirectoryInfo
  359.            MediaInfoWorkWithFilesInDir(aDir)
  360.        For Each nextDir In aDir.GetDirectories
  361.            If playlist = True Then
  362.                Using writer As StreamWriter = New StreamWriter(aDir.FullName & "\" & nextDir.Name & "\" & nextDir.Name & ".m3u", False, System.Text.Encoding.UTF8)
  363.                    'overwrite existing playlist
  364.                End Using
  365.            End If
  366.            MediaInfoWorkWithDirectory(nextDir)
  367.        Next
  368.        End Sub
  369.  
  370.        Public Sub MediaInfoWorkWithFilesInDir(ByVal aDir As DirectoryInfo)
  371.  
  372.            Dim aFile As FileInfo
  373.  
  374.            For Each aFile In aDir.GetFiles()
  375.  
  376.                If accepted_extensions.ToLower.Contains(aFile.Extension.ToLower) Then
  377.  
  378.                    ' print output
  379.                    AppendText(consolebox, Color.Yellow, "Processing: ")
  380.                    AppendText(consolebox, Color.White, aFile.ToString() + vbNewLine)
  381.                    consolebox.ScrollToCaret()
  382.                    processedfiles += 1
  383.                    totalfiles_label.Text = "Processed " + processedfiles.ToString() + " of " + totalfiles.ToString() + " total video files"
  384.  
  385.                    ' Attributes
  386.                    If attribs = True Then
  387.                        aFile.Attributes = (aFile.Attributes And Not FileAttributes.ReadOnly And Not FileAttributes.Hidden And Not FileAttributes.System And Not FileAttributes.Archive)
  388.                    End If
  389.  
  390.                    ' Rename to Word-Case
  391.                    If wordcase = True Then
  392.                        Dim renamestr As String = StrConv(aFile.Name, VbStrConv.ProperCase)
  393.                        My.Computer.FileSystem.RenameFile(aFile.FullName, renamestr + "_FILMEN")
  394.                        My.Computer.FileSystem.RenameFile(aFile.FullName + "_FILMEN", renamestr)
  395.                    End If
  396.  
  397.                    ' Rename to Lower-Case
  398.                    If lowercase = True Then
  399.                        Dim renamestr As String = StrConv(aFile.Name, VbStrConv.Lowercase)
  400.                        My.Computer.FileSystem.RenameFile(aFile.FullName, renamestr + "_FILMEN")
  401.                        My.Computer.FileSystem.RenameFile(aFile.FullName + "_FILMEN", renamestr)
  402.                    End If
  403.  
  404.                    ' Playlists
  405.                    If playlist = True Then
  406.                        Using writer As StreamWriter = New StreamWriter(aFile.DirectoryName.ToString() & "\" & aDir.Name & ".m3u", True, System.Text.Encoding.UTF8)
  407.                            writer.WriteLine(aFile.FullName.ToString())
  408.                        End Using
  409.                    End If
  410.  
  411.                    ' MEDIAINFO:  (ac3, dts, wav and multitrack)
  412.                    If ac3 = True Or dts = True Or wav = True Or multitrack = True Then
  413.  
  414.                        MI.Open(aFile.FullName)
  415.  
  416.                        Dim Pos As Integer = 0
  417.                        To_Display = Nothing
  418.  
  419.                        ' multitrack
  420.                        If multitrack = True Then
  421.                            If MI.Count_Get(StreamKind.Audio) > 1 Then
  422.                                results_box.AppendText("Multi Track: " + aFile.FullName.ToString() + vbNewLine)
  423.                                results_box.SelectionStart = results_box.Text.Length
  424.                                results_box.ScrollToCaret()
  425.                                problems += 1
  426.                                problems_label.Text = problems.ToString() + " problems found"
  427.                            End If
  428.                        End If
  429.  
  430.                        While Pos < MI.Count_Get(StreamKind.Audio)
  431.  
  432.                            ' AC-3
  433.                            If ac3 = True Then
  434.                                If MI.Get_(StreamKind.Audio, Pos, "Format").ToString() = "AC-3" Then
  435.                                    results_box.AppendText("AC3 Track: " + aFile.FullName.ToString() + vbNewLine)
  436.                                    results_box.SelectionStart = results_box.Text.Length
  437.                                    results_box.ScrollToCaret()
  438.                                    problems += 1
  439.                                    problems_label.Text = problems.ToString() + " problems found"
  440.                                End If
  441.                            End If
  442.  
  443.                            ' DTS
  444.                            If dts = True Then
  445.                                If MI.Get_(StreamKind.Audio, Pos, "Format").Contains("DTS") Then
  446.                                    results_box.AppendText("DTS Track: " + aFile.FullName.ToString() + vbNewLine)
  447.                                    results_box.SelectionStart = results_box.Text.Length
  448.                                    results_box.ScrollToCaret()
  449.                                    problems += 1
  450.                                    problems_label.Text = problems.ToString() + " problems found"
  451.                                End If
  452.                            End If
  453.  
  454.                            ' WAV
  455.                            If wav = True Then
  456.                                If MI.Get_(StreamKind.Audio, Pos, "Format").Contains("PCM") Then
  457.                                    results_box.AppendText("WAV Track: " + aFile.FullName.ToString() + vbNewLine)
  458.                                    results_box.SelectionStart = results_box.Text.Length
  459.                                    results_box.ScrollToCaret()
  460.                                    problems += 1
  461.                                    problems_label.Text = problems.ToString() + " problems found"
  462.                                End If
  463.                            End If
  464.  
  465.                            System.Math.Max(System.Threading.Interlocked.Increment(Pos), Pos - 1)
  466.                        End While
  467.                    End If
  468.  
  469.                    If metadata = True Then
  470.                        Dim ffmpeg_process As New Process()
  471.                        Dim ffmpeg_startinfo As New ProcessStartInfo()
  472.                        ffmpeg_startinfo.FileName = "cmd.exe "
  473.                        ffmpeg_startinfo.Arguments = "/C ffmpeg.exe -y -i " & ControlChars.Quote & aFile.FullName.ToString() & ControlChars.Quote & " -f ffmetadata " & ControlChars.Quote & "%TEMP%\" & aFile.Name.ToString() & "_metadata.txt" & ControlChars.Quote & " >NUL 2>&1 && Type " & ControlChars.Quote & "%TEMP%\" & aFile.Name.ToString() & "_metadata.txt" & ControlChars.Quote & "| FINDSTR /I " & ControlChars.Quote & "^INAM ^title" & ControlChars.Quote & " >NUL && Echo FOUND && EXIT || Echo NOT FOUND && Exit"
  474.                        ffmpeg_startinfo.UseShellExecute = False
  475.                        ffmpeg_startinfo.CreateNoWindow = True
  476.                        ffmpeg_startinfo.RedirectStandardOutput = True
  477.                        ffmpeg_startinfo.RedirectStandardError = True
  478.                        ffmpeg_process.EnableRaisingEvents = True
  479.                        ffmpeg_process.StartInfo = ffmpeg_startinfo
  480.                        ffmpeg_process.Start()
  481.                        ffmpeg_process.WaitForExit()
  482.  
  483.                        Dim readerStdOut As IO.StreamReader = ffmpeg_process.StandardOutput
  484.                        Dim FINDstdOut As String = ffmpeg_process.StandardOutput.ReadToEnd
  485.  
  486.                        If FINDstdOut.Contains("FOUND") Then
  487.                            AppendText(consolebox, Color.Red, "TAGS FOUND! Removing tags, please wait..." & vbNewLine)
  488.                            Dim relative_dir As String = aDir.FullName.ToString().Replace(aDir.Root.ToString(), "\")
  489.                            Dim ffmpegconvert_process As New Process()
  490.                            Dim ffmpegconvert_startinfo As New ProcessStartInfo()
  491.                            ffmpegconvert_startinfo.FileName = "cmd.exe "
  492.                            ffmpegconvert_startinfo.Arguments = "/C MKDIR " & ControlChars.Quote & userSelectedFolderPathmetadata & relative_dir & ControlChars.Quote & " 2>NUL & ffmpeg.exe -y -i " & ControlChars.Quote & aFile.FullName.ToString() & ControlChars.Quote & " -c copy -map_metadata -1 " & ControlChars.Quote & userSelectedFolderPathmetadata & relative_dir & "\" & aFile.Name.ToString() & ControlChars.Quote & " >NUL 2>&1 & Exit"
  493.                            ffmpegconvert_startinfo.UseShellExecute = False
  494.                            ffmpegconvert_startinfo.CreateNoWindow = True
  495.                            ffmpegconvert_startinfo.RedirectStandardOutput = True
  496.                            ffmpegconvert_startinfo.RedirectStandardError = True
  497.                            ffmpegconvert_process.EnableRaisingEvents = True
  498.                            ffmpegconvert_process.StartInfo = ffmpegconvert_startinfo
  499.                            ffmpegconvert_process.Start()
  500.                            ffmpegconvert_process.WaitForExit()
  501.                            'Dim ffmpegconvertreaderStdOut As IO.StreamReader = ffmpegconvert_process.StandardOutput
  502.  
  503.                        End If
  504.  
  505.                        Do While readerStdOut.EndOfStream = False
  506.                            consolebox.AppendText(readerStdOut.ReadLine() + vbNewLine)
  507.                            consolebox.SelectionStart = consolebox.Text.Length
  508.                            consolebox.ScrollToCaret()
  509.                        Loop
  510.  
  511.                    End If
  512.                End If
  513.            Next
  514.  
  515.        End Sub
  516.  
  517. #End Region
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.        ' start button
  529.        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles start_button.Click
  530.  
  531.  
  532.  
  533.            If metadata = True And metadatatextbox.Text = "Select a folder to save the converted videos without metadata..." Then
  534.                MsgBox("You must select a folder for the saved metadata videos...", , "Filmen v1.0")
  535.            Else
  536.                If ac3 = False And dts = False And wav = False And multitrack = False And playlist = False And attribs = False And wordcase = False And metadata = False And lowercase = False Then
  537.                    MsgBox("You must select at least one option...", , "Filmen v1.0")
  538.                Else
  539.  
  540.                    consolebox.Clear()
  541.  
  542.                    ' pause / cancel button ON
  543.                    pause_button.Enabled = True
  544.                    cancel_button.Enabled = True
  545.  
  546.  
  547.  
  548.                t.Start()
  549.  
  550.  
  551.  
  552.                    ' Total files label
  553.                    processedfiles = 0
  554.                    totalfiles_label.Text = totalfiles.ToString() + " Total video files"
  555.  
  556.                    ' Problems label
  557.                    problems = 0
  558.                    problems_label.Text = "0 problems found"
  559.  
  560.                    ' Attempt message
  561.                    consolebox.AppendText(vbNewLine + "[+] Attempting to organize your videos in 3...")
  562.                    consolebox.Refresh()
  563.                    consolebox.SelectionStart = consolebox.Text.Length
  564.                    consolebox.ScrollToCaret()
  565.                    Thread.Sleep(750)
  566.                    consolebox.AppendText(vbNewLine + "[+] Attempting to organize your videos in 2...")
  567.                    consolebox.Refresh()
  568.                    consolebox.SelectionStart = consolebox.Text.Length
  569.                    consolebox.ScrollToCaret()
  570.                    Thread.Sleep(750)
  571.                    consolebox.AppendText(vbNewLine + "[+] Attempting to organize your videos in 1..." + vbNewLine + vbNewLine)
  572.                    consolebox.Refresh()
  573.                    consolebox.SelectionStart = consolebox.Text.Length
  574.                    consolebox.ScrollToCaret()
  575.                    Thread.Sleep(750)
  576.  
  577.                    ' Organization process
  578.                    NameOfDirectory = userSelectedFolderPath
  579.                    MediaInfo(NameOfDirectory)
  580.                    consolebox.AppendText(vbNewLine + "[+] Organization finalized!" + vbNewLine)
  581.                    consolebox.Refresh()
  582.                    consolebox.SelectionStart = consolebox.Text.Length
  583.                    consolebox.ScrollToCaret()
  584.  
  585.                    ' pause / cancel button OFF
  586.                    pause_button.Enabled = False
  587.                    cancel_button.Enabled = False
  588.  
  589.                End If
  590.            End If
  591.        End Sub
  592.  
  593.    Private Sub pause_button_Click(sender As Object, e As EventArgs) Handles pause_button.Click
  594.        paused = True
  595.    End Sub
  596. End Class
  597.  
  598.  


Páginas: 1 ... 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 [1008] 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines