Rank: Advanced Member
Groups: Registered
Joined: 12/24/2021(UTC) Posts: 508 Location: athens Thanks: 123 times Was thanked: 71 time(s) in 67 post(s)
|
Originally Posted by: ArunLongjam Originally Posted by: doggy https://youtu.be/YPetIze1Os8 Thanks doggy, It's what I've been looking for a long time.. Can you share the code & files? It will help me most. Thanks. Hello doggy motivated me to try to do something that will do this thing. As i dont how to code in VB.NET language or any other language i thought that i can ask AI and improvise on how to do this procedure. The difficult thing here (at least for me) is that in vmix xml api it doesnt say the speed of the ticker so we can use it as reference. So i made (to be exactly i said AI to do for me) a python script. Here this is the code. If you want to try it, you have first to install python in your pc. Here https://forums.vmix.com/...e-way-for-vmix-scripting is some instructions on how to do it Code:
import requests
import time
import xml.etree.ElementTree as ET
def request_ticker_title():
return input("Enter please your ticker name: ")
def get_ticker_info(title):
response = requests.get("http://127.0.0.1:8088/api")
root = ET.fromstring(response.content)
for input_element in root.findall("inputs/input"):
input_title = input_element.get("title")
if input_title.lower() == title.lower():
text_element = input_element.find("text")
state = input_element.get("state")
return text_element.text, state == "Running"
return "", False
def send_data_source_next_row():
response = requests.get("http://127.0.0.1:8088/api/?Function=DataSourceNextRow&Value=Excel/CSV,Sheet1")
print("Updating data source:", response)
def send_data_source_select_row(row_number):
response = requests.get(f"http://127.0.0.1:8088/api/?Function=DataSourceSelectRow&Value=Excel/CSV,Sheet1,{row_number}")
print("Selecting Data source row:", response)
def calculate_wait_time(ticker_text, base_time, base_text_length, time_per_char):
char_count = len(ticker_text)
return base_time + (char_count - base_text_length) * time_per_char
def request_last_row_text():
return input("Enter the last text line of your ticker: ")
def main():
ticker_title = request_ticker_title()
last_row_text = request_last_row_text()
ticker_was_running = False
prev_ticker_text = ""
base_time = 9
base_text_length = len("BYE")
time_per_char = (11.5 - 9) / (len("HOW ARE YOU? LET ME SEE THE RESULT") - len("BYE"))
while True:
ticker_text, ticker_running = get_ticker_info(ticker_title)
print(f"Text of the ticker: {ticker_text}, State of the ticker: {ticker_running}")
if ticker_running:
if not ticker_was_running or ticker_text != prev_ticker_text:
wait_time = calculate_wait_time(ticker_text, base_time, base_text_length, time_per_char)
print(f"Wait for {wait_time} seconds")
time.sleep(wait_time)
send_data_source_next_row()
time.sleep(1)
if last_row_text and ticker_text == last_row_text:
send_data_source_select_row(0)
time.sleep(1)
ticker_was_running = ticker_running
prev_ticker_text = ticker_text
time.sleep(1)
if __name__ == "__main__":
main()
How this code work? When you make your .py file you have to do some modifications for your needs. At first you need in this line response = requests.get("http://127.0.0.1:8088/api/?Function=DataSourceNextRow&Value=Excel/CSV, Sheet1") and this line response = requests.get(f"http://127.0.0.1:8088/api/?Function=DataSourceSelectRow&Value=Excel/CSV, Sheet1,{row_number}") to change Sheet1 to the name of your excel/csv file and press save. Τhen in vmix rename your ticker in something you want. For example Ticker1 and run your .py script. It will ask for you to enter the name of your ticker. For example Ticker1 and press enter. Now script will ask you to enter the last datasource line of your ticker. This is optional and you can press enter and continue The reason I did it this way is because I couldn't find in the XML API of vMix when the last line of the datasource is, so that the script can go back to the first line and continue running. If we leave the field empty here and press enter, once it reaches the last line of the datasource, it will stay there and repeat the last line in the ticker. If we put the text we have on the last line in the field, then once it passes, the script will go back and run the ticker again from the first line of the datasource. I've done it for vMix production 1080 50i. It's not perfect, but I think it does the job.After all, AI can't replace a person who knows programming well. Now, depending on the length of the text you will be running, you can adjust the numbers in the function time_per_char = (11.5 - 9) / (len("HOW ARE YOU? LET ME SEE THE RESULT") - len("BYE")) or change the words and text I have put to compare. You can try it, do tests if you want. I know it's not the most perfect thing that could be done, but okay, since I like to search and learn (even if AI has to write the code for me, it's not always easy to explain to a machine what code you want it to write) it gave me the opportunity to try what will come out.
|