Skip to content

Instantly share code, notes, and snippets.

@DCubix
Last active February 3, 2024 18:33
Show Gist options
  • Save DCubix/7a00689aeded8123da109ccbfe907c3a to your computer and use it in GitHub Desktop.
Save DCubix/7a00689aeded8123da109ccbfe907c3a to your computer and use it in GitHub Desktop.
Script que permite que o Holyrics se comunique com o vMix, atualizando titles conforme a projeção.
'--
'-- Script para conexão dos dados do Holyrics ao vMix
'-- inclui dados de letra de música e bíblia
'-- autor: Diego Lopes
'-- data: 03/02/2024=
'--
'-- CONFIGURAÇÕES DO HOLYRICS
dim holyricsHost as String = "http://192.168.100.3:8088"
dim holyricsView as String = "stage-view"
dim holyricsUrl as String = holyricsHost & "/" & holyricsView & "/text.json"
'-- CONFIGURAÇÕES DO VMIX
dim vmixBibliaInputName as String = "vvpp_card_biblia.gtzip"
dim vmixLetraInputName as String = "letra.gtzip"
dim vmixBibliaLivroVersoFieldName as String = "livro"
dim vmixBibliaTextoFieldName as String = "texto"
dim vmixLetraFieldName as String = "LETRA"
'-- configurações do script
dim webClient as System.Net.WebClient = New System.Net.WebClient()
webClient.Encoding = New System.Text.UTF8Encoding(true)
dim vbLf as String = "\n"
dim vbCr as String = "\r"
dim vmixInBiblia = Input.Find(vmixBibliaInputName)
dim vmixInLetra = Input.Find(vmixLetraInputName)
dim previousText as String = ""
dim regexpType as System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("""type""\s*:\s*""([^""]+)""")
dim regexpText as System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("""text""\s*:\s*""([^""]+)""")
dim regexHeader as System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("""header""\s*:\s*""([^""]+)""")
dim regexHtml as System.Text.RegularExpressions.Regex = New System.Text.RegularExpressions.Regex("<.*?>")
'-- mainloop
do while true
dim json as String = ""
Try
json = webClient.DownloadString(holyricsUrl)
Catch ex as Exception
Console.WriteLine("Erro ao conectar ao Holyrics: " & ex.Message)
sleep(5000)
continue do
End Try
json = System.Text.RegularExpressions.Regex.Unescape(json)
'-- extrai campo "type" do json
dim type as String = regexpType.Match(json).Groups(1).Value
'-- extrai campo "text" do json
dim text as String = regexpText.Match(json).Groups(1).Value
'-- verifica se é letra ou bíblia usando o campo type
if type = "MUSIC" then
'-- remove tags html e quebras de linha
text = regexHtml.Replace(text, "").Replace(vbLf, " ").Replace(vbCr, " ")
'-- envia para o vMix
vmixInLetra.Text(vmixLetraFieldName & ".Text") = text
else if type = "BIBLE" then
dim header as String = regexHeader.Match(json).Groups(1).Value
header = regexHtml.Replace(header, "").Replace(vbLf, " ").Replace(vbCr, " ")
'-- extrai texto entre tags <ctt> e </ctt>
text = System.Text.RegularExpressions.Regex.Match(text, "<ctt>(.*?)</ctt>").Groups(1).Value
'-- remove tags html e quebras de linha
text = regexHtml.Replace(text, "").Replace(vbLf, " ").Replace(vbCr, " ")
'-- remove àspas incluindo as unicode
text = text.Replace("“", """").Replace("”", """")
'-- duplica as aspas
text = text.Replace("""", """""""")
'-- envia para o vMix
vmixInBiblia.Text(vmixBibliaLivroVersoFieldName & ".Text") = header
vmixInBiblia.Text(vmixBibliaTextoFieldName & ".Text") = text
end if
'-- aguarda
sleep(400)
loop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment