109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
# add data
row["listformat"] = "href" #self.parent.channel().listformat
if row.get(self.timefield):
row["title"] = row["title"] + " -- " + row[self.timefield]
row[self.timefield] = timespec
# store
self.save_timer(row)
self.parent.status("Timer saved.")
# store row in timer database
def save_timer(self, row):
self.streams.append(row)
self.bookmarks.save()
self.queue(row)
pass
# Add timer/recording events to scheduler (or later crontab)
def queue(self, row):
# chk
if not row.get(self.timefield) or not row.get("url"):
#log.DATA("NO TIME DATA", row)
return
# extract timing parameters
_ = row[self.timefield]
days = self.days(_)
time = self.time(_)
duration = self.duration(_)
# which action
if row[self.timefield].find("rec")>=0:
activity, action_method = "record", self.record
else:
activity, action_method = "play", self.play
# add
if days and time and activity:
task = self.sched.add_daytime_task(action_method, activity, days, None, time, kronos.method.threaded, [row], {})
log.QUEUE( activity, self.sched, (action_method, activity, days, None, time, kronos.method.threaded, [row], {}), task.get_schedule_time(True) )
else:
log.ERR_QUEUE( activity, self.sched, (action_method, activity, days, None, time, kronos.method.threaded, [row], {}) )
# converts Mon,Tue,... into numeric 1-7
def days(self, s):
|
|
|
|
<
|
<
>
|
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
|
# add data
row["listformat"] = "href" #self.parent.channel().listformat
if row.get(self.timefield):
row["title"] = row["title"] + " -- " + row[self.timefield]
row[self.timefield] = timespec
# store
if self.save_timer(row):
self.status("Timer saved.")
# store row in timer database
def save_timer(self, row):
self.streams.append(row)
self.bookmarks.save()
return self.queue(row)
# Add timer/recording events to scheduler (or later crontab)
def queue(self, row):
# chk
if not row.get(self.timefield) or not row.get("url"):
return log.DATA("NO TIME DATA", row)
# extract timing parameters
_ = row[self.timefield]
days = self.days(_)
time = self.time(_)
duration = self.duration(_)
# which action
if row[self.timefield].find("rec")>=0:
activity, action_method = "record", self.record
else:
activity, action_method = "play", self.play
# add
if days and time and activity:
task = self.sched.add_daytime_task(action_method, activity, days, None, time, kronos.method.threaded, [row], {})
log.QUEUE( activity, self.sched, (action_method, activity, days, None, time, kronos.method.threaded, [row], {}), task.get_schedule_time(True) )
return True
else:
log.ERR_QUEUE( activity, self.sched, (action_method, activity, days, None, time, kronos.method.threaded, [row], {}) )
# converts Mon,Tue,... into numeric 1-7
def days(self, s):
|