-
Notifications
You must be signed in to change notification settings - Fork 5
/
nakamoriplugin.py
1210 lines (986 loc) · 56.5 KB
/
nakamoriplugin.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
# -*- coding: utf-8 -*-
from lib.external_calendar import ADDON
import lib.windows.ac_calendar
from lib import kodi_utils
from lib import shoko_utils
from lib import naka_player
from lib.addon_utils import plugin
from lib.naka_utils import ThisType, map_episodetype_int_to_thistype
from models import kodi_models
from sys import argv
from lib.windows import wizard
import xbmc # type: ignore
import xbmcgui # type: ignore
from xbmcgui import ListItem # type: ignore
import xbmcaddon # type: ignore
from xbmcplugin import addDirectoryItem, endOfDirectory, addDirectoryItems # type: ignore
import lib.search as search
import lib.favorite as favorite
from operator import itemgetter
import string
plugin_addon = xbmcaddon.Addon(id='plugin.video.nakamori')
# TODO this is setthing inside Shoko that will Group Series into parent Groups (ex. Monogatari-Series)
do_we_want_to_make_eptype_setting = plugin_addon.getSettingBool('show_eptypes')
@plugin.route('/')
def list_all_filters():
"""
List all Filters for current User
:return: Draw ListItem's Collection of Filters
"""
if not plugin_addon.getSettingBool('skip_information'):
# spot for 'what's new window'
# also let's flag this information in sqlite version, mark
pass
# set_content is needed beause we will lose Skin support
kodi_models.set_content('tvshows')
kodi_models.set_sorting_method(ThisType.filter)
y = kodi_models.list_all_filters()
x = kodi_models.main_menu_items()
for extra in x:
y.append((0, ThisType.menu, extra, kodi_models.remove_markdown(extra.getLabel())))
y_count = len(y)
# sort them by name
y.sort(key=itemgetter(3))
for filter_id, f_type, li, label in y:
if label == "Tags":
li.setArt({
'fanart': f'{kodi_models.plugin_img_path}/backgrounds/tags.png',
'banners': f'{kodi_models.plugin_img_path}/banners/tags.png',
'poster': f'{kodi_models.plugin_img_path}/icons/tags.png',
'icon': f'{kodi_models.plugin_img_path}/icons/tags.png'
})
elif label == "Years":
li.setArt({
'fanart': f'{kodi_models.plugin_img_path}/backgrounds/years.png',
'banners': f'{kodi_models.plugin_img_path}/banners/years.png',
'poster': f'{kodi_models.plugin_img_path}/icons/years.png',
'icon': f'{kodi_models.plugin_img_path}/icons/years.png'
})
elif label == "Seasons":
li.setArt({
'fanart': f'{kodi_models.plugin_img_path}/backgrounds/seasons.png',
'banners': f'{kodi_models.plugin_img_path}/banners/seasons.png',
'poster': f'{kodi_models.plugin_img_path}/icons/seasons.png',
'icon': f'{kodi_models.plugin_img_path}/icons/seasons.png'
})
if f_type == ThisType.filter:
addDirectoryItem(plugin.handle, plugin.url_for(list_groups_by_filter_id, filter_id), li, True, totalItems=y_count)
elif f_type == ThisType.filters:
addDirectoryItem(plugin.handle, plugin.url_for(list_filter_by_filters_id, filter_id), li, True, totalItems=y_count)
elif f_type == ThisType.menu:
addDirectoryItem(plugin.handle, li.getPath(), li, True, totalItems=y_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/fs-<filters_id>')
def list_filter_by_filters_id(filters_id: int):
kodi_models.set_content('tvshows')
kodi_models.set_sorting_method(ThisType.filter)
y = kodi_models.list_all_filter_by_filters_id(filters_id)
y_count = len(y)
for obj_id, obj_type, li in y:
if obj_type == ThisType.filter:
addDirectoryItem(plugin.handle, plugin.url_for(list_groups_by_filter_id, obj_id), li, True, totalItems=y_count)
if obj_type == ThisType.filters:
addDirectoryItem(plugin.handle, plugin.url_for(list_filter_by_filters_id, obj_id), li, True, totalItems=y_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/f-<filter_id>')
def list_groups_by_filter_id(filter_id: int):
"""
List all Groups for current User in Filter
:param filter_id: ID of Filter that we want list content of
:return: Draw ListItem's Collection of Group
"""
kodi_models.set_content('tvshows')
if int(filter_id) == 0:
list_unsorted()
return
kodi_models.set_sorting_method(ThisType.series)
y = kodi_models.list_all_groups_by_filter_id(filter_id)
y_count = len(y)
for obj_id, obj_type, li in y:
if obj_type == ThisType.group:
addDirectoryItem(plugin.handle, plugin.url_for(open_group_by_group_id_and_filter_id, filter_id, obj_id), li, True, totalItems=y_count)
if obj_type == ThisType.series:
addDirectoryItem(plugin.handle, plugin.url_for(open_series_by_series_id_and_filter_id, filter_id, obj_id), li, True, totalItems=y_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/f-<filter_id>/g-<group_id>')
def open_group_by_group_id_and_filter_id(filter_id: int, group_id: int):
kodi_models.set_content('tvshows')
kodi_models.set_sorting_method(ThisType.series)
y = kodi_models.list_all_series_by_group_id(group_id)
y_count = len(y)
for obj_id, li in y:
addDirectoryItem(plugin.handle, plugin.url_for(open_series_by_series_id_and_filter_id, filter_id, obj_id), li, True, totalItems=y_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/f-<filter_id>/s-<series_id>')
def open_series_by_series_id_and_filter_id(filter_id: int, series_id: int):
list_of_ep_types = []
list_of_eps = []
_e, s = kodi_models.list_episodes_for_series_by_series_id(series_id)
for e in _e:
list_of_eps.append(e)
for ep_id, ep_type, li in list_of_eps:
if ep_type not in list_of_ep_types:
list_of_ep_types.append(ep_type)
first_not_watched = -1
list_items_to_add = []
if len(list_of_ep_types) > 1 and do_we_want_to_make_eptype_setting:
kodi_models.set_content('seasons')
kodi_models.set_sorting_method(ThisType.tvepisodes)
for ep_type in list_of_ep_types:
li = kodi_models.get_listitem_from_episodetype(ep_type, s.art)
addDirectoryItem(plugin.handle, plugin.url_for(open_eptype_by_eptype_by_series_id_and_filter_id, filter_id, series_id, int(ep_type)), li, True, totalItems=len(list_of_ep_types))
else:
kodi_models.set_content('episodes')
kodi_models.set_sorting_method(ThisType.episodes)
con = kodi_models.add_continue_item(series=s, episode_type=list_of_ep_types[0])
_index = 0 if con is None else 1
for ep_id, ep_type, li in list_of_eps:
_index += 1
if first_not_watched == -1 and li.getVideoInfoTag().getPlayCount() == 0:
li.select(selected=True)
first_not_watched = _index
list_items_to_add.append((plugin.url_for(open_episode, filter_id, series_id, ep_id), li, False))
if con is not None:
_con = (plugin.url_for(move_to, first_not_watched), con, False)
list_items_to_add.insert(0, _con)
addDirectoryItems(plugin.handle, list_items_to_add)
endOfDirectory(plugin.handle, cacheToDisc=False)
if len(list_of_ep_types) == 1:
kodi_utils.move_to(first_not_watched)
@plugin.route('/f-<filter_id>/s-<series_id>/et-<eptype_id>')
def open_eptype_by_eptype_by_series_id_and_filter_id(filter_id: int, series_id: int, eptype_id: int):
kodi_models.set_content('episodes')
kodi_models.set_sorting_method(ThisType.episodes)
y, s = kodi_models.list_episodes_for_series_by_series_id(series_id)
first_not_watched = -1
con = kodi_models.add_continue_item(series=s, episode_type=map_episodetype_int_to_thistype(eptype_id))
list_items_to_add = []
_index = 0 if con is None else 1
for ep_id, ep_type, li in y:
if int(ep_type) == int(eptype_id):
_index += 1
if first_not_watched == -1 and li.getVideoInfoTag().getPlayCount() == 0:
li.select(selected=True)
first_not_watched = _index
list_items_to_add.append((plugin.url_for(open_episode, filter_id, series_id, ep_id), li, False))
if con is not None:
_con = (plugin.url_for(move_to, first_not_watched), con, False)
list_items_to_add.insert(0, _con)
addDirectoryItems(plugin.handle, list_items_to_add)
endOfDirectory(plugin.handle, cacheToDisc=False)
kodi_utils.move_to(first_not_watched)
@plugin.route('/f-<filter_id>/s-<series_id>/e-<ep_id>-play/dontmark')
def open_episode_dont_mark(filter_id: int, series_id: int, ep_id: int):
play_episode(filter_id, series_id, ep_id, False)
@plugin.route('/f-<filter_id>/s-<series_id>/e-<ep_id>-play')
def open_episode(filter_id: int, series_id: int, ep_id: int):
kodi_utils.debug(f'open_episode: /f-{filter_id}/s-{series_id}/e-{ep_id}-play')
play_episode(filter_id, series_id, ep_id, True)
def play_episode(filter_id: int, series_id: int, ep_id: int, use_watch_mark: bool):
kodi_utils.debug(f'play_episode: {filter_id}, {series_id}, {ep_id}, {use_watch_mark}')
is_resume_enable = plugin_addon.getSettingBool('file_resume')
raw_files_list = kodi_models.get_file_id_from_ep_id(ep_id)
file_id = 0
if len(raw_files_list) == 1:
file_id = raw_files_list[0].id
else:
if plugin_addon.getSettingBool('pick_file'):
items = [kodi_models.get_file_name(x.filename) for x in raw_files_list]
my_file = xbmcgui.Dialog().select(plugin_addon.getLocalizedString(30196), items)
if my_file > -1:
file_id = raw_files_list[my_file].id
else:
# cancel -1,0
file_id = 0
else:
file_id = raw_files_list[0].id
if file_id != 0:
naka_player.play_video(file_id=file_id, ep_id=ep_id, s_id=series_id, force_direct_play=True, resume=is_resume_enable, mark_as_watched=use_watch_mark)
@plugin.route('/f-0/s-<series_id>/e-<ep_id>-pick')
def pick_file_and_play(series_id: int, ep_id: int):
is_resume_enable = plugin_addon.getSettingBool('file_resume')
raw_files_list = kodi_models.get_file_id_from_ep_id(ep_id)
items = [kodi_models.get_file_name(x.filename) for x in raw_files_list]
my_file = xbmcgui.Dialog().select(plugin_addon.getLocalizedString(30196), items)
if my_file > -1:
file_id = raw_files_list[my_file].id
else:
# cancel -1,0
file_id = 0
if file_id != 0:
naka_player.play_video(file_id=file_id, ep_id=ep_id, s_id=series_id, force_direct_play=True, resume=is_resume_enable, mark_as_watched=True)
@plugin.route('/f-0/r-<file_id>-play')
def open_rawfile(file_id: int):
naka_player.play_video(file_id=file_id, ep_id=0, s_id=0, force_direct_play=True)
def list_unsorted():
kodi_models.set_category('Unsort')
kodi_models.set_content('video')
x = kodi_models.list_all_unsorted()
x_count = len(x)
for r_id, r in x:
addDirectoryItem(plugin.handle, plugin.url_for(open_rawfile, r_id), r, False, totalItems=x_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/dialog/wizard/logout')
def logout_user_from_nakamori():
xbmc.executebuiltin('ReplaceWindow("10000")')
plugin_addon.setSettingString('apikey', 'set-new-apikey')
# reset apikey
pass
@plugin.route('/dialog/wizard/login')
def open_login_screen():
xbmc.executebuiltin("Dialog.Close(all, true)")
wizard.open_login_wizard()
@plugin.route('/dialog/wizard/connection')
def open_login_screen():
xbmc.executebuiltin("Dialog.Close(all, true)")
wizard.open_connection_wizard()
@plugin.route('/search')
def show_search_menu():
kodi_models.set_content('tvshows')
kodi_models.set_category(plugin_addon.getLocalizedString(30221))
# A-Z search (no keyboard needed)
li = ListItem(label=kodi_models.bold('A-Z'), offscreen=True)
kodi_models.set_art(li, None, 'search.png')
addDirectoryItem(plugin.handle, plugin.url_for(az_search), li, True)
use_fuzzy = plugin_addon.getSettingBool('use_fuzzy_search')
# Search
if not use_fuzzy:
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30224)), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, True, False, False), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30224)) + " Tag", offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, True, False, True), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30225)), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, False, False, False), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30225)) + ' Tag', offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, False, False, True), li, True)
else:
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30224) + " (Fuzzy)"), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, True, True, False), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30224) + " Tag (Fuzzy)"), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, True, True, True), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30225) + " (Fuzzy)"), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, False, True, False), li, True)
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30225) + " Tag (Fuzzy)"), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(new_search, False, True, True), li, True)
# draw search history we have saved
search_history = search.get_search_history()
search_count = len(search_history)
for ss in search_history:
query = ss[0]
fuzziness = ss[1]
taginess = ss[2]
if len(query) == 0:
continue
fuzzy = ''
if fuzziness == 1:
fuzzy = ' [fuzzy]'
tag = ''
if taginess == 1:
tag = 'tag:'
item = ListItem(label=tag + query + fuzzy, offscreen=True)
kodi_models.set_art(item, None, 'search.png')
remove_item = (plugin_addon.getLocalizedString(30204), f'RunScript(plugin.video.nakamori, /dialog/search/{query}-{fuzziness}-{taginess}/remove)')
item.addContextMenuItems([remove_item])
addDirectoryItem(plugin.handle, plugin.url_for(search_for, query, fuzziness, taginess), item, True, totalItems=search_count)
# add clear all for more than 10 items, no one wants to clear them one by one
if len(search_history) > 10:
li = ListItem(label=kodi_models.bold(plugin_addon.getLocalizedString(30224)), offscreen=True)
kodi_models.set_art(li, None, 'new-search.png')
addDirectoryItem(plugin.handle, plugin.url_for(url_clear_search_terms), li, False)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/search/<save>-<fuzzy>-<tag>')
def new_search(save: bool, fuzzy: bool, tag: bool):
fuzziness = 1 if str(fuzzy).lower() == 'true' else 0
taginess = 1 if str(tag).lower() == 'true' else 0
query = kodi_models.search_box()
if query != '':
if str(save).lower() == "true":
if search.check_in_database(query, fuzziness, taginess):
search.remove_search_history(query, fuzziness, taginess)
search.add_search_history(query, fuzziness, taginess)
search_for(query, fuzzy, tag)
else:
show_search_menu()
@plugin.route('/menu-search/<query>-<fuzzy>-<tag>')
def search_for(query: str, fuzzy: bool, tag: bool):
kodi_models.set_content('tvshows')
kodi_models.set_category(query)
fuzziness = True if str(fuzzy).lower() == 'true' else False
taginess = True if str(tag).lower() == 'true' else False
if len(query) > 0:
list_of_s = kodi_models.show_search_result_menu(query, fuzziness, taginess)
list_count = len(list_of_s)
for s in list_of_s:
addDirectoryItem(plugin.handle, plugin.url_for(open_series_by_series_id_and_filter_id, 0, s.id),
kodi_models.get_listitem_from_serie(s), True, totalItems=list_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/search/az')
def az_search():
kodi_models.set_content('tvshows')
kodi_models.set_content('A-Z')
az_count = len(string.ascii_uppercase)
for c in string.ascii_uppercase:
item = ListItem(label=c, offscreen=True)
kodi_models.set_art(item, None, 'search.png')
addDirectoryItem(plugin.handle, plugin.url_for(az_search_for, c), item, True, totalItems=az_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/menu-search/az/<characters>')
def az_search_for(characters: str):
kodi_models.set_content('tvshows')
kodi_models.set_content('A-Z')
# adding items to go "dir up" would make a backward loop while using backspace
# TODO find a good way to go 3-5 levels up without later looping with backspace or '..' item
ss = kodi_models.show_az_search_results(characters)
list_count = len(ss)
character_list = []
for s in ss:
_index = len(characters)
if len(s.match) > _index:
_new_char = s.match[_index].lower()
if _new_char not in character_list:
character_list.append(_new_char)
addDirectoryItem(plugin.handle, plugin.url_for(open_series_by_series_id_and_filter_id, 0, s.id),
kodi_models.get_listitem_from_serie(s, s.match), True, totalItems=list_count)
for new_char in character_list:
item = ListItem(label=characters + new_char, offscreen=True)
kodi_models.set_art(item, None, 'search.png')
addDirectoryItem(plugin.handle, plugin.url_for(az_search_for, characters + new_char), item, True, totalItems=list_count)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/dialog/search/clear')
def url_clear_search_terms():
search.clear_search_history()
xbmc.executebuiltin('Container.Refresh')
@plugin.route('/dialog/search/<query>-<fuzzy>-<tag>/remove')
def url_remove_search_term(query, fuzzy, tag):
search.remove_search_history(query, fuzzy, tag)
xbmc.executebuiltin('Container.Refresh')
@plugin.route('/dialog/series/<series_id>/vote')
def vote_for_series(series_id):
kodi_models.vote_for_series(int(series_id))
@plugin.route('/dialog/episode/vote/<ep_id>')
def vote_for_episode(ep_id):
kodi_models.vote_for_episode(ep_id)
@plugin.route('/dialog/refresh')
def refresh_kodi():
xbmc.executebuiltin('Container.Refresh')
@plugin.route('/favorites')
def show_favorites():
kodi_models.set_content('tvshows')
kodi_models.set_category(plugin_addon.getLocalizedString(30211))
list_of_li = kodi_models.list_all_favorites()
count_li = len(list_of_li)
for s_id, li in list_of_li:
remove_item = (plugin_addon.getLocalizedString(30213), f'RunScript(plugin.video.nakamori, /dialog/favorites/{s_id}/remove)')
li.addContextMenuItems([remove_item])
addDirectoryItem(plugin.handle, plugin.url_for(open_series_by_series_id_and_filter_id, 0, s_id), li, True, totalItems=count_li)
endOfDirectory(plugin.handle, cacheToDisc=False)
@plugin.route('/dialog/favorites/<sid>/remove')
def remove_favorite(sid):
favorite.remove_favorite(sid)
xbmc.executebuiltin('Notification(%s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30211),
plugin_addon.getLocalizedString(30213),
plugin_addon.getAddonInfo('icon')))
xbmc.executebuiltin('Container.Refresh')
@plugin.route('/dialog/favorites/<sid>/add')
def add_favorite(sid):
favorite.add_favorite(sid)
xbmc.executebuiltin('Notification(%s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30211),
plugin_addon.getLocalizedString(30212),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko')
def show_shoko():
# - AniDB (Folder)
# - Import folders (Folder)
# - TvDB (Folder)
# - MovieDB (Folder)
# - Images (Folder)
# - Trakt (Folder)
# - AVDump mismatched files (item) apiv3.avdump_mismatched_files
# - Recreate all groups (item) apiv3.recreate_all_groups
# - Sync hashes (item) apiv2.sync_hashes (apiv3.sync_hashes always returns BadRequest)
# - Update all mediainfo (item) apiv3.update_all_mediainfo
# - Update series stats (item) apiv3.update_series_stats
# kodi_models.set_content('tvshows')
# set category to '.. / Shoko'
kodi_models.set_category(plugin_addon.getLocalizedString(30115))
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
avdump_mismatched_files_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30373))
avdump_mismatched_files_li.setArt(list_item_art)
avdump_mismatched_files_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30394)}) # setting 'description'
recreate_all_groups_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30374))
recreate_all_groups_li.setArt(list_item_art)
recreate_all_groups_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30395)}) # setting 'description'
sync_hashes_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30375))
sync_hashes_li.setArt(list_item_art)
sync_hashes_li.setInfo(type="video", infoLabels={"plot": ""}) # setting 'description'
update_all_mediainfo_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30376))
update_all_mediainfo_li.setArt(list_item_art)
update_all_mediainfo_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30396)}) # setting 'description'
update_series_stats_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30377))
update_series_stats_li.setArt(list_item_art)
update_series_stats_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30397)}) # setting 'description'
directory_items = [
# AniDB (url, ListItem, isFolder)
(plugin.url_for(show_shoko_anidb_directory), ListItem(label=plugin_addon.getLocalizedString(30367)), True),
# Import folders (url, ListItem, isFolder)
(plugin.url_for(show_shoko_import_folders_directory), ListItem(label=plugin_addon.getLocalizedString(30368)), True),
# TvDB (url, ListItem, isFolder)
(plugin.url_for(show_shoko_tvdb_directory), ListItem(label=plugin_addon.getLocalizedString(30369)), True),
# MovieDB (url, ListItem, isFolder)
(plugin.url_for(show_shoko_moviedb_directory), ListItem(label=plugin_addon.getLocalizedString(30370)), True),
# Images (url, ListItem, isFolder)
(plugin.url_for(show_shoko_images_directory), ListItem(label=plugin_addon.getLocalizedString(30371)), True),
# Trakt (url, ListItem, isFolder)
(plugin.url_for(show_shoko_trakt_directory), ListItem(label=plugin_addon.getLocalizedString(30372)), True),
# AVDump mismatched files (url, ListItem, isFolder)
(plugin.url_for(shoko_avdump_mismatched_files), avdump_mismatched_files_li, False),
# Recreate all groups (url, ListItem, isFolder)
(plugin.url_for(shoko_recreate_all_groups), recreate_all_groups_li, False),
# Sync hashes (url, ListItem, isFolder)
(plugin.url_for(shoko_sync_hashes), sync_hashes_li, False),
# Update all mediainfo (url, ListItem, isFolder)
(plugin.url_for(shoko_update_all_mediainfo), update_all_mediainfo_li, False),
# Update series stats (url, ListItem, isFolder)
(plugin.url_for(shoko_update_series_stats), update_series_stats_li, False)
]
# add folders and items to 'Shoko' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/avdump_mismatched_files')
def shoko_avdump_mismatched_files():
kodi_models.shoko_avdump_mismatched_files()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30115),
plugin_addon.getLocalizedString(30373),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/recreate_all_groups')
def shoko_recreate_all_groups():
kodi_models.shoko_recreate_all_groups()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30115),
plugin_addon.getLocalizedString(30374),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/sync_hashes')
def shoko_sync_hashes():
kodi_models.shoko_sync_hashes()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30115),
plugin_addon.getLocalizedString(30375),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/update_all_mediainfo')
def shoko_update_all_mediainfo():
kodi_models.shoko_update_all_mediainfo()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30115),
plugin_addon.getLocalizedString(30376),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/update_series_stats')
def shoko_update_series_stats():
kodi_models.shoko_update_series_stats()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30115),
plugin_addon.getLocalizedString(30377),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
# # IN CASE OF - we want separate folder for Shoko actions in Shoko directory (the one in '/' route)
# # 1. uncomment this function
# # 2. add directory item in show_shoko()
# # 3. delete duplicate items
# # 4. (opt) add localized string for directory name
# @plugin.route('/shoko/shoko')
# def show_shoko_shoko_directory():
# # 'Shoko' (Folder)
# # - AVDump mismatched files (item) apiv3.avdump_mismatched_files
# # - Recreate all groups (item) apiv3.recreate_all_groups
# # - Sync hashes (item) apiv2.sync_hashes (apiv3.sync_hashes always returns BadRequest)
# # - Update all mediainfo (item) apiv3.update_all_mediainfo
# # - Update series stats (item) apiv3.update_series_stats
# kodi_models.set_content('tvshows')
# kodi_models.set_category(plugin_addon.getLocalizedString())
# directory_items = [
# # AVDump mismatched files (url, ListItem, isFolder)
# ('', ListItem(label=plugin_addon.getLocalizedString(30373)), False),
# # Recreate all groups (url, ListItem, isFolder)
# ('', ListItem(label=plugin_addon.getLocalizedString(30374)), False),
# # Sync hashes (url, ListItem, isFolder)
# ('', ListItem(label=plugin_addon.getLocalizedString(30375)), False),
# # Update all mediainfo (url, ListItem, isFolder)
# ('', ListItem(label=plugin_addon.getLocalizedString(30376)), False),
# # Update series stats (url, ListItem, isFolder)
# ('', ListItem(label=plugin_addon.getLocalizedString(30377)), False)
# ]
# # add items to 'Shoko' directory
# addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
# endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/anidb')
def show_shoko_anidb_directory():
# 'AniDB' (Folder)
# - Download missing data (item)
# - Sync votes (item)
# - Sync "My List" (item)
# - Update all info (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / AniDB'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30367)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
download_missing_data_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30378))
download_missing_data_li.setArt(list_item_art)
download_missing_data_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30398)}) # setting 'description'
sync_votes_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30379))
sync_votes_li.setArt(list_item_art)
sync_votes_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30399)}) # setting 'description'
sync_my_list_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30380))
sync_my_list_li.setArt(list_item_art)
sync_my_list_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30400)}) # setting 'description'
update_all_info_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30381))
update_all_info_li.setArt(list_item_art)
update_all_info_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30401)}) # setting 'description'
directory_items = [
# Download missing data (url, ListItem, isFolder)
(plugin.url_for(anidb_download_missing_data), download_missing_data_li, False),
# Sync votes (url, ListItem, isFolder)
(plugin.url_for(anidb_sync_votes), sync_votes_li, False),
# Sync "My List" (url, ListItem, isFolder)
(plugin.url_for(anidb_sync_my_list), sync_my_list_li, False),
# Update all info (url, ListItem, isFolder)
(plugin.url_for(anidb_update_all_info), update_all_info_li, False)
]
# add items to 'AniDB' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/anidb/download_missing_data')
def anidb_download_missing_data():
kodi_models.anidb_download_missing_data()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30367),
plugin_addon.getLocalizedString(30378),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/anidb/sync_votes')
def anidb_sync_votes():
kodi_models.anidb_sync_votes()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30367),
plugin_addon.getLocalizedString(30379),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/anidb/sync_my_list')
def anidb_sync_my_list():
kodi_models.anidb_sync_my_list()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30367),
plugin_addon.getLocalizedString(30380),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/anidb/update_all_info')
def anidb_update_all_info():
kodi_models.anidb_update_all_info()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30367),
plugin_addon.getLocalizedString(30381),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/import_folders')
def show_shoko_import_folders_directory():
# Import folders (Folder)
# - Remove missing files (item)
# - Remove missing files (keep in "My List") (item)
# - Run import (item)
# - (User import folders) (Folders)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / Import folders'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30368)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
remove_missing_files_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30382))
remove_missing_files_li.setArt(list_item_art)
remove_missing_files_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30402)}) # setting 'description'
remove_missing_files_keep_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30383))
remove_missing_files_keep_li.setArt(list_item_art)
remove_missing_files_keep_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30403)}) # setting 'description'
run_import_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30384))
run_import_li.setArt(list_item_art)
run_import_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30404)}) # setting 'description'
directory_items = [
# Remove missing files (url, ListItem, isFolder)
(plugin.url_for(import_folder_remove_missing_files), remove_missing_files_li, False),
# Remove missing files (keep in "My List") (url, ListItem, isFolder)
(plugin.url_for(import_folder_remove_missing_files_keep), remove_missing_files_keep_li, False),
# Run import (url, ListItem, isFolder)
(plugin.url_for(import_folder_run_import_all), run_import_li, False)
]
# get list items of import folders
directory_items += kodi_models.get_import_folders_items()
# add items to 'Import folders' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/import_folders/remove_missing_files')
def import_folder_remove_missing_files():
kodi_models.import_folder_remove_missing_files(True)
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30368),
plugin_addon.getLocalizedString(30382),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/import_folders/remove_missing_files_keep')
def import_folder_remove_missing_files_keep():
kodi_models.import_folder_remove_missing_files(False)
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30368),
plugin_addon.getLocalizedString(30383),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/import_folders/run_import_all')
def import_folder_run_import_all():
kodi_models.import_folders_run_import_all()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30368),
plugin_addon.getLocalizedString(30384),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/import_folders/<folder_name>-<folder_id>')
def show_shoko_user_import_folder_directory(folder_name, folder_id):
# Import folder (folder)
# - Rescan folder (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / Import folders / folder_name'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30368)} / {folder_name}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
rescan_folder_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30393))
rescan_folder_li.setArt(list_item_art)
directory_items = [
# Rescan folder (url, ListItem, isFolder)
(plugin.url_for(user_import_folder_rescan, folder_name, folder_id), rescan_folder_li, False),
]
# add items to this user's import folder directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/import_folders/<folder_name>-<folder_id>/rescan')
def user_import_folder_rescan(folder_name, folder_id):
kodi_models.user_import_folder_rescan(folder_id)
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (folder_name,
plugin_addon.getLocalizedString(30393),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/tvdb')
def show_shoko_tvdb_directory():
# TvDB (Folder)
# - Regenerate links (item)
# - Update all info (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / TvDB'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30369)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
regenerate_links_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30385))
regenerate_links_li.setArt(list_item_art)
regenerate_links_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30405)}) # setting 'description'
update_all_info_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30386))
update_all_info_li.setArt(list_item_art)
update_all_info_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30406)}) # setting 'description'
directory_items = [
# Regenerate links (url, ListItem, isFolder)
(plugin.url_for(tvdb_regenerate_links), regenerate_links_li, False),
# Update all info (url, ListItem, isFolder)
(plugin.url_for(tvdb_update_all_info), update_all_info_li, False)
]
# add items to 'TvDB' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/tvdb/regenerate_links')
def tvdb_regenerate_links():
kodi_models.tvdb_regenerate_links()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30369),
plugin_addon.getLocalizedString(30385),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/tvdb/update_all_info')
def tvdb_update_all_info():
kodi_models.tvdb_update_all_info()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30369),
plugin_addon.getLocalizedString(30386),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/moviedb')
def show_shoko_moviedb_directory():
# MovieDB (Folder)
# - Update all info (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / MovieDB'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30370)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
update_all_info_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30387))
update_all_info_li.setArt(list_item_art)
update_all_info_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30407)}) # setting 'description'
directory_items = [
# Update all info (url, ListItem, isFolder)
(plugin.url_for(moviedb_update_all_info), update_all_info_li, False)
]
# add items to 'MovieDB' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/moviedb/update_all_info')
def moviedb_update_all_info():
kodi_models.moviedb_update_all_info()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30370),
plugin_addon.getLocalizedString(30387),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/images')
def show_shoko_images_directory():
# Images (Folder)
# - Update all (item)
# - Validate all (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / Images'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30371)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
update_all_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30388))
update_all_li.setArt(list_item_art)
update_all_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30408)}) # setting 'description'
validate_all_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30389))
validate_all_li.setArt(list_item_art)
validate_all_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30409)}) # setting 'description'
directory_items = [
# Update all (url, ListItem, isFolder)
(plugin.url_for(images_update_all), update_all_li, False),
# Validate all (url, ListItem, isFolder)
(plugin.url_for(images_validate_all), validate_all_li, False)
]
# add items to 'Images' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)
@plugin.route('/shoko/images/update_all')
def images_update_all():
kodi_models.images_update_all()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30371),
plugin_addon.getLocalizedString(30388),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/images/validate_all')
def images_validate_all():
kodi_models.images_validate_all()
xbmc.executebuiltin('Notification(%s / %s, %s, 7500, %s)' % (plugin_addon.getLocalizedString(30371),
plugin_addon.getLocalizedString(30389),
plugin_addon.getLocalizedString(30392),
plugin_addon.getAddonInfo('icon')))
@plugin.route('/shoko/trakt')
def show_shoko_trakt_directory():
# Trakt (Folder)
# - Sync Trakt collection (item)
# - Update all info (item)
# kodi_models.set_content('tvshows')
# set category to ' .. / Shoko / Trakt'
kodi_models.set_category(f'{plugin_addon.getLocalizedString(30115)} / {plugin_addon.getLocalizedString(30372)}')
list_item_art = {
'poster': f'{kodi_models.plugin_img_path}/icons/command.png',
'icon': f'{kodi_models.plugin_img_path}/icons/command.png'
}
sync_trakt_collection_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30390))
sync_trakt_collection_li.setArt(list_item_art)
sync_trakt_collection_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30410)}) # setting 'description'
update_all_info_li = xbmcgui.ListItem(label=plugin_addon.getLocalizedString(30391))
update_all_info_li.setArt(list_item_art)
update_all_info_li.setInfo(type="video", infoLabels={"plot": plugin_addon.getLocalizedString(30411)}) # setting 'description'
directory_items = [
# Sync Trakt collection (url, ListItem, isFolder)
(plugin.url_for(trakt_sync_trakt_collection), sync_trakt_collection_li, False),
# Update all info (url, ListItem, isFolder)
(plugin.url_for(trakt_update_all_info), update_all_info_li, False)
]
# add items to 'Trakt' directory
addDirectoryItems(handle=plugin.handle, items=directory_items, totalItems=directory_items.__len__())
endOfDirectory(handle=plugin.handle, cacheToDisc=False)