Qlab 4 - Save playback duration and count as text file (Scripts)

1,135 views
Skip to first unread message

Ben Bull

unread,
Feb 21, 2017, 9:29:50 AM2/21/17
to QLab
Hi all, 

I'm hoping to find someone who can help me with a Qlab script. I work in Outside Broadcast TV and have used "QCart" for a number of years as my primary playback software. Qcart is not retired and has been incorporated into Qlab 4. 
Creating accurate logs of music played is important so that we can ensure that music artists get paid accordingly.

I'm after a simple Apple Script which would log track/cue name, the start and end time of the playback, playback duration, and if possible playback count. Ideally the script would save a text file for each day that I could then import into Excel to process. 

Hopefully someone who has the expertise is prepared to help, it would be greatly appreciated

Cheers, 
Ben 



Chris Ashworth

unread,
Feb 21, 2017, 10:11:46 AM2/21/17
to Ben Bull, ql...@googlegroups.com
Hi Ben,

We have on our list to add better logging for this purpose, but delayed working on it because we weren’t sure we understood the requirements.

So this is a great opportunity to learn them so we can plan how to build it out.

Could you tell me more about the following?

- Are you looking for a start/end/duration each time any given cue is played? 
- Is there a minimum time that you care about? (e.g. "only if it plays longer than 10 seconds”)
- How do you define playback count? 
- In your view is it okay to log each time a cue plays and let a different system sum the counts?
- My assumption is that we’d track these logs per workspace; do you see any problems with that approach?
- How far back in time do you need/want the logs to extend? 

best,
Chris

Ben Bull

unread,
Feb 21, 2017, 3:48:11 PM2/21/17
to Chris Ashworth, ql...@googlegroups.com
Hi Chris, 

Thanks for your response.

In its simplest form if would be great if it could do the following:
  • Log how long each cue was played/was triggered for. 
  • Log clip/cue name
The above is basically what your current log is doing, the issue being that the line of text generated in the log isn't in a spreadsheet friendly format, like csv. Due to the time of day being logged in your current log function, I am able to vaguely determine play duration already (eg, between start of cue1 and start of cue2). I just have a very tough time when trying to split up date, time, track name out of a single line of text. 

In a more complex form:
  • Log time of day (TOD) when the clip/cue was triggered, Log TOD when the clip/cue finished playing.
  • Log how long each cue was played/was triggered for. (This could be a simple subtraction between the two values above)
  • Log clip/cue/track name
  • Minimum play duration is not essential as my excel sheet can just ignore durations under 10 seconds. (This is usually when we are auditioning a cue)
  • Tracking this information per each workspace seems completely fine. 
  • Logs could go report everything up until someone clears the log with the "Clear Log" button. 
  • When I say play count, I simply mean the number of times the cue has been triggered since the log was cleared. Again, this is not essential as I can work this out in my excel sheet based on the number of log entries for a certain cue name. 
I hope this clears it up a little. 
Thanks for your help.

Ben

Rich Walsh

unread,
Feb 21, 2017, 4:00:53 PM2/21/17
to ql...@googlegroups.com
I was wondering it you’d tried log level 2 or “Record cue sequence…” – both of which suffer from not appearing to acknowledge stopping cues (so to stop a cart you’d need a stop cue, not to click on its stop button).

I roughed up this, which you would use by giving it a hotkey and then using that hotkey to start/stop the selected cue in a cart:

try
tell application id "com.figure53.QLab.4" to tell front workspace
set selectedCue to last item of (selected as list)
set {theNumber, theName, theTarget, theStatus} to {q number, q list name, file target, running} of selectedCue
if theStatus is true then
set theAction to "Stop "
panic selectedCue
else
set theAction to "Start"
start selectedCue
end if
if theTarget is missing value then
set theMessage to theAction & " | " & theNumber & " | " & theName
else
set theMessage to theAction & " | " & theNumber & " | " & theName & " | " & theTarget
end if
end tell
do shell script "echo `date '+%d-%m-%y %T'`\" | " & theMessage & "\" >> $HOME/Library/Logs/QLab.log"
end try

Consider it an alpha version… Logging is to a file in the Console, and is only to the nearest second.

I haven’t taken your response below into account yet. Do you want me to try to take that any further?

Rich

-- 
Contact support anytime: sup...@figure53.com
Follow Figure 53 on Twitter: http://twitter.com/Figure53
--- 
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/qlab/CAFicLi%3DF3wOfggLEh7meOzYYDxtXjU%3DMLqHBbz%3DYWHp1d_YhZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Rich Walsh

unread,
Feb 21, 2017, 7:29:55 PM2/21/17
to ql...@googlegroups.com
I had a bit more of a play: there’s some tricky concepts here. I’ve made something that hijacks the space bar to go/panic selected cue and logs elapsed time if panicking. I can’t hijack ESC, but § will do a logged panic. There’s a third mechanism in there for logging on demand in a follow-on: use a Start Cue to start “log” and its name will be logged.

I can’t think of an elegant way to deal with follow-ons or groups, but perhaps with carts this will do what you need? If you’re using something other than the mouse to choose carts to fire then it’d need some bespoke thought though…

I think anything much more fancy will probably need to be built in – although have you come across http://artificers.co.uk? I’m unclear if you have to add a Network Cue every time you want to log to Stamp – or if it’s polling in the way that QLab Remote must be?

Output is currently to the Desktop, a new file each day/workspace; tab delimited (csv much harder).

Rich
GO logger.zip
Message has been deleted

micpool

unread,
Feb 22, 2017, 1:59:34 AM2/22/17
to QLab
I dont have time to script this at the moment, but an alternative approach would be to have a script running in the background, perhaps called by a network cue with a long duration, that looks at the active cues and logs the times that audio cues appear and dissapear from the active cues list to a file.

The main problem with this approach is that ESC will halt the script, so it is not neccesarily robust enough to use for an audited application for collection agencies.

This is another case where the ability to run scripts outside of cues, on actions, or on idle, or some other mechanism to solve ESC killing long duration network cues could be useful.

Mic

micpool

unread,
Feb 22, 2017, 6:11:39 AM2/22/17
to QLab
I think Stamp just Logs QLab OSC messages sent explicitly and individually  from network cues, which isn't really worth £99 pounds if that's all you want to do.
This script cue logger will something similar for nothing but it still requires you to create a special cue each time you want to log something.


Mic

Rich Walsh

unread,
Feb 22, 2017, 10:42:38 AM2/22/17
to ql...@googlegroups.com
Interesting: that isn’t a lot of functionality for £99, is it?

Was it clear that the workspace I posted can do all of the following?

  1. Log key cue info for every (keyboard-triggered) GO, tab-delimited for use in Excel
  2. Log key cue info including elapsed time for every cue panicked by selecting it and pressing the GO trigger again
  3. Log custom messages using the name of Start Cues which trigger a logging script

Unusually I hadn’t checked the QLab Cook Book for a solution first, so I’ve invented the wheel too – although perhaps mine has alloy rims? ;-)

