-
Notifications
You must be signed in to change notification settings - Fork 174
/
FavoriteAPI.java
1405 lines (1403 loc) · 78.4 KB
/
FavoriteAPI.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2015 The SageTV Authors. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package sage.api;
import sage.*;
/**
* Favorites are objects which are used for repeated recording in SageTV
*/
public class FavoriteAPI {
private FavoriteAPI() {}
public static void init(Catbert.ReflectionFunctionTable rft)
{
rft.put(new PredefinedJEPFunction("Favorite", "IsFirstRunsAndReRuns", 1, new String[] { "Favorite" })
{
/**
* Returns true if this Favorite is configured to record both first runs and reruns.
* @param Favorite the Favorite object
* @return true if this Favorite is configured to record both first runs AND reruns, false otherwise
*
* @declaration public boolean IsFirstRunsAndReRuns(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return Boolean.valueOf(a != null && a.firstRunsAndReruns());
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsFirstRunsOnly", 1, new String[] { "Favorite" })
{
/**
* Returns true if this Favorite is configured to record first runs but not reruns.
* @param Favorite the Favorite object
* @return true if this Favorite is configured to record first runs only, false otherwise
*
* @declaration public boolean IsFirstRunsOnly(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(((Agent) stack.pop()).isFirstRunsOnly());
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsReRunsOnly", 1, new String[] { "Favorite" })
{
/**
* Returns true if this Favorite is configured to record reruns but not first runs.
* @param Favorite the Favorite object
* @return true if this Favorite is configured to record reruns only, false otherwise
*
* @declaration public boolean IsReRunsOnly(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(((Agent) stack.pop()).isReRunsOnly());
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsFirstRuns", 1, new String[] { "Favorite" })
{
/**
* Returns true if this Favorite is configured to record first runs (it may or may not record reruns)
* @param Favorite the Favorite object
* @return true if this Favorite is configured to record first runs, false otherwise
*
* @declaration public boolean IsFirstRuns(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(!((Agent) stack.pop()).isReRunsOnly());
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsReRuns", 1, new String[] { "Favorite" })
{
/**
* Returns true if this Favorite is configured to record reruns (it may or may not record first runs)
* @param Favorite the Favorite object
* @return true if this Favorite is configured to record reruns, false otherwise
*
* @declaration public boolean IsReRuns(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(!((Agent) stack.pop()).isFirstRunsOnly());
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsAutoDelete", 1, new String[] { "Favorite" })
{
/**
* Returns true if SageTV is allowed to automatically delete recordings of this
* Favorite when it needs more disk space. If this is false, then SageTV will never automatically
* delete files recorded for this Favorite; the user will have to delete the files themself.
* @param Favorite the Favorite object
* @return true if this Favorite is configured for auto delete, false otherwise
*
* @declaration public boolean IsAutoDelete(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(!((Agent) stack.pop()).testAgentFlag(Agent.DONT_AUTODELETE_FLAG));
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsDeleteAfterAutomaticConversion", 1, new String[] { "Favorite" })
{
/**
* If an automatic conversion quality is set for this Favorite; then this will return true if
* the original file will be deleted after that conversion is performed
* @param Favorite the Favorite object
* @return true if this Favorite is configured to delete the original file after automatic conversion
* @since 7.0
*
* @declaration public boolean IsDeleteAfterAutomaticConversion(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Boolean.valueOf(((Agent) stack.pop()).testAgentFlag(Agent.DELETE_AFTER_CONVERT_FLAG));
}});
rft.put(new PredefinedJEPFunction("Favorite", "IsFavoriteEnabled", 1, new String[] { "Favorite" })
{
/**
* Returns true if SageTV considers this favorite when performing scheduling.
* @param Favorite the Favorite object
* @return true if this Favorite is enabled, false otherwise
* @since 9.0
*
* @declaration public boolean IsFavoriteEnabled(Favorite Favorite);
*/
@Override
public Object runSafely(Catbert.FastStack stack) throws Exception{
//Note here that the value of the test is negated
return Boolean.valueOf(!((Agent) stack.pop()).testAgentFlag(Agent.DISABLED_FLAG));
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetKeepAtMost", 1, new String[] { "Favorite" })
{
/**
* Returns the maximum number of recordings that match this Favorite that should be kept on disk. If AutoDelete is
* set to true then SageTV will continue to record new airings of this Favorite as they air, and delete the oldest
* recording on disk if it hits the keep at most limit. If AutoDelete is false then SageTV will stop recording this Favorite
* once it has this many recordings on disk
* @param Favorite the Favorite object
* @return the maximum number of recordings SageTV should keep on disk of this Favorite, 0 if it is unlimited
*
* @declaration public int GetKeepAtMost(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return new Integer(((Agent) stack.pop()).getAgentFlag(Agent.KEEP_AT_MOST_MASK));
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteDescription", 1, new String[] { "Favorite" })
{
/**
* Returns a String that describes this Favorite.
* @param Favorite the Favorite object
* @return a descriptive string for this Favorite
*
* @declaration public String GetFavoriteDescription(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return (a == null) ? "" : a.getCause();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoritePresentationName", 1, new String[] { "Favorite" })
{
/**
* Returns a String that describes this Favorite in a 'clean' way. Should be used in conjunction with
* GetFavoritePresentationPrefix to create a complete string for presenting a Favorite named uniquely.
* @param Favorite the Favorite object
* @return a descriptive string for this Favorite
* @since 8.0
*
* @declaration public String GetFavoritePresentationName(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return (a == null) ? "" : a.getCause(true);
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoritePresentationPrefix", 1, new String[] { "Favorite" })
{
/**
* Returns a String that describes this type of Favorite this is, such as Show, Keyword, Person, etc.
* @param Favorite the Favorite object
* @return a descriptive string for the type of Favorite
* @since 8.0
*
* @declaration public String GetFavoritePresentationPrefix(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return (a == null) ? "" : a.getTypeName();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteTitle", 1, new String[] { "Favorite" })
{
/**
* Returns the title that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the title that an Airing must match to be included in this Favorite, returns the empty string if the title isn't a field that needs to match
*
* @declaration public String GetFavoriteTitle(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return (a == null) ? "" : a.getTitle();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteCategory", 1, new String[] { "Favorite" })
{
/**
* Returns the category that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the category that an Airing must match to be included in this Favorite, returns the empty string if category isn't a field that needs to match
*
* @declaration public String GetFavoriteCategory(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getCategory();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteSubCategory", 1, new String[] { "Favorite" })
{
/**
* Returns the subcategory that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the subcategory that an Airing must match to be included in this Favorite, returns the empty string if subcategory isn't a field that needs to match
*
* @declaration public String GetFavoriteSubCategory(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getSubCategory();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoritePerson", 1, new String[] { "Favorite" })
{
/**
* Returns the person that an Airing must have to be included in this Favorite. The person may also be restricted by their role in the content.
* @param Favorite the Favorite object
* @return the person that an Airing must have to be included in this Favorite, returns the empty string if person isn't a field that needs to match
*
* @declaration public String GetFavoritePerson(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Person rv = ((Agent) stack.pop()).getPersonObj();
return (rv != null) ? rv.toString() : "";
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteRated", 1, new String[] { "Favorite" })
{
/**
* Returns the rating that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the rating that an Airing must match to be included in this Favorite, returns the empty string if rating isn't a field that needs to match
*
* @declaration public String GetFavoriteRated(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getRated();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoritePersonRole", 1, new String[] { "Favorite" })
{
/**
* Returns the role that an Airing must have the Favorite Person in to be included in this Favorite. This only applies if a person is set for this Favorite.
* @param Favorite the Favorite object
* @return the role that the favorite person for an Airing must have to be included in this Favorite, returns the empty string if role doesn't matter
*
* @declaration public String GetFavoritePersonRole(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return Show.getRoleString(((Agent) stack.pop()).getRole());
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteYear", 1, new String[] { "Favorite" })
{
/**
* Returns the year that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the year that an Airing must match to be included in this Favorite, returns the empty string if year isn't a field that needs to match
*
* @declaration public String GetFavoriteYear(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getYear();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteParentalRating", 1, new String[] { "Favorite" })
{
/**
* Returns the parental rating that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @return the parental rating that an Airing must match to be included in this Favorite, returns the empty string if parental rating isn't a field that needs to match
*
* @declaration public String GetFavoriteParentalRating(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getPR();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteChannel", 1, new String[] { "Favorite" })
{
/**
* Returns the channel name (call sign) that an Airing must be on to be included in this Favorite.
* @param Favorite the Favorite object
* @return the channel name that an Airing must be on to be included in this Favorite, returns the empty string if channel doesn't matter; for mult-channel favorites this will be a semicolon or comma-delimited list of channel names
*
* @declaration public String GetFavoriteChannel(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getChannelName();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteKeyword", 1, new String[] { "Favorite" })
{
/**
* Returns the keyword string that an Airing must match to be included in this Favorite. This is case insensitive. Double quotes
* can be used to require word to be in a certain order. Otherwise; each individual word is searched for in the Airing's details and must
* match a whole word for the match to succeed. The * character can be used to match 0 or more characters. The ? character can be used
* to match a single character. Regex is the matching language used for this so any other regex parsing characters besides * and ? can be used.
* All of the fields of the object are searched as part of this.
* @param Favorite the Favorite object
* @return the keyword that an Airing must match to be included in this Favorite, returns the empty string if keyword doesn't matter
*
* @declaration public String GetFavoriteKeyword(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
return (a == null) ? "" : a.getKeyword();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteNetwork", 1, new String[] { "Favorite" })
{
/**
* Returns the network name that an Airing must be on to be included in this Favorite.
* @param Favorite the Favorite object
* @return the network name that an Airing must be on to be included in this Favorite, returns the empty string if network doesn't matter
*
* @declaration public String GetFavoriteNetwork(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getNetwork();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteTimeslot", 1, new String[] { "Favorite" })
{
/**
* Returns the timeslot that an Airing must be in to be included in this Favorite. It just needs to overlap the timeslot.
* @param Favorite the Favorite object
* @return the timeslot that an Airing must be in to be included in this Favorite, returns the empty string if timeslot doesn't matter
*
* @declaration public String GetFavoriteTimeslot(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent a = (Agent) stack.pop();
int slotType = a.getSlotType();
int[] slots = a.getTimeslots();
if (slotType == 0 || slots == null || slots.length == 0)
return "";
StringBuffer sb = new StringBuffer();
for (int i = 0; i < slots.length; i++)
{
if (i > 0)
sb.append(';');
sb.append(BigBrother.getTimeslotString(slotType, slots[i]));
}
return sb.toString();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetStartPadding", 1, new String[] { "Favorite" })
{
/**
* Returns the amount of time any recording for this Favorite should start before the actual Airing begins.
* @param Favorite the Favorite object
* @return the amount of time any recording for this Favorite should start before the actual Airing begins, in milliseconds
*
* @declaration public long GetStartPadding(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return new Long(((Agent) stack.pop()).getStartPadding());
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetStopPadding", 1, new String[] { "Favorite" })
{
/**
* Returns the amount of time any recording for this Favorite should stop after the actual Airing ends.
* @param Favorite the Favorite object
* @return the amount of time any recording for this Favorite should stop after the actual Airing ends, in milliseconds
*
* @declaration public long GetStopPadding(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return new Long(((Agent) stack.pop()).getStopPadding());
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteQuality", 1, new String[] { "Favorite" })
{
/**
* Gets the name of the recording quality that should be used when recording this Favorite.
* @param Favorite the Favorite object
* @return the name of the recording quality that should be used when recording this Favorite, the empty string if the default recording quality should be used
*
* @declaration public String GetFavoriteQuality(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getRecordingQuality();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteAutomaticConversionFormat", 1, new String[] { "Favorite" })
{
/**
* Gets the name of the format that recordings of this Favorite will automatically be converted to when they have completed recording. It will return an empty
* string if automatic conversion is disabled for this Favorite
* @param Favorite the Favorite object
* @return the name of the transcode format that should be used when converting this Favorite, the empty string if no automatic conversion should be done
* @since 7.0
*
* @declaration public String GetFavoriteAutomaticConversionFormat(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getAutoConvertFormat();
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteAutomaticConversionDestination", 1, new String[] { "Favorite" })
{
/**
* Gets the directory that automatic conversions of this favorite should be saved to.
* Returns the empty string when using the same directory the recording is in.
* @param Favorite the Favorite object
* @return the destination directory for the automatic conversions of this Favorite; or null if its the same as the recording directory
* @since 7.0
*
* @declaration public java.io.File GetFavoriteAutomaticConversionDestination(Favorite Favorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
return ((Agent) stack.pop()).getAutoConvertDest();
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetStartPadding", 2, new String[] { "Favorite", "StartPadding" }, true)
{
/**
* Sets the amount of time any recording for this Favorite should start before the actual Airing begins.
* @param Favorite the Favorite object
* @param StartPadding the amount of time any recording for this Favorite should start before the actual Airing begins, in milliseconds
*
* @declaration public void SetStartPadding(Favorite Favorite, long StartPadding);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
long q = ((Number) stack.pop()).longValue();
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
Carny.getInstance().setStartPadding(a, q);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetStopPadding", 2, new String[] { "Favorite", "StopPadding" }, true)
{
/**
* Sets the amount of time any recording for this Favorite should stop after the actual Airing ends.
* @param Favorite the Favorite object
* @param StopPadding the amount of time any recording for this Favorite should stop after the actual Airing ends, in milliseconds
*
* @declaration public void SetStopPadding(Favorite Favorite, long StopPadding);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
long q = ((Number) stack.pop()).longValue();
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
Carny.getInstance().setStopPadding(a, q);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteQuality", 2, new String[] { "Favorite", "Quality" }, true)
{
/**
* Sets the name of the recording quality that should be used when recording this Favorite.
* @param Favorite the Favorite object
* @param Quality the name of the recording quality that should be used when recording this Favorite, the empty string if the default recording quality should be used
*
* @declaration public void SetFavoriteQuality(Favorite Favorite, String Quality);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String q = (String) stack.pop();
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Carny.getInstance().setRecordingQuality(a, q);
SchedulerSelector.getInstance().kick(false); // because it can change the encoders for it
}
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteAutomaticConversionFormat", 2, new String[] { "Favorite", "Format" }, true)
{
/**
* Sets the name of the format to transcode this Favorite to after a recording has been completed. Format names should come from {@link TranscodeAPI#GetTranscodeFormats GetTranscodeFormats()}.
* Use the empty string or null to disable automatic conversion for this Favorite.
* @param Favorite the Favorite object
* @param Format the name of the transcode format to use when converting recordings of this Favorite; the empty string or null to disable automatic conversion
* @since 7.0
*
* @declaration public void SetFavoriteAutomaticConversionFormat(Favorite Favorite, String Format);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String q = (String) stack.pop();
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()) && Permissions.hasPermission(Permissions.PERMISSION_CONVERSION, stack.getUIMgr()))
Carny.getInstance().setAutoConvertFormat(a, q);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteAutomaticConversionDestination", 2, new String[] { "Favorite", "Folder" }, true)
{
/**
* Sets the directory that automatic conversions of this favorite should be saved to.
* Use null to use the same directory the recording is in.
* @param Favorite the Favorite object
* @param Folder the destination directory for the automatic conversions of this Favorite; null to use the same directory as the recording directory
* @since 7.0
*
* @declaration public void SetFavoriteAutomaticConversionDestination(Favorite Favorite, java.io.File Folder);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
java.io.File f = getFile(stack);
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()) && Permissions.hasPermission(Permissions.PERMISSION_CONVERSION, stack.getUIMgr()))
a.setAutoConvertDest(f);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "CreateFavoritePriority", 2, new String[] { "HigherPriorityFavorite", "LowerPriorityFavorite" }, true)
{
/**
* Establishes a priority of one Favorite over another. This will take undo any previous prioritization that it directly conflicts with.
* Favorites with a higher priority will be recorded over ones with a lower priority if there's a case where both cannot be recorded at once.
* @param HigherPriorityFavorite the Favorite object that you wish to make a higher priority than the other specified Favorite object
* @param LowerPriorityFavorite the Favorite object that you wish to make a lower priority than the other specified Favorite object
*
* @declaration public void CreateFavoritePriority(Favorite HigherPriorityFavorite, Favorite LowerPriorityFavorite);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Agent q = (Agent) stack.pop();
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
Carny.getInstance().createPriority(a, q);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "ConfirmManualRecordOverFavoritePriority", 2, new String[] { "ManualRecordAiring", "FavoriteAiring" }, true)
{
/**
* Confirms that the user is aware that a manual recording they've selected creates a conflict with this favorite recording. This is purely
* for notifcation purposes.
* @param ManualRecordAiring the manual record Airing object to confirm the recording priority of
* @param FavoriteAiring the Airing for the Favorite that won't be recorded due to the manual record
*
* @declaration public void ConfirmManualRecordOverFavoritePriority(Airing ManualRecordAiring, Airing FavoriteAiring);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Airing q = getAir(stack);
Airing a = getAir(stack);
if (a != null)
{
ManualRecord mr = Wizard.getInstance().getManualRecord(a);
if (mr != null && q != null && Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
mr.bully(q);
SchedulerSelector.getInstance().kick(false);
}
}
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetDontAutodelete", 2, new String[] { "Favorite", "DontAutoDelete" }, true)
{
/**
* Sets whether or not SageTV is allowed to automatically delete recordings of this
* Favorite when it needs more disk space. If this is true, then SageTV will never automatically
* delete files recorded for this Favorite; the user will have to delete the files themself.
* @param Favorite the Favorite object
* @param DontAutoDelete true if this Favorite is configured to NOT auto delete, false otherwise
*
* @declaration public void SetDontAutodelete(Favorite Favorite, boolean DontAutoDelete);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
boolean b = evalBool(stack.pop());
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Carny.getInstance().setAgentFlags(a, Agent.DONT_AUTODELETE_FLAG, b?Agent.DONT_AUTODELETE_FLAG:0);
Carny.getInstance().kick();
}
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetDeleteAfterAutomaticConversion", 2, new String[] { "Favorite", "DeleteAfterAutomaticConversion" }, true)
{
/**
* Sets whether or not SageTV should delete the original file after doing an automatic conversion
* for this Favorite
* @param Favorite the Favorite object
* @param DeleteAfterAutomaticConversion true if this Favorite is configured to delete the source file after automatic conversion
* @since 7.0
*
* @declaration public void SetDeleteAfterAutomaticConversion(Favorite Favorite, boolean DeleteAfterAutomaticConversion);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
boolean b = evalBool(stack.pop());
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()) && Permissions.hasPermission(Permissions.PERMISSION_CONVERSION, stack.getUIMgr()))
Carny.getInstance().setAgentFlags(a, Agent.DELETE_AFTER_CONVERT_FLAG, b?Agent.DELETE_AFTER_CONVERT_FLAG:0);
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetKeepAtMost", 2, new String[] { "Favorite", "NumberToKeep" }, true)
{
/**
* Sets the maximum number of recordings that match this Favorite that should be kept on disk. If AutoDelete is
* set to true then SageTV will continue to record new airings of this Favorite as they air, and delete the oldest
* recording on disk if it hits the keep at most limit. If AutoDelete is false then SageTV will stop recording this Favorite
* once it has this many recordings on disk
* @param Favorite the Favorite object
* @param NumberToKeep the maximum number of recordings SageTV should keep on disk of this Favorite, 0 if it is unlimited
*
* @declaration public void SetKeepAtMost(Favorite Favorite, int NumberToKeep);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
int q = getInt(stack);
q = Math.min(Math.max(0, q), 63); // this uses 6 bits to store itself
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Carny.getInstance().setAgentFlags(a, Agent.KEEP_AT_MOST_MASK, q);
Carny.getInstance().kick();
}
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetRunStatus", 3, new String[] { "Favorite", "FirstRuns", "ReRuns" }, true)
{
/**
* Sets whether first runs, reruns or both types of airings should be recorded for this Favorite. If both arguments
* are false, SageTV will record both first runs and reruns.
* @param Favorite the Favorite object
* @param FirstRuns true if first runs should be recorded with this favorite, false otherwise
* @param ReRuns true if reruns should be recorded with this Favorite, false otherwise
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetRunStatus(Favorite Favorite, boolean FirstRuns, boolean ReRuns);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
boolean rb = evalBool(stack.pop());
boolean fb = evalBool(stack.pop());
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (rb && !fb)
{
newMask = newMask | Agent.RERUN_MASK;
newMask = newMask & (~Agent.FIRSTRUN_MASK);
}
else if (!rb && fb)
{
newMask = newMask | Agent.FIRSTRUN_MASK;
newMask = newMask & (~Agent.RERUN_MASK);
}
else
newMask = newMask & ~(Agent.RERUN_MASK | Agent.FIRSTRUN_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteTitle", 2, new String[] { "Favorite", "Title" }, true)
{
/**
* Sets the title that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @param Title the title that an Airing must match to be included in this Favorite, use the empty string or null if the title isn't a field that needs to match
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteTitle(Favorite Favorite, String Title);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.TITLE_MASK;
else
newMask = newMask & (~Agent.TITLE_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, s, a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteCategories", 3, new String[] { "Favorite", "Category", "SubCategory" }, true)
{
/**
* Sets the category and optionally the subcategory that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @param Category the category that an Airing must match to be included in this Favorite, use the empty string or null if the category isn't a field that needs to match
* @param SubCategory the category that an Airing must match to be included in this Favorite, use the empty string the subcategory doesn't need to match
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteCategories(Favorite Favorite, String Category, String SubCategory);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String sub = getString(stack);
String scat = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (scat != null && scat.length() > 0)
newMask = newMask | Agent.CATEGORY_MASK;
else
newMask = newMask & (~Agent.CATEGORY_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), scat, sub,
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoritePerson", 3, new String[] { "Favorite", "Person", "Role" }, true)
{
/**
* Sets a person (and optionally the role the person must appear in) that must be in an Airing for it to be included in this Favorite
* @param Favorite the Favorite object
* @param Person the name of the person that needs to be included in an Airing for it to match this Favorite, use the empty string or null if person doesn't need to match
* @param Role the name of the role the corresponding person needs to be in, or the emptry string or null if role doesn't matter
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoritePerson(Favorite Favorite, Person Person, String Role);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
int role = Show.getRoleForString(getString(stack));
Person p = getPerson(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (p != null)
newMask = newMask | Agent.ACTOR_MASK;
else
newMask = newMask & (~Agent.ACTOR_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
p, role, a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteRated", 2, new String[] { "Favorite", "Rated" }, true)
{
/**
* Sets the rating that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @param Rated the rating that an Airing must match to be included in this Favorite, use the empty string or null if rating isn't a field that needs to match
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteRated(Favorite Favorite, String Rated);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.RATED_MASK;
else
newMask = newMask & (~Agent.RATED_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), s, a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteYear", 2, new String[] { "Favorite", "Year" }, true)
{
/**
* Sets the year that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @param Year the year that an Airing must match to be included in this Favorite, use the empty string or null if year isn't a field that needs to match
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteYear(Favorite Favorite, String Year);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.YEAR_MASK;
else
newMask = newMask & (~Agent.YEAR_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), s, a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteParentalRating", 2, new String[] { "Favorite", "ParentalRating" }, true)
{
/**
* Sets the parental rating that an Airing must match to be included in this Favorite.
* @param Favorite the Favorite object
* @param ParentalRating the parental rating that an Airing must match to be included in this Favorite, use the empty string or null if parental rating isn't a field that needs to match
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteParentalRating(Favorite Favorite, String ParentalRating);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.PR_MASK;
else
newMask = newMask & (~Agent.PR_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), s, a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteKeyword", new String[] { "Favorite", "Keyword" }, true)
{
/**
* Sets the keyword string that an Airing must match to be included in this Favorite. This is case insensitive. Double quotes
* can be used to require word to be in a certain order. Otherwise; each individual word is searched for in the Airing's details and must
* match a whole word for the match to succeed. The * character can be used to match 0 or more characters. The ? character can be used
* to match a single character. Regex is the matching language used for this so any other regex parsing characters besides * and ? can be used.
* All of the fields of the object are searched as part of this.
* @param Favorite the Favorite object
* @param Keyword the keyword that an Airing must match to be included in this Favorite, use the empty string or null if keyword doesn't matter
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteKeyword(Favorite Favorite, String Keyword);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.KEYWORD_MASK;
else
newMask = newMask & (~Agent.KEYWORD_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
a.getSlotType(), a.getTimeslots(), s);
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteChannel", 2, new String[] { "Favorite", "Channel" }, true)
{
/**
* Sets the channel name (call sign) that an Airing must be on to be included in this Favorite.
* @param Favorite the Favorite object
* @param Channel the channel name (String) or Channel object (Channel) that an Airing must be on to be included in this Favorite, use null or the empty string if channel doesn't matter; you may also use a semicolon or comma-delimited list of channel names for mult-channel favorites
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteChannel(Favorite Favorite, Object Channel);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Object o = stack.pop();
String s;
if (o instanceof Channel)
s = ((Channel) o).getName();
else if (o != null)
s = o.toString();
else
s = null;
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.CHANNEL_MASK;
else
newMask = newMask & (~Agent.CHANNEL_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), s,
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteNetwork", 2, new String[] { "Favorite", "Network" }, true)
{
/**
* Sets the network name that an Airing must be on to be included in this Favorite.
* @param Favorite the Favorite object
* @param Network the network name that an Airing must be on to be included in this Favorite, use null or the empty string if network doesn't matter
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteNetwork(Favorite Favorite, String Network);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String s = getString(stack);
Agent a = (Agent) stack.pop();
int newMask = a.getAgentMask();
if (s != null && s.length() > 0)
newMask = newMask | Agent.NETWORK_MASK;
else
newMask = newMask & (~Agent.NETWORK_MASK);
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), s, a.getChannelName(),
a.getSlotType(), a.getTimeslots(), a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteTimeslot", 2, new String[] { "Favorite", "Timeslot" }, true)
{
/**
* Sets the timeslot that an Airing must be in to be included in this Favorite. It just needs to overlap the timeslot.
* @param Favorite the Favorite object
* @param Timeslot the timeslot that an Airing must be in to be included in this Favorite, use null or the empty string if timeslot doesn't matter.
* The timeslot should be in one of three formats: 1) Day Time, 2) Day, 3) Time. Where Day is a day of the week, and Time is an
* hour of the day such as 3pm or 8:00 (if the user's locale uses am/pm then it'll be like 3pm, otherwise it'll use like 8:00).
* Multiple timeslots are allowed and should be sent as a semicolon delimited list; an Airing only needs to overlap one of the timeslots to match the Favorite then.
* Multiple timeslots must also all be of the same type (i.e. all DayTime, all Day or all Time).
* @return true if the change was successful, false if the change would alter this Favorite to be identical to an existing Favorite or if the user doesn't have permissions to make this change
*
* @declaration public boolean SetFavoriteTimeslot(Favorite Favorite, String Timeslot);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
String slotString = getString(stack);
if (slotString == null) slotString = "";
java.util.StringTokenizer toker = new java.util.StringTokenizer(slotString, ";");
int slotType = 0;
java.util.ArrayList slots = new java.util.ArrayList();
Agent a = (Agent) stack.pop();
while (toker.hasMoreTokens())
{
int[] ts = BigBrother.getTimeslotForString(toker.nextToken());
if (slotType == 0)
slotType = ts[0];
else if (slotType != ts[0])
throw new IllegalArgumentException("All timeslots passed into SetFavoriteTimeslot must be of the same type!");
if (slotType != 0)
slots.add(new Integer(ts[1]));
}
int newMask = a.getAgentMask();
newMask = newMask & ~(Agent.DAYSLOT_MASK | Agent.TIMESLOT_MASK | Agent.FULLSLOT_MASK);
if (slotType == BigBrother.DAY_ALIGN)
newMask = newMask | Agent.DAYSLOT_MASK;
else if (slotType == BigBrother.TIME_ALIGN)
newMask = newMask | Agent.TIMESLOT_MASK;
else if (slotType == BigBrother.FULL_ALIGN)
newMask = newMask | Agent.FULLSLOT_MASK;
int[] rawSlots = null;
if (slots.size() > 0)
{
rawSlots = new int[slots.size()];
for (int i = 0; i < slots.size(); i++)
rawSlots[i] = ((Integer) slots.get(i)).intValue();
}
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Agent noob = Carny.getInstance().updateFavorite(a, newMask, a.getTitle(), a.getCategory(), a.getSubCategory(),
a.getPersonObj(), a.getRole(), a.getRated(), a.getYear(), a.getPR(), a.getNetwork(), a.getChannelName(),
slotType, rawSlots, a.getKeyword());
return (noob == a) ? Boolean.TRUE : Boolean.FALSE;
}
else
return Boolean.FALSE;
}});
rft.put(new PredefinedJEPFunction("Favorite", "SetFavoriteEnabled", 2, new String[] { "Favorite", "Enabled" }, true)
{
/**
* Sets whether or not SageTV will use this favorite when scheduling recordings
* @param Favorite the Favorite object
* @param Enabled true if this Favorite is to be used for scheduling, false otherwise
* @since 9.0
*
* @declaration public void SetFavoriteEnabled(Favorite Favorite, boolean Enabled);
*/
@Override
public Object runSafely(Catbert.FastStack stack) throws Exception{
boolean b = evalBool(stack.pop());
Agent a = (Agent) stack.pop();
if (Permissions.hasPermission(Permissions.PERMISSION_RECORDINGSCHEDULE, stack.getUIMgr()))
{
Carny.getInstance().enableFavorite(a, b);
Carny.getInstance().kick();
}
return null;
}});
rft.put(new PredefinedJEPFunction("Favorite", "GetFavoriteForAiring", 1, new String[] { "Airing" })
{
/**
* Gets the Favorite that matches this Airing if one exists.
* @param Airing the Airing object to get a matching Favorite for
* @return a Favorite object that matches this Airing or null if there is no such Favorite
*
* @declaration public Favorite GetFavoriteForAiring(Airing Airing);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
Airing a = getAir(stack);
Agent bond = Carny.getInstance().getCauseAgent(a);
if (bond != null && bond.isFavorite())