-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
streamextras.py
1206 lines (1096 loc) · 47.2 KB
/
streamextras.py
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
'''
Gitago's Stream Extras Plugin
'''
import sys
import TouchPortalAPI as TP
import requests
import re
import urllib.request as urllib2
import random
import time
from tabulate import tabulate
from threading import Thread
from collections import deque
# imports below are optional, to provide argument parsing and logging functionality
from argparse import ArgumentParser
from logging import (getLogger, Formatter, NullHandler, FileHandler, StreamHandler, DEBUG, INFO, WARNING)
__version__ = "2.3"
PLUGIN_ID = "gitago.streamextras.plugin"
TP_PLUGIN_INFO = {
'sdk': 3,
'version': int(float(__version__) * 1),
'name': "Stream Extras",
'id': PLUGIN_ID,
'configuration': {
'colorDark': "#a1a915",
'colorLight': "#676767",
}
}
TP_PLUGIN_SETTINGS = {
'TwitchChannelID': {
'name': "Twitch ID",
'type': "text",
'default': "",
'readOnly': False,
},
'YoutubeID': {
'name': "Youtube ID",
'type': "text",
'default': "",
'readOnly': False,
},
'WaitTime': {
'name': "Wait Time",
'type': "number",
'default': "3",
'readOnly': False,
}
}
TP_PLUGIN_CATEGORIES = {
"streamextras": {
'id': PLUGIN_ID + ".streamextras",
'name': "SE | Stream Extras",
'imagepath': "%TP_PLUGIN_FOLDER%Countdown Plugin/timer_git.png"
},
"lists": {
'id': PLUGIN_ID + ".lists",
'name': "SE | Lists",
'imagepath': "%TP_PLUGIN_FOLDER%Countdown Plugin/timer_git.png"
},
"giveaway_lists": {
'id': PLUGIN_ID + ".giveawaylist",
'name': "SE | Lists: Giveaway",
'imagepath': "%TP_PLUGIN_FOLDER%Countdown Plugin/timer_git.png"
},
"youtube_extras": {
'id': PLUGIN_ID + ".youtube_extras",
'name': "SE | Youtube",
'imagepath': "%TP_PLUGIN_FOLDER%Countdown Plugin/timer_git.png"
}
}
TP_PLUGIN_ACTIONS = {
'action1': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.game2",
'name': "Twitch Extras (Get Info)",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "Get {$gitago.streamextras.plugin.act.get.choice$} for {$gitago.streamextras.plugin.act.viewer.name$} ",
'data': {
'viewername': {
'id': PLUGIN_ID + ".act.viewer.name",
'type': "text",
'label': "viewer name",
'default': "",
},
'hours': {
'id': PLUGIN_ID + ".act.get.choice",
'type': "choice",
'label': "Your Choice",
'default': "",
'valueChoices': ["Game/Category", "Avatar", "Status", "Account Age", "Follow Age", "Follower Count", "Random User", "Up-Time", "Highlights", "Most Recent Upload", "Total Views", "Viewer Count" ]
},
}
},
'action2': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.game1",
'name': "Get (X) Followers [100 max]",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "Retrieve {$gitago.streamextras.plugin.act.get.count$} {$gitago.streamextras.plugin.act.get.choice2$} for {$gitago.streamextras.plugin.act.viewer.name2$} {$gitago.streamextras.plugin.act.asc.desc$} ",
'data': {
'viewername': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.viewer.name2",
'type': "text",
'label': "viewer name",
'default': "",
},
'hours': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.choice2",
'type': "choice",
'label': "See Multiple Followers or Videos",
'default': "Follower(s)",
'valueChoices': [ "Follower(s)" ]
},
'count': {
'id': PLUGIN_ID + ".act.get.count",
'type': "number",
'label': "count",
'default': "0",
"minValue": 0,
"maxValue": 100,
'allowDecimals': False
},
'desc/asc': {
'id': PLUGIN_ID + ".act.asc.desc",
'type': "choice",
'label': "asc or desc",
'default': "Descending",
'valueChoices': ["Ascending", "Descending"]
},
}
},
'action3': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.youtubevideo",
'name': "Get YT Video URL + Description",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "Retrieve latest {$gitago.streamextras.plugin.act.get.choice3$}",
'data': {
'viewername': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.viewer.name3",
'type': "text",
'label': "viewer name",
'default': "",
},
'hours': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.choice3",
'type': "choice",
'label': "See Multiple Followers or Videos",
'default': "Youtube Video",
'valueChoices': [ "Youtube Video" ]
},
}
},
'Action 4': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.live.youtubeurl",
'name': "Get YT Live URL",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "Get the Live Youtube URL for {$gitago.streamextras.plugin.act.youtuber.name$}",
'data': {
'Live Stream to Get': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.youtuber.name",
'type': "text",
'label': "Retrieve Live Youtube URL / Channel Trailer ",
'default': "",
}
}
},
'action5': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.random",
'name': "Pick Random Active Chatter",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "Get Random {$gitago.streamextras.plugin.act.get.randomchoice$}",
'data': {
'randomchoice': {
'category': "streamextras",
'id': PLUGIN_ID + ".act.get.randomchoice",
'type': "choice",
'label': "Your Choice",
'default': "",
'valueChoices': ["Random User"]
},
}
},
'action6': {
'category': "lists",
'id': PLUGIN_ID + ".act.list",
'name': "Add or Remove to/from a List",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "{$gitago.streamextras.plugin.act.list.add.remove$} {$gitago.streamextras.plugin.act.list.chatter$} to the list {$gitago.streamextras.plugin.act.list.name$}",
'data': {
'List Names .act.list': {
'id': PLUGIN_ID + ".act.list.name",
'type': "choice",
'label': "Pick a Name",
'default': "Chatter List",
'valueChoices': ["Chatter List", "Giveaway List"]
},
'Add or Remove Person': {
'id': PLUGIN_ID + ".act.list.add.remove",
'type': "choice",
'label': "Lists: Add / Remove Person ",
'default': "Add",
'valueChoices': ["Add", "Remove"]
},
'name of person': {
'id': PLUGIN_ID + ".act.list.chatter",
'type': "text",
'label': "Chatter to Add or Remove",
'default': "",
},
}
},
'action7': {
'category': "lists",
'id': PLUGIN_ID + ".act.clearlist",
'name': "Save or Clear a List",
'prefix': TP_PLUGIN_CATEGORIES['lists']['name'],
'type': "communicate",
"tryInline": True,
'format': "{$gitago.streamextras.plugin.act.list.clear.or.save$} the list {$gitago.streamextras.plugin.act.list.clear$} in the format {$gitago.streamextras.plugin.act.list.listsaveformat$}",
'data': {
'List Names .act.list.clear': {
'category': "lists",
'id': PLUGIN_ID + ".act.list.clear",
'type': "choice",
'label': "Clear a List",
'default': "",
'valueChoices': ["Chatter List", "Giveaway List"]
},
'Clear or Random': {
'category': "lists",
'id': PLUGIN_ID + ".act.list.clear.or.save",
'type': "choice",
'label': "Save or Clear a List",
'default': "",
'valueChoices': ["Save", "Clear"]
},
'List Save Format': {
'category': "lists",
'id': PLUGIN_ID + ".act.list.listsaveformat",
'type': "choice",
'label': "Save Format",
'default': "",
'valueChoices': ["Grid", "Fancy_Grid", "Github", "Simple", "Presto", "Pretty", "PSQL", "Pipe", "Orgtbl", "Jira", "Rst", "MoinMoin", "YouTrack", "Textile", "HTML", "Latex"]
}
}
},
'action8': {
'category': "lists",
'id': PLUGIN_ID + ".act.random.hold",
'name': "On Hold Random Pick",
'prefix': TP_PLUGIN_CATEGORIES['lists']['name'],
'type': "communicate",
"tryInline": True,
"hasHoldFunctionality": True,
'format': "Pick a Random Person from {$gitago.streamextras.plugin.act.onhold.listchoice$} ",
'data': {
'on hold random pick': {
'id': PLUGIN_ID + ".act.onhold.listchoice",
'type': "choice",
'label': "Your Choice",
'default': "",
'valueChoices': [ "Chatter List", "Giveaway List"]
},
}
},
'action9': {
'category': "lists",
'id': PLUGIN_ID + ".act.list.pickrandom",
'name': "Pick Random from List",
'prefix': TP_PLUGIN_CATEGORIES['lists']['name'],
'type': "communicate",
"tryInline": True,
'format': "Select a Random User from {$gitago.streamextras.plugin.act.list.choice$}",
'data': {
'List Names .act.list.clear': {
'category': "lists",
'id': PLUGIN_ID + ".act.list.choice",
'type': "choice",
'label': "Pick a Random Choice",
'default': "",
'valueChoices': ["Chatter List", "Giveaway List"]
}
}
},
###
'action10': {
'category': "lists",
'id': PLUGIN_ID + ".act.queue",
'name': "Start/Stop Chatter Queue",
'prefix': TP_PLUGIN_CATEGORIES['streamextras']['name'],
'type': "communicate",
"tryInline": True,
'format': "{$gitago.streamextras.plugin.act.queue.choice$} the New Chatter Queue ",
'data': {
'List Names .act.list': {
'id': PLUGIN_ID + ".act.queue.choice",
'type': "choice",
'label': "Start or stop",
'default': "Stop",
'valueChoices': ["Start", "Stop", "Pause"]
},
}
},
##
}
### giveawaylist.status needs looked at... its telling what person was removed/added..
## need something like it, but to tel lif the giveaway is actively running or not...
# Plugin static or dynamic state(s).
TP_PLUGIN_STATES = {
'recentfollowers': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.recentchannelfollower",
'type': "text",
'desc': "SE | Channel's Recent Follower(s)",
'default': ""
},
'highlights': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.highlight",
'type': "text",
'desc': "SE | Channel's Highlights URL",
'default': ""
},
'viewer_game': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.gametitle",
'type': "text",
'desc': "SE | User - Last Game/Category Streamed",
'default': ""
},
'channel_status': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.channelstatus",
'type': "text",
'desc': "SE | User - Channel Description",
'default': ""
},
'avatar_URL': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.avatarurl",
'type': "text",
'desc': "SE | User - Avatar URL",
'default': ""
},
'followercount': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.followerscount",
'type': "text",
'desc': "SE | User - Follower Count",
'default': ""
},
'viewercount': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.viewercount",
'type': "text",
'desc': "SE | User - Viewer Count",
'default': ""
},
'totalviews': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.totalviews",
'type': "text",
'desc': "SE | User - Total Channel Views",
'default': ""
},
'creationdate': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.accountage",
'type': "text",
'desc': "SE | User - Created Date",
'default': ""
},
'Follow Age': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.followage",
'type': "text",
'desc': "SE | User - Follow Age",
'default': ""
},
'randompick': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.randompick",
'type': "text",
'desc': "SE | Random Active User OTHER",
'default': ""
},
'randomuser': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.randomuser",
'type': "text",
'desc': "SE | Random - Active User",
'default': ""
},
'recentupload': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.recentupload",
'type': "text",
'desc': "SE | Recent Upload - Full Details ",
'default': ""
},
'Most Recent Video: URL': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.uploadurl",
'type': "text",
'desc': "SE | Recent Video - Upload URL",
'default': ""
},
'Most Recent Video: Title': {
'category': "streamextras",
'id': PLUGIN_ID + ".state.uploadtitle",
'type': "text",
'desc': "SE | Recent Video - Upload Title",
'default': ""
},
'Youtube Live Video: Full URL': {
'category': "youtube_extras",
'id': PLUGIN_ID + ".state.youtubeliveurl",
'type': "text",
'desc': "SE | Youtube LIVE - Full URL ",
'default': ""
},
'Youtube Recent Video: Full Info': {
'category': "youtube_extras",
'id': PLUGIN_ID + ".state.youtubevideofull",
'type': "text",
'desc': "SE | Youtube Video - Description + URL ",
'default': ""
},
'Youtube Recent Video: URL': {
'category': "youtube_extras",
'id': PLUGIN_ID + ".state.youtubevideourl",
'type': "text",
'desc': "SE | Youtube Video - URL",
'default': ""
},
'Youtube Recent Video: Description': {
'category': "youtube_extras",
'id': PLUGIN_ID + ".state.youtubevideodescription",
'type': "text",
'desc': "SE | Youtube Video - Description",
'default': ""
},
'New Chatter Status': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.chatterstatus",
'type': "text",
'desc': "SE | New Chatter Status",
'default': "False"
},
'The Chatter Queue Status': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.queuestatus",
'type': "text",
'desc': "SE | Chatter List: Queue Status",
'default': ""
},
'New Chatter Name': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.chattername",
'type': "text",
'desc': "SE | New Chatter Name",
'default': ""
},
'Chatter List Status': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.status",
'type': "text",
'desc': "SE | Chatter List - Status",
'default': ""
},
'Chatter List Total': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.chattertotal",
'type': "text",
'desc': "SE | Chatter List - Total Chatters",
'default': ""
},
'Chatter Queue Total': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.queuetotal",
'type': "text",
'desc': "SE | Chatter List - Chat Queue Total",
'default': ""
},
'Chatter List Random Pick': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatterlist.random",
'type': "text",
'desc': "SE | Chatter List - Random Pick",
'default': ""
},
'Giveaway List Status': {
'category': "giveaway_lists",
'id': PLUGIN_ID + ".state.giveawaylist.status",
'type': "text",
'desc': "SE | Giveaway List - Status",
'default': ""
},
'Giveaway List Total': {
'category': "giveaway_lists",
'id': PLUGIN_ID + ".state.giveawaylist.total",
'type': "text",
'desc': "SE | Giveaway List - Total",
'default': ""
},
'Giveaway List Random Pick': {
'category': "giveaway_lists",
'id': PLUGIN_ID + ".state.giveawaylist.random",
'type': "text",
'desc': "SE | Giveaway List - Random Pick",
'default': ""
},
'Top Chatter #1': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatter_first",
'type': "text",
'desc': "SE | Top Chatter #1",
'default': ""
},
'Top Chatter #2': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatter_second",
'type': "text",
'desc': "SE | Top Chatter #2",
'default': ""
},
'Top Chatter #3': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatter_third",
'type': "text",
'desc': "SE | Top Chatter #3",
'default': ""
},
'Top Chatter #4': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatter_fourth",
'type': "text",
'desc': "SE | Top Chatter #4",
'default': ""
},
'Top Chatter #5': {
'category': "lists",
'id': PLUGIN_ID + ".state.chatter_fifth",
'type': "text",
'desc': "SE | Top Chatter #5",
'default': ""
},
}
# Plugin Event(s).
TP_PLUGIN_EVENTS = {}
try:
TPClient = TP.Client(
pluginId=PLUGIN_ID,
sleepPeriod=0.05,
autoClose=True,
checkPluginId=True,
maxWorkers=4,
updateStatesOnBroadcast=False,
)
except Exception as e:
sys.exit(f"Could not create TP Client, exiting. Error was:\n{repr(e)}")
#### Main Variables n Such ####
global totalchatterlist
global chatterlist
global giveawaylist #no idea if this global is needed
totalchatterlist = ""
queue = deque([])
cl = {}
giveawaylist = []
#have chatterlist = cl because of old code and not tryin to get confused lol
chatterlist = cl
queue_switch = "pause"
running = False
### Settings Stuff #####
wait = 0
twitchid = ""
youtubeid = ""
#### NOT SURE IF THIS IS NEEDED SINCE IT SETS ELSEWHERE WITH LEGIT INFO??
##### LIST AND QUEUE THINGS #####
def checkchatter(chatname, listname):
global cl
global queue
global running
if chatname == "":
print("its blank")
if queue_switch =="":
print("something went wrong")
# IF CHATTER LIST ON OR PAUSED
if queue_switch == "on" or queue_switch == "pause" and listname =="Chatter List":
update_top_list()
if chatname in cl:
cl[chatname] += 1
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chattertotal", str(len(cl)))
print(cl)
#IF NOT IN LIST JUST ADD NAME with 1 and add to queue
if chatname not in cl:
cl[chatname] = 1
queue.append(chatname)
# print("New Chatter:", chatname, "Added")
#print("")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chattertotal", str(len(cl)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", str(len(queue)))
if not running and queue_switch == "on" and (len(queue)) > 0:
print("startin it up since its off and chatter not in list")
running = True
Thread(target = startqueue).start()
if not running and queue_switch == "pause" and (len(queue)) > 0:
pass
# just some what ifs below
if queue_switch =="on" and running:
pass
if queue_switch == "off" and (len(queue)) > 0:
print("queue is off, and we have people waiting")
running = False
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chatterstatus", "FALSE")
#maybe use this for 'multiple lists'..
def addname(chatname, listname):
if listname == "Chatter List":
cl[chatname] += 1
queue.append(chatname)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", str(len(queue)))
if listname == "Giveaway List":
giveawaylist.append(chatname)
totalgiveawaylist = len(giveawaylist)
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.status", chatname + " added.")
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.total", str(totalgiveawaylist))
def startqueue():
global running
while (len(queue)) >= 0:
print("The Remaining Queue [", (len(queue)), "]: ", queue)
print("")
item = queue.popleft()
print("Person removed: ", item, "next in: ", wait, "seconds")
print("")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chatterstatus", "TRUE")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chattername", item)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", str(len(queue)))
time.sleep(2)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chatterstatus", "FALSE")
time.sleep(int(wait))
if (len(queue)) == 0:
print(f"queue is {(str(len(queue)))}, Running is FALSE now")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chatterstatus", "FALSE")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuestatus", "Waiting")
running = False
break
if queue_switch == "off":
print("Can not continue, Queue is OFF")
break
if queue_switch == "pause":
print("Can not continue, Queue is Paused")
break
print("Ok, Loop Stopped")
##switch is controlled by TP data, which looks to see if queue_switch is on/off/paused.. andthen decides what to do then...
def switch(data):
global queue_switch
global running
if data == "on" and not running:
if (len(queue)) == 0:
queue_switch = "on"
print("0 in QUEUE, Switch is now ON")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuestatus", "On")
pass
if (len(queue)) > 0:
print(len(queue))
queue_switch = "on"
Thread(target = startqueue).start()
print("Switch On Initiated: ",queue_switch)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuestatus", "On")
if data== "off":
queue_switch = "off"
print("Switch Off Initiated: ",queue_switch)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuestatus", "Off")
if data == "pause":
queue_switch = "pause"
print("Pause Initiated: ", queue_switch)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuestatus", "Paused")
def removename(chattername, listname):
global chatterlist
if listname =="Chatter List":
if chattername in chatterlist:
chatterlist.remove(chattername)
totalchatterlist = len(chatterlist)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", str(totalchatterlist))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.status", chattername + " removed from list")
print("1 removed chatter list")
if listname =="Giveaway List":
if chattername in giveawaylist:
giveawaylist.remove(chattername)
totalgiveawaylist = len(giveawaylist)
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.total", str(totalgiveawaylist))
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.status", chattername + " removed from list")
print("1 removed from giveaway list")
def clearlist(listclearname):
global totalchatterlist
#global totalgiveawaylist
global chatterlist
global cl
global giveawaylist
#put this global in so it can clear queue when it clears chatter list..
global queue
if listclearname == "Chatter List":
print("Chatter List CLEARED")
cl = {}
chatterlist = cl
queue = deque([])
totalchatterlist = "0"
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", str(len(queue)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chattertotal", totalchatterlist)
print(cl)
print(chatterlist)
print(queue)
elif listclearname == "Giveaway List":
print("Giveaway List CLEARED")
giveawaylist = []
totalgiveawaylist = "0"
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.total", totalgiveawaylist)
#used mainly just to pick a random active chatter
def randomlistpick(listname):
if listname == "Chatter List":
if (int(len(chatterlist))) == 0:
print("sorry no body in list")
elif (int(len(chatterlist))) > 0:
randompick = random.choice(cl)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.random", randompick)
while randompick == "":
print("Something went wrong, picking again")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.random", randompick)
# TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.random", randompick)
if listname == "Giveaway List":
if (int(len(giveawaylist))) == 0:
print("sorry no body in list")
elif (int(len(giveawaylist))) > 0:
randompick = random.choice(cl)
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.random", randompick)
while randompick == "":
print("Something went wrong, picking again")
TPClient.stateUpdate(PLUGIN_ID + ".state.giveawaylist.random", randompick)
def update_top_list():
global cl
sorted_chatlist = dict(sorted(cl.items(), key=lambda item: item[1], reverse = True))
#print(len(cl))
print(cl)
if (len(cl)) == 0:
pass
if (len(cl)) == 1:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
if (len(cl)) == 2:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
second = str(count1).ljust(3)+ ": " + name1.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_second", (str(second)))
if (len(cl)) == 3:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
second = str(count1).ljust(3)+ ": " + name1.ljust(27)
third = str(count2).ljust(3) + ": " + name2.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_second", (str(second)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_third", (str(third)))
if (len(cl)) == 4:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
second = str(count1).ljust(3)+ ": " + name1.ljust(27)
third = str(count2).ljust(3) + ": " + name2.ljust(27)
fourth = str(count3).ljust(3) + ": " + name3.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_second", (str(second)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_third", (str(third)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_fourth", (str(fourth)))
if (len(cl)) == 5:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
second = str(count1).ljust(3)+ ": " + name1.ljust(27)
third = str(count2).ljust(3) + ": " + name2.ljust(27)
fourth = str(count3).ljust(3) + ": " + name3.ljust(27)
fifth = str(count4).ljust(3) + ": " + name4.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_second", (str(second)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_third", (str(third)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_fourth", (str(fourth)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_fifth", (str(fifth)))
if (len(cl)) >= 6:
for n, key in enumerate(sorted_chatlist.keys()):
globals()["name%d"%n] = key
for n, val in enumerate(sorted_chatlist.values()):
globals()["count%d"%n] = val
first = str(count0).ljust(3)+ ": " + name0.ljust(27)
second = str(count1).ljust(3)+ ": " + name1.ljust(27)
third = str(count2).ljust(3) + ": " + name2.ljust(27)
fourth = str(count3).ljust(3) + ": " + name3.ljust(27)
fifth = str(count4).ljust(3) + ": " + name4.ljust(27)
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_first", (str(first)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_second", (str(second)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_third", (str(third)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_fourth", (str(fourth)))
TPClient.stateUpdate(PLUGIN_ID + ".state.chatter_fifth", (str(fifth)))
def savelist(list, formatchoice):
global cl
if list =="Chat List":
sorted_chatlist = dict(sorted(chatterlist.items(), key=lambda item: item[1], reverse = True))
data = [[idx, key, val] for idx, (key, val) in enumerate(sorted_chatlist.items(), start =1)]
headers = ["#", "Name", "Messages"]
tabulated = (tabulate(data, headers, tablefmt= formatchoice.lower() ))
textfile = open("Active_Chatters.txt", "w")
textfile.write(tabulated)
textfile.close()
if list =="Giveaway List":
num = 0
totalgiveawaylist=(len(giveawaylist))
textfile = open("Giveaway_List.txt", "w")
textfile.write("Giveaway List" + " - " + (str(totalgiveawaylist)) + "\n")
for element in giveawaylist:
num +=1
textfile.write(str(num).ljust(2) + " | " + element + "\n")
textfile.close()
#### END OF LIST/QUEUE FUNCTIONS #####
# TP Client event handler callbacks
# Initial connection handler
@TPClient.on(TP.TYPES.onConnect)
def onConnect(data):
global twitchid
global youtubeid
global wait
twitchid = data['settings'][0]['Twitch ID']
youtubeid = data['settings'][1]['Youtube ID']
wait = data['settings'][2]['Wait Time']
print("connected")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.queuetotal", "0")
TPClient.stateUpdate(PLUGIN_ID + ".state.chatterlist.chattertotal", "0")
# Settings handler
@TPClient.on(TP.TYPES.onSettingUpdate)
def onSettingUpdate(data):
global twitchid
global youtubeid
global wait
twitchid = data["values"][0]['Twitch ID']
youtubeid = data["values"][1]['Youtube ID']
wait = data['values'][2]['Wait Time']
# Action handler
@TPClient.on(TP.TYPES.onAction)
def onAction(data):
#print(data)
global twitchid
global youtubeid
global wait
youtubename = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.youtuber.name")
queuechoice = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.queue.choice")
clearorsave = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.clear.or.save")
randomlistpickname = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.list.choice")
listclearname = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.clear")
listname = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.name")
listformat = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.listsaveformat")
addorremove = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.add.remove")
chattername = TPClient.getActionDataValue(data.get("data"),"gitago.streamextras.plugin.act.list.chatter")
ascdesc = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.asc.desc")
viewersname = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.viewer.name")
viewersname2 = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.viewer.name2")
viewersname3 = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.viewer.name3")
count = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.get.count")
choice = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.get.choice")
choice2 = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.get.choice2")
choice3 = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.get.choice3")
randomchoice = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.get.randomchoice")
number = TPClient.getActionDataValue(data.get("data"), "gitago.streamextras.plugin.act.number")
if data['actionId'] == "gitago.streamextras.plugin.act.get.game":
r = requests.get(f"https://decapi.me/twitch/game/{viewersname2}")
Game = r.text
TPClient.stateUpdate(PLUGIN_ID + ".state.gametitle", Game)
if data['actionId'] == "gitago.streamextras.plugin.act.get.youtubevideo":
if choice3 == "Youtube Video":
r = requests.get(f"https://decapi.me/youtube/latest_video?id={youtubeid}")
urlcontent = r.text
### Regex - this is everything after the -
uploadurl = re.search(r'(?<= - ).*', urlcontent)
## Regex - this is everything before the -
uploadtitle = re.search(r'.*(?= - )', urlcontent)
TPClient.stateUpdate(PLUGIN_ID + ".state.youtubevideourl", uploadurl.group(0))
TPClient.stateUpdate(PLUGIN_ID + ".state.youtubevideodescription", uploadtitle.group(0))
TPClient.stateUpdate(PLUGIN_ID + ".state.youtubevideofull", r.text)
# Action 1 Data
if data['actionId'] == "gitago.streamextras.plugin.act.get.game1":
if choice2 == "Follower(s)":
if count == "" or count == "0":
if ascdesc == "Descending":
print("ok its 0 or empty")
r = requests.get(f"https://decapi.me/twitch/followers?channel={viewersname2}&direction=desc")
TPClient.stateUpdate(PLUGIN_ID + ".state.recentchannelfollower", r.text)
if ascdesc == "Ascending":
r = requests.get(f"https://decapi.me/twitch/followers?channel={viewersname2}&direction=asc")
TPClient.stateUpdate(PLUGIN_ID + ".state.recentchannelfollower", r.text)