Rich

Tony Godman

unread,
Feb 22, 2017, 1:41:06 PM2/22/17
to QLab
Hi
I wonder if for some broadcasters some interlock with transmission might be an idea so that logging of items used ( for fees) only takes place on shows that actually went out on TX,  or were web published for example, and if we were in rehearsal or edit mode then no logs would be needed? Just a thought.



Ben Bull

unread,
Mar 21, 2018, 3:26:49 AM3/21/18
to QLab
Hi All, 

I'm hoping someone will kindly be able to point me in the right direction with this again. Since I started the discussion the lovely Qlab folks seem to have added some terms into the Qlab Applescript dictionary that might help me achieve what i'm trying to do. 

I'm trying to get the q name and elapsed duration of the active cue into a text/csv/excel file or format to be turned into a music cue sheet for TV music reports. 

These terms are:
action elapsed

start time (real) : Time in the file where playback begins.

end time (real) : Time in the file where playback ends.


I trigger these cues via Hot Key in a Cue Cart.

I have tried reverse engineering some other Apple Scripts without much luck. 


Would anyone be able to help draw up even the basics like getting qname and elapsed time of the selected cue so that I can adapt it further into a text file log? 


Kind regards, 

Ben



Rich Walsh

unread,
Mar 21, 2018, 5:58:08 AM3/21/18
to ql...@googlegroups.com
Did you not get anywhere with the work we did last year? Have you looked at Mic’s solution: https://qlabcookbook.com/1994/01/20/captain-slog/?

