darioragusa / JWLibrary-MediaInserter

Add custom images or videos to the Watchtower or the Meeting Workbook.
MIT License
21 stars 3 forks source link

MediaExtract from JWPUB #10

Closed livrasand closed 2 years ago

livrasand commented 2 years ago

First of all: Sorry for the translation, I use Google Translate.

Hello @darioragusa we have had conversations together before, now I am trying to extract the images and videos from a JWPUB file, I have already managed to get the images, now I need to extract the videos from the database. My friend @TjeuKayim recommended that we could get something here together. I hope you join the conversation!

I've already had a little chat with @MrCyjaneK here, you can take a look if you like.

This is what I have of code so far, it's very simple but it works:

Imports System
Imports System.Net
Imports System.IO.Compression
Imports System.IO
Imports System.IO.Compression.ZipFile
Imports System.Data.SQLite
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Windows

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Try
            Label1.Text = "Creando el directorio de descarga temporal"
            My.Computer.FileSystem.CreateDirectory("C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D")
        Catch ex As Exception
            MsgBox("No se pudo crear el directorio" & vbCrLf & ex.Message)
        End Try

        Dim client As New WebClient()
        If My.Computer.Network.IsAvailable Then
            Try
                Label1.Text = "Descargando el archivo JWPUB..."
                My.Computer.Network.DownloadFile("https://download-a.akamaihd.net/files/media_periodical/c8/mwb_S_202207.jwpub", "C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.jwpub")
            Catch ex As Exception
                MsgBox("No se pudo descargar el archivo JWPUB" & vbCrLf & ex.Message)
            End Try
        Else
            Label1.Text = "Conectate a Internet"
            MsgBox("No estás conectado a Internet")
        End If

        Try
            Label1.Text = "Espere 3 segundos..."
            System.Threading.Thread.Sleep(3000)
        Catch ex As Exception
            MsgBox("No se pudo esperar los 3 segundos" & vbCrLf & ex.Message)
        End Try

        Try
            Label1.Text = "Cambiando el nombre al archivo JWPUB por ZIP"
            My.Computer.FileSystem.RenameFile("C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.jwpub", "mwb_S_202207.zip")
        Catch ex As Exception
            MsgBox("No se pudo cambiar el nombre del archivo JWPUB" & vbCrLf & ex.Message)
        End Try

        Try
            Label1.Text = "Descomprimiendo archivo ZIP..."
            ZipFile.ExtractToDirectory("C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.zip", "C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\")
        Catch ex As Exception
            MsgBox("No se pudo descomprimir el archivo ZIP" & vbCrLf & ex.Message)
        End Try

        Try
            Label1.Text = "Cambiando el nombre a la carpeta CONTENTS a ZIP"
            My.Computer.FileSystem.RenameFile("C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\contents", "contents.zip")
        Catch ex As Exception
            MsgBox("No se pudo cambiar el nombre de la carpeta CONTENTS" & vbCrLf & ex.Message)
        End Try

        Try
            Label1.Text = "Descomprimiendo la carpeta CONTENTS.ZIP..."
            ZipFile.ExtractToDirectory("C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\contents.zip", "C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\")
        Catch ex As Exception
            MsgBox("No se pudo descomprimir la carpeta CONTENTS.ZIP" & vbCrLf & ex.Message)
        End Try

        Dim SQLiteConn As New SQLiteConnection
        Try
            SQLiteConn.ConnectionString = "Data Source=C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.db; Integrated Security=true"
            SQLiteConn.Open()
        Catch ex As Exception
            MsgBox("No se pudo conectar a la Base de Datos" & ex.Message)
        End Try

        Dim SQLitecnStr As String = "Data Source=C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.db; Integrated Security=true"
        Dim SQLitecmd As New SQLiteCommand
        Dim SQLiteReader As SQLiteDataReader
        Try
            SQLiteConn.ConnectionString = SQLitecnStr
            SQLiteConn.Open()

            SQLitecmd.Connection = SQLiteConn
            SQLitecmd.CommandText = "SELECT * from Multimedia LIMIT 1;"
            SQLiteReader = SQLitecmd.ExecuteReader()

            MsgBox(SQLiteReader("MimeType").ToString)
        Catch ex As Exception
            MsgBox("No se pudo conectar a la tabla Mutimedia" & ex.Message)
        End Try
    End Sub
End Class

This part is the one that doesn't work:

Dim SQLitecnStr As String = "Data Source=C:\GoAttendant\Attendant Zoom\AppData\Local\Packages\417474656E64616E74205A6F6F6D\mwb_S_202207.db; Integrated Security=true"
        Dim SQLitecmd As New SQLiteCommand
        Dim SQLiteReader As SQLiteDataReader
        Try
            SQLiteConn.ConnectionString = SQLitecnStr
            SQLiteConn.Open()

            SQLitecmd.Connection = SQLiteConn
            SQLitecmd.CommandText = "SELECT * from Multimedia LIMIT 1;"
            SQLiteReader = SQLitecmd.ExecuteReader()

            MsgBox(SQLiteReader("MimeType").ToString)
        Catch ex As Exception
            MsgBox("No se pudo conectar a la tabla Mutimedia" & ex.Message)
        End Try

Here I show you a bit of the Designer. I even have their repository here, but it's not fully uploaded yet, I'm missing some files, maybe by the time you read this they'll all be up.

Captura de pantalla (70)

At first I based my project on this, however it has not worked for me since the error function. I want to implement this project to my Attendant Zoom application, an application to share multimedia in video conference meetings, in the Kingdom Hall or even in Assembly Halls.

darioragusa commented 2 years ago

Hi, I took a look at the other issue, to extract video information from the db you can use a query like this: SELECT KeySymbol, Track, MepsLanguageIndex, IssueTagNumber FROM Multimedia WHERE DataType = 2; (maybe adding some other filter). What error do you get?