MacPython/Audio Hijack Pro

This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.

Print a formatted, plain text list of all scheduled timers with the dates and times for which they are scheduled. A description can be found here

 1 #!/usr/bin/env python
 2 
 3 from appscript import *
 4 import datetime
 5 
 6 # Get a list of all the sessions.
 7 allsessions = app('Audio Hijack Pro').sessions.get()
 8 
 9 # Make a list with the sessions that have scheduled timers.
 10 timersessions = []
 11 for s in allsessions:
 12  for t in s.timers.get():
 13  if t.scheduled():
 14  timersessions.append(s)
 15  break # go to next session after finding a scheduled timer
 16 
 17 # Get the length of the longest name of a timersession.
 18 longest = max(len(s.name()) for s in timersessions)
 19 
 20 # Make a 7-character string with the days that the timer runs.
 21 def timerdays(t):
 22  daylist = ['-'] * 7
 23  if t.runs_Sunday():
 24  daylist[0] = 'S'
 25  if t.runs_Monday():
 26  daylist[1] = 'M'
 27  if t.runs_Tuesday():
 28  daylist[2] = 'T'
 29  if t.runs_Wednesday():
 30  daylist[3] = 'W'
 31  if t.runs_Thursday():
 32  daylist[4] = 'T'
 33  if t.runs_Friday():
 34  daylist[5] = 'F'
 35  if t.runs_Saturday():
 36  daylist[6] = 'S'
 37  return ''.join(daylist)
 38 
 39 # Print the info for all the sessions with enabled timers.
 40 for s in timersessions:
 41  for t in s.timers.get():
 42  if t.scheduled():
 43  dur = t.duration()
 44  durstr = '(%d min)' % (dur/60)
 45  st = t.start_time()
 46  et = st + datetime.timedelta(seconds = dur)
 47  dow = timerdays(t)
 48  ststr = st.strftime("%l:%M %p")
 49  etstr = et.strftime("%l:%M %p")
 50  fmtstr = "%" + str(longest) + "s: %s from %s to %s%s"
 51  print fmtstr % (s.name(), dow, ststr, etstr, durstr.rjust(9))

2026年02月14日 16:09

AltStyle によって変換されたページ (->オリジナル) /