I think this has the framework to do what you describe, but I’m not 100% sure what you’re trying to do which the script I offered last time couldn’t:

set userLogFilenameSuffix to " | Logged Events" -- Text to append to log file names

set userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;
(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)

-- Grab the active cues (excluding this cue – well, all Script Cues – and cue lists / carts)

tell application id "com.figure53.QLab.4" to tell front workspace


set workspaceName to q number


set activeCueNames to q list name of cues whose running is true ¬
and q type is not "Script" and q type is not "Cue List" and q type is not "Cart"
set activeCueActionElapsed to action elapsed of cues whose running is true ¬
and q type is not "Script" and q type is not "Cue List" and q type is not "Cart" -- These will be raw times in seconds: no formatting


end tell

-- Grab the time

set logTime to do shell script "date " & quoted form of userFileTimestampFormat

-- Get path to log file

set theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"

-- Cycle through the cues to make a message for the log

set theMessageList to {}
set firstColumn to logTime

repeat with i from 1 to (count activeCueNames)
set end of theMessageList to firstColumn & tab & item i of activeCueNames & tab & item i of activeCueActionElapsed
if i = 1 then set firstColumn to tab -- Only log the time in the first row for each message
end repeat

set currentTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to linefeed
set theMessage to theMessageList as text
set AppleScript's text item delimiters to currentTIDs

-- Write to the log

do shell script "echo \"" & theMessage & "\" >> " & quoted form of theFilePath

Rich

--
Contact support anytime: sup...@figure53.com
Follow Figure 53 on Twitter: https://twitter.com/Figure53
User Group Code of Conduct: https://figure53.com/help/code-of-conduct/

---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.

micpool

unread,
Mar 21, 2018, 12:44:31 PM3/21/18
to QLab
Assuming what Ben was wanting was a logging system that would, as far as possible, log what music was playing on a cart list without having to program a log cue for each cart position , and assuming  that there was only 1 music cue running at a time. i.e all carts are set to  panic other cues in cart when started.

This could be achieved by a looping script cue which detects when the last active cue, (that is not the script), changes, and write the new file to the log together with the time since the last change

Of course, the problem with a logging cue looping in the background is it will stop when ESC is pressed. Even if it was in another workspace all workspaces will stop on ESC.

I thought a way round this might be to write a little application in Python to do the logging, but then I remembered I had only got to p33 of 'control your turtle with Python for ages 9-11'

So.... I used QLab 3 to run the logging loop in. It auto-starts and as long as it never becomes the active application then it will ignore ESCs sent to the cart workspace in QLab 4

I haven't got time to finish it, but as a proof of concept it's there.

QLab 4 Cart (Replace broken cues by dragging  your own audio in) and a QLab 3 workspace attached.

Mic
Cart.qlab4
logger.cues

Ben Bull

unread,
Mar 21, 2018, 11:11:53 PM3/21/18
to QLab
Hi Mic and Rich, 

Thanks for your reply and help so far. 
I have actually taken ideas from both of you and now have it working pretty much how it needs to, which is great. 

Mic, you are right. All of my clips are triggered out of carts and (other than a transition fade) there is never more than one clip playing at a time. 

I am now using Rich's script via Keyboard Maestro (Macro software) which is just running the script every second when Qlab is open and is the front window. 

This is spitting out:

22/03/18 15:52:02 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 0.22854031
22/03/18 15:52:03 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 1.231632312
22/03/18 15:52:04 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 2.232098834
22/03/18 15:52:05 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 3.224376371
22/03/18 15:52:06 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 4.212067697
22/03/18 15:52:07 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 5.221919848
22/03/18 15:52:08 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 6.223441033
22/03/18 15:52:09 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 7.212064678
22/03/18 15:52:10 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 8.222934765
22/03/18 15:52:11 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 9.224069309
22/03/18 15:52:12 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 10.210508389
22/03/18 15:52:13 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 11.211964303
22/03/18 15:52:14 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 12.224451094
22/03/18 15:52:15 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 13.223480948
22/03/18 15:52:16 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 14.243827376
22/03/18 15:52:17 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 15.225853939
22/03/18 15:52:18 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 16.227190745
22/03/18 15:52:19 UPM_BBCPM065_14_Anthem_For_The_People_Main_Track_Joiner_Knowler_983387.mp3 17.321831958
UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 0.447140771
22/03/18 15:52:20 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 1.333444842
22/03/18 15:52:21 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 2.364448086
22/03/18 15:52:22 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 3.384867324
22/03/18 15:52:23 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 4.326283594
22/03/18 15:52:24 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 5.34769091
22/03/18 15:52:25 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 6.341263213
22/03/18 15:52:26 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 7.331994924
22/03/18 15:52:27 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 8.339758694
22/03/18 15:52:28 UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 9.343200102
22/03/18 15:52:29 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 0.192356288
UPM_KOS411_16_Level_Up_Main_Track_Huguenin_763554.mp3 10.394176863
22/03/18 15:52:30 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 1.191064693
22/03/18 15:52:31 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 2.147728342
22/03/18 15:52:32 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 3.147979434
22/03/18 15:52:33 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 4.138569185
22/03/18 15:52:34 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 5.144909155
22/03/18 15:52:35 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 6.136732707
22/03/18 15:52:36 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 7.147516985
22/03/18 15:52:37 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 8.151644997
22/03/18 15:52:38 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 9.139085754
22/03/18 15:52:39 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 10.149103584
22/03/18 15:52:40 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 11.149012127
22/03/18 15:52:41 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 12.146748845
22/03/18 15:52:42 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 13.15220024
22/03/18 15:52:43 UPM_ATMOS320_6_Ball_Skills_Main_Track_Pollard_Salkeld_794761.mp3 14.226357847
UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 0.101723699
22/03/18 15:52:44 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 1.099954323
22/03/18 15:52:45 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 2.017202329
22/03/18 15:52:46 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 3.012473163
22/03/18 15:52:47 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 4.019480262
22/03/18 15:52:48 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 5.017035732
22/03/18 15:52:49 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 6.008030607
22/03/18 15:52:50 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 7.017133622
22/03/18 15:52:51 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 8.018168186
22/03/18 15:52:52 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 9.008015145
22/03/18 15:52:53 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 10.016654194
22/03/18 15:52:54 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 11.027138274
22/03/18 15:52:55 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 12.065778067
UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 0.19536798
22/03/18 15:52:56 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 1.182085767
22/03/18 15:52:57 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 2.141848814
22/03/18 15:52:58 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 3.151787663
22/03/18 15:52:59 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 4.143939907
22/03/18 15:53:00 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 5.146375754
22/03/18 15:53:01 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 6.151369005
22/03/18 15:53:02 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 7.154451912
22/03/18 15:53:03 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 8.139618375
22/03/18 15:53:04 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 9.151159147
22/03/18 15:53:05 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 10.147390636
22/03/18 15:53:06 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 11.152620857
22/03/18 15:53:07 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 12.141139781
22/03/18 15:53:08 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 13.147126299
22/03/18 15:53:09 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 14.134004722
22/03/18 15:53:10 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 15.13473968

....
... // Removed to shorten this example.
..

22/03/18 15:53:55 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 60.153444901
22/03/18 15:53:56 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 61.154511989
22/03/18 15:53:57 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 62.150050282
22/03/18 15:53:58 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 63.150991342
22/03/18 15:53:59 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 64.135227411
22/03/18 15:54:00 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 65.141188215
22/03/18 15:54:01 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 66.139269137
22/03/18 15:54:02 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 67.167604845
22/03/18 15:54:03 UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 68.158960038
22/03/18 15:54:04 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 0.347669631
UPM_ATMOS311_12_Beautiful_Awesome_Main_Track_Banbury_Husband_763665.mp3 69.213942687
22/03/18 15:54:05 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 1.278497908
22/03/18 15:54:06 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 2.279460673
22/03/18 15:54:07 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 3.281443649
22/03/18 15:54:08 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 4.28118591
22/03/18 15:54:09 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 5.273248754
22/03/18 15:54:10 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 6.2775241
22/03/18 15:54:11 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 7.279832106
22/03/18 15:54:12 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 8.282985144
22/03/18 15:54:13 UPM_KOS600_7_Anthemic_Strings_Main_Track_Kalfayan_985333.mp3 9.389945538

etc..

As you can see its obviously returning a result every second which is still useful for me. For some of the entries, it is giving me a total elapsed duration during that particular play which is awesome! I have highlighted these in green. Ideally this total elapsed duration is all that I require. Rich, is there a way to ensure that the script returns the total elapsed duration after each play like the ones labelled in green? I'm not sure why it is only doing it some of the time. I like how these particular results stand out in a different column like you have done already as it makes it easier for me when sorting through the data to be formatted later on.

FYI, the lines labelled in orange are out of order; i'm assuming this is due Qlab stopping and fading between cues. Ie, Clip 1 is still fading out when Clip 2 starts playing. This isn't a problem for what i'm doing as this data will be filtered out later on. 

It's really just the clip name and total elapsed duration (during that particular play) that i am after. Can you think of a better way of achieving this every time? 

Thank you both so much for your help so far, you have got me to a spot where I can finally understand the basics of getting this data and turning it into something useful. 


Cheers, 
Ben

micpool

unread,
Mar 22, 2018, 5:38:15 AM3/22/18
to QLab
On Thursday, March 22, 2018 at 3:11:53 AM UTC, Ben Bull wrote:
It's really just the clip name and total elapsed duration (during that particular play) that i am after. Can you think of a better way of achieving this every time? 



I assume then that something prevented you trying out my solution ? This would have produced the following output.

Which, barring some minor tidying up, seems to be exactly what you are requesting.


Until you add some error checking, or some brute force try/end try the script will decompile if you open QLab 3 before QLab 4 as there is no workspace present. I've attached a new version that has try/end try blocks included.

If you didn't want to use QLab 3 as the logger you can adapt the script, so that after running the first part which gets the info from QLab 4,  as long as your logging app can store 3 variables you can use whatever you want.

It just needs to store the currently playing cue (to check if has changed), and the current and previous times the playing cue changed.

tell application id "com.figure53.QLab.4"

try

tell front workspace

set workspaceName to q number

set theactivecues to (count of (active cues as list))

if theactivecues > 0 then

set thelastcue to uniqueID of last item of (active cues as list)

set thecuename to q list name of cue id thelastcue

else

set thelastcue to ""

set thecuename to "NO CUES PLAYING "

end if

end tell

end try

end tell


tell application id "com.figure53.QLab.3"

try

tell front workspace

if notes of cue "LOG" = thelastcue then

return

else

set notes of cue "LOG" to thelastcue

--log routine here

if notes of cue "PREV" = "" then set notes of cue "PREV" to "0"

set notes of cue "THIS" to (do shell script "date +%s")

set theduration to ((notes of cue "THIS") as integer) - ((notes of cue "PREV") as integer)

set notes of cue "PREV" to notes of cue "THIS"

set userLogFilenameSuffix to " | Logged Events" -- Text to append to log file names

set userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;

(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)

set logTime to do shell script "date " & quoted form of userFileTimestampFormat

set theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"

set theMessageList to {}

set firstColumn to logTime

set theduration to tab & tab & tab & tab & tab & theduration

do shell script "echo \"" & theduration & "\" >> " & quoted form of theFilePath

set end of theMessageList to firstColumn & tab & thecuename

set currentTIDs to AppleScript's text item delimiters

set AppleScript's text item delimiters to linefeed

set themessage to theMessageList as text

set AppleScript's text item delimiters to currentTIDs

-- Write to the log

do shell script "echo \"" & themessage & "\" >> " & quoted form of theFilePath

end if

end tell

end try

end tell


Mic
logger.cues

micpool

unread,
Mar 22, 2018, 6:11:31 AM3/22/18
to QLab
On Thursday, March 22, 2018 at 9:38:15 AM UTC, micpool wrote:


If you didn't want to use QLab 3 as the logger you can adapt the script, so that after running the first part which gets the info from QLab 4,  as long as your logging app can store 3 variables you can use whatever you want.



In fact, if you protect against the logger stopping because ESC has been pressed, e.g a cover over the  ESC Key, then you can run the logger as a cue list in the same QLab 4 workspace as the carts, as in the attached.

Mic
CartLogger using QLab4 ONLY.qlab4

Rich Walsh

unread,
Mar 22, 2018, 6:25:57 AM3/22/18
to ql...@googlegroups.com
I’m not going to get into why you didn’t get what you expected out of the script as this wasn’t what I thought you were trying to do with it!

I took Mic’s idea and some of what we looked at last year and made an app that can run alongside QLab and log Audio Cues as they stop. I think Mic’s been playing this morning too.

(* STOP logger

Run this app alongside QLab to write a log file to the Desktop of how long Audio Cues had played for when they stop (rounded down to the nearest second)

**** TO QUIT: close all workspaces (the app won't run if there aren't any)

v0.9: 22/03/18 Rich Walsh (inspired by Mic Pool)

-- ###FIXME### This has not been tested AT ALL beyond proving that it works in principal; there is no real error protection
-- ###FIXME### Notifications don't work well when multiple cues stop at the same time
-- ###FIXME### Action elapsed is affected by scrubbing, so is not a true reflection in general of how long a cue _played_ for
-- ###FIXME### Build in detection that QLab is running to avoid trying to launch it
-- ###FIXME### Notify why the app is quitting!

<<< Last run with QLab 4.2, MacOS 10.12.6 >>> *)

-- User-defined variables

set userLogFilenameSuffix to " | Logged Stops" -- Text to append to log file names

set userFileTimestampFormat to "+%d/%m/%y %H:%M:%S" -- Set the format for timestamps;
(* the structure of this string follows the conversion specifiers of strftime: run "man strftime" in Terminal to see more *)

set userNotificationsOn to true -- Set this to false if you don't want a notification

set userPollingInterval to 1 -- Set how many seconds between iterations (accuracy will be roughly ±userPollingInterval)

-- Declarations

property dialogTitle : "STOP logger"

-- Get setup details

try
tell application id "com.figure53.QLab.4" to tell front workspace to set workspaceName to q number
on error
return -- Quit if no workspace open
end try

set theFilePath to "" & (POSIX path of (path to desktop)) & "QLab | " & workspaceName & userLogFilenameSuffix & ".txt"

set capturedAudioCueIDs to {}
set capturedAudioCueElapses to {}

-- Run the loop

repeat


-- Get the latest news


try
tell application id "com.figure53.QLab.4" to tell front workspace
set latestAudioCueIDs to uniqueID of cues whose running is true and q type is "Audio"
set latestAudioCueElapses to action elapsed of cues whose running is true and q type is "Audio"
end tell
on error
return -- Quit if no workspace open
end try


-- Compare against the last capture and log accordingly


if latestAudioCueIDscapturedAudioCueIDs then
set logTime to do shell script "date " & quoted form of userFileTimestampFormat
repeat with i from 1 to count capturedAudioCueIDs
if item i of capturedAudioCueIDs is not in latestAudioCueIDs then
set elapsedTime to makeMSS(item i of capturedAudioCueElapses)
tell application id "com.figure53.QLab.4" to tell front workspace
set stoppedCue to q list name of cue id (item i of capturedAudioCueIDs)
end tell
set theMessage to logTime & tab & stoppedCue & tab & elapsedTime
do shell script "echo \"" & theMessage & "\" >> " & quoted form of theFilePath
if userNotificationsOn then display notification stoppedCue & " stopped at " & elapsedTime with title dialogTitle subtitle "Event logged"
end if
end repeat
end if


-- Update the cache


set capturedAudioCueIDs to latestAudioCueIDs
set capturedAudioCueElapses to latestAudioCueElapses


-- Wait…


delay userPollingInterval


end repeat

-- Subroutines

(* === TIME === *)

on makeMSS(howLong) -- [Shared subroutine]
set howManyMinutes to howLong div 60
set howManySeconds to howLong mod 60 div 1
return (howManyMinutes as text) & ":" & my padNumber(howManySeconds, 2)
end makeMSS

(* === TEXT WRANGLING === *)

on padNumber(theNumber, minimumDigits) -- [Shared subroutine]
set paddedNumber to theNumber as text
repeat while (count paddedNumber) < minimumDigits
set paddedNumber to "0" & paddedNumber
end repeat
return paddedNumber
end padNumber

(* END: STOP logger *)

Rich

On 22 Mar 2018, at 03:11, Ben Bull <benb...@gmail.com> wrote:

Hi Mic and Rich, 

Thanks for your reply and help so far. 
I have actually taken ideas from both of you and now have it working pretty much how it needs to, which is great. 

Mic, you are right. All of my clips are triggered out of carts and (other than a transition fade) there is never more than one clip playing at a time. 

I am now using Rich's script via Keyboard Maestro (Macro software) which is just running the script every second when Qlab is open and is the front window. 

This is spitting out:

<snip>
STOP logger.app.zip

Ben Bull

unread,
Mar 26, 2018, 3:45:01 PM3/26/18
to QLab
Thank you both very much for your help and effort, This is exactly what I wanted. I used this on air yesterday with a macro setup that imports the data, formats it and exports a finalised PDF Music Cue Sheet - Something i have wanted to be able to do for many years. 

Mic, I did use/try your setup after getting Qlab3 back, and it worked great. My colleagues and I had used Qcart up until it was discontinued last year. Our purchase of Qcart gives us a discount on the Audio version of Qlab but does not cover the whole fee. While I am using a Pro audio licence for Qlab; first prize was an apple script that ran independent of Qlab so that my colleagues could migrate to from Qcart to Qlab and use the logging function on the basic licence without forking out the full fee just yet.

I am using Rich's script with the help of your code and it is working perfectly.

Thanks very much, 
If you're ever in NZ and want to check out a Live Broadcast Truck let me know so I can shout you both a beer. 

Cheers, 
Ben

Ben Bull

unread,
Aug 4, 2018, 9:22:14 PM8/4/18
to QLab
Hi Mic and Rich, 

I am messing around with trying to add accurate file metadata to this log; such as Artist/Composer, Publisher etc. So far the only way I can pull any info about the file that is/has played is to get Qlab to provide the target location for the most recently played file, store that and then have finder return specific info about the file's, just how you typically would when right clicking on a file and going "get info".

Unfortunately I cant seem to get applescript/finder to provide me with the audio file related info such as Artist/Composer. I am only able to retrieve generic file info such as modified date, size etc.. 

Have either of you got any bright ideas on how to retrieve audio metadata and add it to the text log? 

Cheers, 
Ben

Ben Bull

unread,
Aug 4, 2018, 10:57:24 PM8/4/18
to QLab
I may have actually found the solution myself. 

I have found a script online and been able to modify it to display metadata using mdls - kMDItem etc. This now gives me much more info to use in my music return/cue sheet.
Attached is this script as well as the music cue sheet template. 

Would either of you be able to help me in merging these two scripts (the attached script and the one that you wrote a few months ago) together so that what is outputted in the show logger.txt file ends up being tab  delimitated and formatted ready to be copied into the cue sheet xls template along with the elapsed durations as reported in the original script?

Kind regards, 
Ben
Qlab GG - Ben B.zip

Rich Walsh

unread,
Aug 17, 2018, 11:12:14 AM8/17/18
to ql...@googlegroups.com
Sorry, I’ve been away.

We’ve played with mdls before: https://groups.google.com/d/msg/qlab/WsIeThk_bBQ/3d4fnDBjAgAJ. I’ve added a couple of lines to my app to grab the additional metadata, but it’s up to you to deal with how you want to format that – and indeed to test it… I'm not 100% sure which version of Mic & my offerings you're using though.

I think I’ve made the app not remove "=" from the actual metadata and not fall over if the cue name or metadata contain ' " ( ) { } etc – but I may have missed something.

Rich

--
Contact support anytime: sup...@figure53.com
Follow Figure 53 on Twitter: https://twitter.com/Figure53
User Group Code of Conduct: https://figure53.com/help/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
<Qlab GG - Ben B.zip>
STOP logger 0.9.5.zip
Reply all
Reply to author
Forward
0 new messages