This repository has been archived by the owner on Apr 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
/
addon.py
executable file
·2365 lines (2180 loc) · 156 KB
/
addon.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
#Internet Archive ROM Launcher
#Zach Morris
#https://github.com/zach-morris/plugin.program.iarl
from resources.lib.xbmcswift2b import Plugin
from resources.lib.xbmcswift2b import actions
from resources.lib.xbmcswift2b import ListItem as LI
import os, sys, subprocess, xbmc, xbmcgui, xbmcaddon
from resources.lib.util import *
from resources.lib.webutils import *
import resources.lib.paginate as paginate
xbmc.log(msg='IARL: Lets Play!', level=xbmc.LOGNOTICE)
#Initialize Stuff
plugin = Plugin()
try: #Added for even more viewtypes depending on the skin
if plugin.get_setting('iarl_setting_setcontent',unicode) != 'None':
xbmcplugin.setContent(int(sys.argv[1]),str(plugin.get_setting('iarl_setting_setcontent',unicode)))
except:
xbmc.log(msg='IARL: Unable to set content type', level=xbmc.LOGDEBUG)
iarl_data = {
'settings' : { 'cache_list' : plugin.get_setting('iarl_setting_cache_list',bool),
'clean_list' : plugin.get_setting('iarl_setting_clean_list',bool),
'listing_convention' : plugin.get_setting('iarl_setting_listing',unicode),
'naming_convention' : plugin.get_setting('iarl_setting_naming',unicode),
'items_per_page_setting' : None, #Initialize variable and set later
'iarl_setting_history' : plugin.get_setting('iarl_setting_history',int),
'local_file_action' : plugin.get_setting('iarl_setting_localfile_action',unicode),
'game_select_action' : plugin.get_setting('iarl_setting_default_action',unicode),
'show_search_item' : None, #Initialize variable and set later
'show_randomplay_item' : None, #Initialize variable and set later
'show_history_item' : None, #Initialize variable and set later
'show_extras_item' : None, #Initialize variable and set later
'autoplay_trailer' : plugin.get_setting('iarl_setting_autoplay_trailer',unicode),
'download_cache' : None, #Initialize variable and set later
'ia_enable_login' : None, #Initialize variable and set later
'ia_username' : plugin.get_setting('iarl_setting_ia_username',unicode),
'ia_password' : plugin.get_setting('iarl_setting_ia_password',unicode),
'external_launch_env' : plugin.get_setting('iarl_external_user_external_env',unicode),
'external_launch_close_kodi' : plugin.get_setting('iarl_external_launch_close_kodi',unicode),
'path_to_retroarch' : xbmc.translatePath(plugin.get_setting('iarl_path_to_retroarch',unicode)),
'path_to_retroarch_system_dir' : xbmc.translatePath(plugin.get_setting('iarl_path_to_retroarch_system_dir',unicode)),
'path_to_retroarch_cfg' : xbmc.translatePath(plugin.get_setting('iarl_path_to_retroarch_cfg',unicode)),
'enable_additional_emulators' : [plugin.get_setting('iarl_additional_emulator_1_type',unicode),plugin.get_setting('iarl_additional_emulator_2_type',unicode),plugin.get_setting('iarl_additional_emulator_3_type',unicode)],
'path_to_additional_emulators' : [xbmc.translatePath(plugin.get_setting('iarl_additional_emulator_1_path',unicode)),xbmc.translatePath(plugin.get_setting('iarl_additional_emulator_2_path',unicode)),xbmc.translatePath(plugin.get_setting('iarl_additional_emulator_3_path',unicode))],
'enable_netplay' : None, #Initialize variable and set later
'netplay_host_or_client' : plugin.get_setting('iarl_netplay_hostclient',unicode),
'netplay_host_nickname' : plugin.get_setting('iarl_netplay_nickname1',unicode),
'netplay_client_nickname' : plugin.get_setting('iarl_netplay_nickname2',unicode),
'netplay_spectator_nickname' : plugin.get_setting('iarl_netplay_nickname3',unicode),
'netplay_host_IP' : plugin.get_setting('iarl_netplay_IP',unicode),
'netplay_host_port' : plugin.get_setting('iarl_netplay_port',unicode),
'netplay_sync_frames' : None, #Initialize variable and set later
'enable_postdl_edit' : None, #Initialize variable and set later
'hidden_setting_clear_cache_value' : plugin.get_setting('iarl_setting_clear_cache_value',bool),
'hidden_setting_clear_hidden_archives' : plugin.get_setting('iarl_setting_clear_hidden_archives',bool),
'hidden_setting_warn_chd' : plugin.get_setting('iarl_setting_warn_chd',bool),
'hidden_setting_warn_iso' : plugin.get_setting('iarl_setting_warn_iso',bool),
'hidden_setting_tou_agree' : plugin.get_setting('iarl_setting_tou',bool),
'launch_with_subprocess' : plugin.get_setting('iarl_setting_subprocess_launch',bool),
'hard_code_favorite_settings' : plugin.get_setting('iarl_setting_favorite_hard_code',bool),
'hard_coded_include_back_link' : plugin.get_setting('iarl_setting_back_link_hard_code',bool),
},
'addon_data':{ 'plugin_name' : 'plugin.program.iarl',
'log_level' : 'LOG_LEVEL_INFO',
'operating_system' : get_operating_system(),
'addon_media_path' : get_media_files_path(),
'addon_skin_path' : get_skin_files_path(),
'addon_dat_path' : get_XML_files_path(),
'addon_temp_dl_path' : get_userdata_temp_dir(),
'addon_list_cache_path' : get_userdata_list_cache_dir(),
'addon_install_path' : get_addon_install_path(),
'addon_bin_path' : get_addondata_bindir(),
'7za_path' : None,
'chdman_path' : None,
'default_icon' : 'arcade_default_box.jpg',
'default_header_color' : 'white.png',
'default_bg_color' : 'black.png',
'default_buttonfocustheme' : 'button-highlight1.png',
'default_buttonnofocustheme' : 'button-nofocus2.png',
},
'archive_data': None,
'current_archive_data':{'xml_id' : None,
'page_id' : None,
'emu_name' : None,
'emu_base_url' : None,
'emu_homepage' : None,
'emu_filepath' : None,
'emu_parser' : None,
'emu_category' : None,
'emu_version' : None,
'emu_date' : None,
'emu_author' : None,
'emu_description' : None,
'emu_plot' : None,
'emu_boxart' : None,
'emu_banner' : None,
'emu_fanart' : None,
'emu_logo' : None,
'emu_trailer' : None,
'emu_download_path' : None,
'emu_post_download_action' : None,
'emu_launcher' : None,
'emu_ext_launch_cmd' : None,
'total_num_archives' : None,
'emu_total_num_games' : None,
'category_id' : None,
'header_color' : None,
'background_color' : None,
'button_focus' : None,
'button_nofocus' : None,
},
'current_rom_data':{'rom_label' : None,
'rom_name' : None,
'rom_icon' : None,
'rom_thumbnail' : None,
'rom_title' : None,
'rom_filenames' : list(),
'rom_save_filenames' : list(),
'rom_supporting_filenames' : list(),
'rom_save_supporting_filenames' : list(),
'rom_emu_command' : None,
'rom_override_cmd' : None,
'rom_override_postdl' : None,
'rom_override_downloadpath' : None,
'rom_size' : list(),
'rom_plot' : None,
'rom_date' : None,
'rom_year' : None,
'rom_studio' : None,
'rom_genre' : None,
'rom_nplayers' : None,
'rom_tag' : None,
'rom_rating' : None,
'rom_perspective' : None,
'rom_esrb' : None,
'rom_trailer' : None,
'rom_boxarts' : [None,None,None,None,None,None,None,None,None,None],
'rom_snapshots' : [None,None,None,None,None,None,None,None,None,None],
'rom_fanarts' : [None,None,None,None,None,None,None,None,None,None],
'rom_banners' : [None,None,None,None,None,None,None,None,None,None],
'rom_logos' : [None,None,None,None,None,None,None,None,None,None],
},
'current_save_data':{'rom_save_filenames' : list(),
'rom_save_filenames_exist' : list(),
'matching_rom_save_filenames' : list(),
'rom_save_filenames_success' : list(),
'rom_supporting_filenames' : list(),
'rom_save_supporting_filenames' : list(),
'rom_save_supporting_filenames_exist' : list(),
'matching_rom_save_supporting_filenames' : list(),
'rom_save_supporting_filenames_success' : list(),
'rom_converted_filenames' : list(),
'rom_converted_filenames_success' : list(),
'rom_converted_supporting_filenames' : list(),
'rom_converted_supporting_filenames_success' : list(),
'overall_download_success' : True,
'overall_conversion_success' : True,
'overwrite_existing_files' : False,
'launch_filename' : None,
},
}
#Define number of items to display per page
items_pp_options = {'10':10,'25':25,'50':50,'100':100,'150':150,'200':200,'250':250,'300':300,'350':350,'400':400,'450':450,'500':500,'List All':99999}
try:
iarl_data['settings']['items_per_page_setting'] = items_pp_options[plugin.get_setting('iarl_setting_items_pp',unicode)]
except ValueError:
iarl_data['settings']['items_per_page_setting'] = 99999 #Default to All if not initialized correctly
if iarl_data['settings']['items_per_page_setting'] is None:
iarl_data['settings']['items_per_page_setting'] = 99999 #Default to All if not initialized correctly
#Define temp download cache size
cache_options = {'Zero (One ROM and Supporting Files Only)':0,'10 MB':10*1e6,'25MB':25*1e6,'50MB':50*1e6,'100MB':100*1e6,'150MB':150*1e6,'200MB':200*1e6,'250MB':250*1e6,'300MB':300*1e6,'350MB':350*1e6,'400MB':400*1e6,'450MB':450*1e6,'500MB':500*1e6,'1GB':1000*1e6,'2GB':2000*1e6,'5GB':5000*1e6,'10GB':10000*1e6,'20GB':20000*1e6}
try:
iarl_data['settings']['download_cache'] = cache_options[plugin.get_setting('iarl_setting_dl_cache',unicode)]
except ValueError:
iarl_data['settings']['download_cache'] = 0 #Default to 0 if not initialized correctly
if iarl_data['settings']['download_cache'] is None:
iarl_data['settings']['download_cache'] = 0 #Default to 0 if not initialized correctly
#Convert Show/Hide to True/False
show_hide_options = {'Show':True,'Hide':False}
try:
iarl_data['settings']['show_search_item'] = show_hide_options[plugin.get_setting('iarl_setting_show_search',unicode)]
except ValueError:
iarl_data['settings']['show_search_item'] = True #Default to True if not initialized correctly
if iarl_data['settings']['show_search_item'] is None:
iarl_data['settings']['show_search_item'] = True #Default to True if not initialized correctly
try:
iarl_data['settings']['show_randomplay_item'] = show_hide_options[plugin.get_setting('iarl_setting_show_randomplay',unicode)]
except ValueError:
iarl_data['settings']['show_randomplay_item'] = True #Default to True if not initialized correctly
if iarl_data['settings']['show_randomplay_item'] is None:
iarl_data['settings']['show_randomplay_item'] = True #Default to True if not initialized correctly
try:
iarl_data['settings']['show_history_item'] = show_hide_options[plugin.get_setting('iarl_setting_show_gamehistory',unicode)]
except ValueError:
iarl_data['settings']['show_history_item'] = True #Default to True if not initialized correctly
if iarl_data['settings']['show_history_item'] is None:
iarl_data['settings']['show_history_item'] = True #Default to True if not initialized correctly
try:
iarl_data['settings']['show_extras_item'] = show_hide_options[plugin.get_setting('iarl_setting_show_extras',unicode)]
except ValueError:
iarl_data['settings']['show_extras_item'] = True #Default to True if not initialized correctly
if iarl_data['settings']['show_extras_item'] is None:
iarl_data['settings']['show_extras_item'] = True #Default to True if not initialized correctly
#Convert Enabled/Disabled to True/False
enabled_disabled_options = {'Enabled':True,'Disabled':False}
try:
iarl_data['settings']['enable_netplay'] = enabled_disabled_options[plugin.get_setting('iarl_enable_netplay',unicode)]
except ValueError:
iarl_data['settings']['enable_netplay'] = False #Default to False if not initialized correctly
if iarl_data['settings']['enable_netplay'] is None:
iarl_data['settings']['enable_netplay'] = False #Default to False if not initialized correctly
try:
iarl_data['settings']['netplay_sync_frames'] = enabled_disabled_options[plugin.get_setting('iarl_netplay_frames',unicode)]
except ValueError:
iarl_data['settings']['netplay_sync_frames'] = False #Default to False if not initialized correctly
if iarl_data['settings']['netplay_sync_frames'] is None:
iarl_data['settings']['netplay_sync_frames'] = False #Default to False if not initialized correctly
try:
iarl_data['settings']['ia_enable_login'] = enabled_disabled_options[plugin.get_setting('iarl_enable_login',unicode)]
except ValueError:
iarl_data['settings']['ia_enable_login'] = False #Default to False if not initialized correctly
if iarl_data['settings']['ia_enable_login'] is None:
iarl_data['settings']['ia_enable_login'] = False #Default to False if not initialized correctly
try:
iarl_data['settings']['enable_postdl_edit'] = enabled_disabled_options[plugin.get_setting('iarl_enable_post_dl_edit',unicode)]
except ValueError:
iarl_data['settings']['enable_postdl_edit'] = False #Default to False if not initialized correctly
if iarl_data['settings']['enable_postdl_edit'] is None:
iarl_data['settings']['enable_postdl_edit'] = False #Default to False if not initialized correctly
#Define path to 7za binary
if xbmc.getCondVisibility('System.HasAddon(virtual.system-tools)'):
try:
iarl_data['addon_data']['7za_path'] = xbmc.translatePath('special://home/addons/virtual.system-tools/bin/7za')
xbmc.log(msg='IARL: 7ZA Path was found in virtual.system-tools', level=xbmc.LOGDEBUG)
except:
xbmc.log(msg='IARL: virtual.system-tools was found but the path could not be defined', level=xbmc.LOGDEBUG)
else:
if 'OSX' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.OSX')
elif 'Windows' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.exe')
elif 'Nix' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.Nix')
elif 'OpenElec RPi' in iarl_data['addon_data']['operating_system'] or 'LibreElec RPi' in iarl_data['addon_data']['operating_system'] or 'LibreElec SX05' in iarl_data['addon_data']['operating_system']:
try:
if 'v7' in os.uname()[4]:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.armv7l')
else:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.armv6l')
except:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.armv6l')
elif 'Android' in iarl_data['addon_data']['operating_system']: #Android. Your walled garden is confusing and generally sucks balls...
if os.path.isdir('/data/data/org.xbmc.kodi/lib'):
if not os.path.isfile('/data/data/org.xbmc.kodi/lib/7z.android'):
try:
copyFile(os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7z.android'),'/data/data/org.xbmc.kodi/lib/7z.android')
xbmc.log(msg='IARL: 7za was copied to /data/data/org.xbmc.kodi/lib/7z.android', level=xbmc.LOGDEBUG)
except:
xbmc.log(msg='IARL: Unable to copy 7z to /data/data/org.xbmc.kodi/lib/7z.android', level=xbmc.LOGDEBUG)
try:
os.chmod('/data/data/org.xbmc.kodi/lib/7z.android', 0555)
# os.chmod('/data/data/org.xbmc.kodi/lib/7z.android', os.stat('/data/data/org.xbmc.kodi/lib/7z.android').st_mode | 0o111)
iarl_data['addon_data']['7za_path'] = '/data/data/org.xbmc.kodi/lib/7z.android'
except:
xbmc.log(msg='IARL: chmod failed for /data/data/org.xbmc.kodi/lib/7z.android', level=xbmc.LOGDEBUG)
iarl_data['addon_data']['7za_path'] = None
xbmc.log(msg='IARL: 7Z Path could not be defined', level=xbmc.LOGDEBUG)
else:
try:
os.chmod('/data/data/org.xbmc.kodi/lib/7z.android', os.stat('/data/data/org.xbmc.kodi/lib/7z.android').st_mode | 0o111)
iarl_data['addon_data']['7za_path'] = '/data/data/org.xbmc.kodi/lib/7z.android'
except:
xbmc.log(msg='IARL: chmod failed for /data/data/org.xbmc.kodi/lib/7z.android', level=xbmc.LOGDEBUG)
iarl_data['addon_data']['7za_path'] = None
xbmc.log(msg='IARL: 7Z Path could not be defined', level=xbmc.LOGDEBUG)
else: #The normal location isnt available, need to try and install the 7za binary in the kodi root dir-http://forum.kodi.tv/showthread.php?tid=231642
if not os.path.isfile(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')):
try:
copyFile(os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7z.android'),os.path.join(xbmc.translatePath('special://xbmc'),'7z.android'))
xbmc.log(msg='IARL: 7za was copied to '+str(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')), level=xbmc.LOGDEBUG)
except:
xbmc.log(msg='IARL: Unable to copy 7za to '+str(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')), level=xbmc.LOGDEBUG)
try:
os.chmod(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android'), os.stat(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')).st_mode | 0o111)
iarl_data['addon_data']['7za_path'] = os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')
except:
xbmc.log(msg='IARL: chmod failed for '+str(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')), level=xbmc.LOGDEBUG)
iarl_data['addon_data']['7za_path'] = None
xbmc.log(msg='IARL: 7ZA Path could not be defined', level=xbmc.LOGDEBUG)
else:
try:
os.chmod(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android'), os.stat(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')).st_mode | 0o111)
iarl_data['addon_data']['7za_path'] = os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')
except:
xbmc.log(msg='IARL: chmod failed for '+str(os.path.join(xbmc.translatePath('special://xbmc'),'7z.android')), level=xbmc.LOGDEBUG)
iarl_data['addon_data']['7za_path'] = None
xbmc.log(msg='IARL: 7ZA Path could not be defined', level=xbmc.LOGDEBUG)
elif 'OpenElec x86' in iarl_data['addon_data']['operating_system'] or 'LibreElec x86' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['7za_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'7za','7za.x86_64')
else:
iarl_data['addon_data']['7za_path'] = None
xbmc.log(msg='IARL: 7ZA Path could not be defined', level=xbmc.LOGDEBUG)
if iarl_data['addon_data']['7za_path'] is not None:
xbmc.log(msg='IARL: 7ZA Path is defined as '+str(iarl_data['addon_data']['7za_path']), level=xbmc.LOGDEBUG)
#Define path to CHDMAN binary
if 'OSX' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['chdman_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'chdman','chdman.OSX')
elif 'Windows' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['chdman_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'chdman','chdman.exe')
elif 'Nix' in iarl_data['addon_data']['operating_system']:
iarl_data['addon_data']['chdman_path'] = os.path.join(iarl_data['addon_data']['addon_bin_path'],'chdman','chdman.Nix')
else:
iarl_data['addon_data']['chdman'] = None
xbmc.log(msg='IARL: CHDMAN Path could not be defined', level=xbmc.LOGDEBUG)
#If cache list is false, then clear the listed cache every time the addon is run
if not iarl_data['settings']['cache_list']:
try:
plugin.clear_function_cache()
except:
pass
#If the advanced setting action 'Clear Addon Cache' was set, then run this one time clear cache function
if iarl_data['settings']['hidden_setting_clear_cache_value']:
advanced_setting_action_clear_cache(plugin)
#If the advanced setting action 'Unhide All Archives' was set, then run this one time clear hidden archives function
if iarl_data['settings']['hidden_setting_clear_hidden_archives']:
unhide_all_archives(plugin)
xbmcaddon.Addon(id='plugin.program.iarl').setSetting(id='iarl_setting_clear_hidden_archives',value='false')
xbmc.log(msg='IARL: Unhide All Archives set back to false', level=xbmc.LOGDEBUG)
#When addon is initialized, get all available archive infos
iarl_data['archive_data'] = get_archive_info()
##Start of Addon Routes
#Update XML Value (Context Menu Item)
@plugin.route('/update_xml/<xml_id>')
def update_xml_value(xml_id):
args_in = plugin.request.args
try:
tag_value = args_in['tag_value'][0]
except:
tag_value = None
if tag_value is None:
try:
tag_value = sys.argv[2].split('=')[-1]
except:
tag_value = None
try:
current_xml_name = str(os.path.split(xml_id)[-1])
except:
current_xml_name = str(xml_id)
if tag_value == 'emu_downloadpath':
xbmc.log(msg='IARL: Updating archive download path for: '+str(xml_id), level=xbmc.LOGDEBUG)
set_new_dl_path(xml_id,plugin)
elif tag_value == 'emu_postdlaction':
xbmc.log(msg='IARL: Updating archive post download action for: '+str(xml_id), level=xbmc.LOGDEBUG)
set_new_post_dl_action(xml_id,plugin)
elif tag_value == 'emu_launcher':
xbmc.log(msg='IARL: Updating internal/external emulator launcher for: '+str(xml_id), level=xbmc.LOGDEBUG)
set_new_emu_launcher(xml_id,plugin)
elif tag_value == 'emu_ext_launch_cmd':
xbmc.log(msg='IARL: Updating external launch command for: '+str(xml_id), level=xbmc.LOGDEBUG)
update_external_launch_commands(iarl_data,xml_id,plugin)
elif tag_value == 'emu_launch_cmd_review':
xbmc.log(msg='IARL: Showing launch command for: '+str(xml_id), level=xbmc.LOGDEBUG)
review_archive_launch_commands(xml_id)
elif tag_value == 'hide_archive':
xbmc.log(msg='IARL: Updating archive visibility for: '+str(xml_id), level=xbmc.LOGDEBUG)
hide_selected_archive(iarl_data,xml_id,plugin)
elif tag_value == 'refresh_archive_cache':
xbmc.log(msg='IARL: Refreshing list_cache for: '+str(xml_id), level=xbmc.LOGDEBUG)
if iarl_data['archive_data'] is None:
iarl_data['archive_data'] = get_archive_info()
try:
cache_category_id = iarl_data['archive_data']['category_id'][iarl_data['archive_data']['emu_filepath'].index(xml_id)]
clear_cache_success = delete_userdata_list_cache_file(cache_category_id)
except:
xbmc.log(msg='IARL: Unable to clear list_cache for: '+str(xml_id), level=xbmc.LOGERROR)
if clear_cache_success:
current_dialog = xbmcgui.Dialog()
ok_ret = current_dialog.ok('Complete','Archive Listing Refreshed')
elif tag_value == 'update_favorite_metadata':
xbmc.log(msg='IARL: Updating Favorites metadata for: '+str(xml_id), level=xbmc.LOGDEBUG)
current_dialog = xbmcgui.Dialog()
ret1 = current_dialog.select('Update Favorite Metadata for '+current_xml_name, ['Title','Description','Author','Thumbnail URL','Banner URL','Fanart URL','Logo URL','Youtube Trailer'])
if ret1 == 0: #Update Title
xbmc.log(msg='IARL: Updating Favorites title for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new title:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),0)
elif ret1 == 1: #Update Description
xbmc.log(msg='IARL: Updating Favorites description for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new description:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n','[CR]').replace('\r','[CR]').replace('<',' ').replace('>',' '),1)
elif ret1 == 2: #Update Author
xbmc.log(msg='IARL: Updating Favorites author for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new author:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),2)
elif ret1 == 3: #Update Thumbnail
xbmc.log(msg='IARL: Updating Favorites Thumbnail URL for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new Thumbnail URL:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),3)
elif ret1 == 4: #Update Banner
xbmc.log(msg='IARL: Updating Favorites Banner URL for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new Banner URL:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),4)
elif ret1 == 5: #Update Fanart
xbmc.log(msg='IARL: Updating Favorites Fanart URL for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new Fanart URL:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),5)
elif ret1 == 6: #Update Logo
xbmc.log(msg='IARL: Updating Favorites Logo URL for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new Logo URL:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),6)
elif ret1 == 7: #Update Video
xbmc.log(msg='IARL: Updating Favorites Video ID for: '+str(xml_id), level=xbmc.LOGDEBUG)
new_xml_text = current_dialog.input('Enter a new YouTube URL:')
set_new_favorite_metadata(xml_id,new_xml_text.replace('\n',' ').replace('\r',' ').replace('<',' ').replace('>',' '),7)
elif ret1 == -1: #Cancelled
xbmc.log(msg='IARL: Updating Favorites metadata was cancelled', level=xbmc.LOGDEBUG)
else: #Unknown
xbmc.log(msg='IARL: Unknown selection for metadata update for: '+str(xml_id), level=xbmc.LOGERROR)
elif tag_value == 'share_favorites_list':
xbmc.log(msg='IARL: Share Favorites List started for: '+str(xml_id), level=xbmc.LOGDEBUG)
share_my_iarl_favorite(xml_id)
else:
xbmc.log(msg='IARL: Context menu selection is not defined', level=xbmc.LOGERROR)
pass #Do Nothing
def update_context(xml_id_in,tag_value_in,context_label):
new_url = plugin.url_for('update_xml_value', xml_id=xml_id_in, tag_value = tag_value_in)
return (context_label, actions.background(new_url))
#Add Favorite (Context Menu Item)
@plugin.route('/update_favorites/<item_string>')
def update_favorite_items(item_string):
ystr = lambda s: s if len(s) > 0 else None
if iarl_data['archive_data'] is None:
iarl_data['archive_data'] = get_archive_info()
iarl_data['current_rom_data']['rom_name'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_name)'))
iarl_data['current_rom_data']['rom_icon'] = ystr(xbmc.getInfoLabel('ListItem.Icon'))
iarl_data['current_rom_data']['rom_thumbnail'] = ystr(xbmc.getInfoLabel('ListItem.Thumb'))
iarl_data['current_rom_data']['rom_title'] = ystr(xbmc.getInfoLabel('ListItem.Title'))
iarl_data['current_rom_data']['rom_studio'] = ystr(xbmc.getInfoLabel('ListItem.Studio'))
iarl_data['current_rom_data']['rom_genre'] = ystr(xbmc.getInfoLabel('ListItem.Genre'))
iarl_data['current_rom_data']['rom_date'] = ystr(xbmc.getInfoLabel('ListItem.Date'))
iarl_data['current_rom_data']['rom_year'] = ystr(xbmc.getInfoLabel('ListItem.Year'))
iarl_data['current_rom_data']['rom_plot'] = ystr(xbmc.getInfoLabel('ListItem.Plot'))
iarl_data['current_rom_data']['rom_trailer'] = ystr(xbmc.getInfoLabel('ListItem.Trailer'))
iarl_data['current_rom_data']['rom_tag'] = ystr(xbmc.getInfoLabel('ListItem.Property(tag)'))
iarl_data['current_rom_data']['rom_nplayers'] = ystr(xbmc.getInfoLabel('ListItem.Property(nplayers)'))
iarl_data['current_rom_data']['rom_rating'] = ystr(xbmc.getInfoLabel('ListItem.Property(rating)'))
iarl_data['current_rom_data']['rom_esrb'] = ystr(xbmc.getInfoLabel('ListItem.Property(esrb)'))
iarl_data['current_rom_data']['rom_perspective'] = ystr(xbmc.getInfoLabel('ListItem.Property(perspective)'))
iarl_data['current_rom_data']['rom_label'] = ystr(xbmc.getInfoLabel('ListItem.Label'))
iarl_data['current_rom_data']['emu_ext_launch_cmd'] = ystr(xbmc.getInfoLabel('ListItem.Property(emu_ext_launch_cmd)')) #Needed to add this for xml favorites
iarl_data['current_rom_data']['emu_post_download_action'] = ystr(xbmc.getInfoLabel('ListItem.Property(emu_post_download_action)')) #Needed to add this for xml favorites
iarl_data['current_rom_data']['emu_download_path'] = ystr(xbmc.getInfoLabel('ListItem.Property(emu_download_path)')) #Needed to add this for xml favorites
if not iarl_data['settings']['hard_code_favorite_settings']: #Only provide link path to original XML
xbmc.log(msg='IARL: Generating IARL Favorite with plugin:// link', level=xbmc.LOGDEBUG)
iarl_data['current_rom_data']['rom_filenames'] = [ystr(xbmc.getInfoLabel('ListItem.FolderPath'))]
else: #Hard code settings into favorites XML
xbmc.log(msg='IARL: Generating IARL Favorite with hardcoded settings', level=xbmc.LOGDEBUG)
iarl_data['current_rom_data']['rom_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_supporting_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_supporting_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_save_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_supporting_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_save_supporting_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_emu_command'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_emu_command)'))
try:
iarl_data['current_rom_data']['rom_override_cmd'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_cmd)'))
except:
iarl_data['current_rom_data']['rom_override_cmd'] = None
try:
iarl_data['current_rom_data']['rom_override_postdl'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_postdl)'))
except:
iarl_data['current_rom_data']['rom_override_postdl'] = None
try:
iarl_data['current_rom_data']['rom_override_downloadpath'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_downloadpath)'))
except:
iarl_data['current_rom_data']['rom_override_downloadpath'] = None
iarl_data['current_rom_data']['rom_size'] = [int(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_file_sizes)').split(',')] #Split into list, convert to int
for ii in range(0,total_arts):
iarl_data['current_rom_data']['rom_fanarts'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(fanart'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_boxarts'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(boxart'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_banners'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(banner'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_snapshots'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(snapshot'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_logos'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(logo'+str(ii+1)+')'))
favorites_xml_filename = query_favorites_xml(iarl_data) #Find all the current favorite xml files, prompt for which to use, or make a new one
if favorites_xml_filename is not None:
try:
add_success = add_favorite_to_xml(iarl_data,favorites_xml_filename)
if add_success:
current_dialog = xbmcgui.Dialog()
ok_ret = current_dialog.ok('Complete','Favorite Added:[CR]'+str(iarl_data['current_rom_data']['rom_name']))
xbmc.log(msg='IARL: Favorite was added: '+str(iarl_data['current_rom_data']['rom_name']), level=xbmc.LOGNOTICE)
except:
xbmc.log(msg='IARL: There was an error adding the favorite '+str(iarl_data['current_rom_data']['rom_name']), level=xbmc.LOGERROR)
if add_success:
try:
cache_category_id = iarl_data['archive_data']['category_id'][iarl_data['archive_data']['emu_filepath'].index(favorites_xml_filename)]
clear_cache_success = delete_userdata_list_cache_file(cache_category_id)
except:
xbmc.log(msg='IARL: Unable to clear list_cache for the favorite list', level=xbmc.LOGERROR)
def update_context_favorite(item_in,context_label):
new_url = plugin.url_for('update_favorite_items', item_string=item_in)
return (context_label, actions.background(new_url))
## Main Start/Index Page of Addon
@plugin.route('/')
def index():
items = []
initialize_userdata()
if iarl_data['archive_data'] is None:
iarl_data['archive_data'] = get_archive_info()
if len(iarl_data['archive_data']['emu_name'])<1: #This is a first run issue, check archive_data
iarl_data['archive_data'] = get_archive_info()
for ii in range(0,iarl_data['archive_data']['total_num_archives']):
#Generate the context menu
if iarl_data['settings']['enable_postdl_edit']:
context_menus = [update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_downloadpath','Update Download Path'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_postdlaction','Update Post DL Action'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_launcher','Update Launcher'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_ext_launch_cmd','Update Ext Launcher Command'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_launch_cmd_review','Review Launch Command'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'hide_archive','Hide This Archive'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'refresh_archive_cache','Refresh Archive Listing'),]
else:
context_menus = [update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_downloadpath','Update Download Path'),
#update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_postdlaction','Update Post DL Action'), #Hidden by default since users shouldnt change this
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_launcher','Update Launcher'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_ext_launch_cmd','Update Ext Launcher Command'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'emu_launch_cmd_review','Review Launch Command'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'hide_archive','Hide This Archive'),
update_context(iarl_data['archive_data']['emu_filepath'][ii],'refresh_archive_cache','Refresh Archive Listing'),]
if 'favorites' in iarl_data['archive_data']['emu_category'][ii].lower(): #Add additional context to Favorites
context_menus = context_menus+[update_context(iarl_data['archive_data']['emu_filepath'][ii],'update_favorite_metadata','Update Favorite Metadata'),update_context(iarl_data['archive_data']['emu_filepath'][ii],'share_favorites_list','Share My List!'),]
if 'hidden' not in iarl_data['archive_data']['emu_category'][ii]: #Don't include the archive if it's tagged hidden
if 'alphabetical' in iarl_data['settings']['listing_convention'].lower(): #List alphabetically
current_plugin_path = plugin.url_for('get_rom_starting_letter_page', category_id=iarl_data['archive_data']['category_id'][ii])
else:
current_plugin_path = plugin.url_for('get_rom_page', category_id=iarl_data['archive_data']['category_id'][ii],page_id='1')
items.append(plugin._listitemify({
'label' : iarl_data['archive_data']['emu_name'][ii],
'path': current_plugin_path,
'icon': iarl_data['archive_data']['emu_logo'][ii],
'thumbnail' : iarl_data['archive_data']['emu_boxart'][ii],
'info' : {'genre': iarl_data['archive_data']['emu_category'][ii],
'credits': iarl_data['archive_data']['emu_author'][ii],
'date': iarl_data['archive_data']['emu_date'][ii],
'plot': iarl_data['archive_data']['emu_plot'][ii],
'trailer': get_youtube_plugin_url(iarl_data['archive_data']['emu_trailer'][ii]),
'FolderPath': iarl_data['archive_data']['emu_base_url'][ii]},
'properties' : {'fanart_image' : iarl_data['archive_data']['emu_fanart'][ii],
'banner' : iarl_data['archive_data']['emu_banner'][ii],
'clearlogo': iarl_data['archive_data']['emu_logo'][ii],
'poster': iarl_data['archive_data']['emu_boxart'][ii]},
'context_menu' : context_menus
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
items[-1].set_clearlogo(items[-1].get_property('clearlogo'))
items[-1].set_clearart(items[-1].get_property('clearlogo'))
#Append Search Function
if iarl_data['settings']['show_search_item']:
items.append(plugin._listitemify({
'label' : '\xc2\xa0Search',
'path' : plugin.url_for('search_roms_window'),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'search.jpg'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'search.jpg'),
'info' : {'genre': '\xc2\xa0',
'date': '01/01/2999',
'plot' : 'Search for a particular game.'},
'properties' : {'fanart_image' : os.path.join(iarl_data['addon_data']['addon_media_path'],'fanart.jpg'),
'banner' : os.path.join(iarl_data['addon_data']['addon_media_path'],'search_banner.jpg')}
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
items[-1].set_clearlogo(items[-1].get_property('clearlogo'))
items[-1].set_clearart(items[-1].get_property('clearlogo'))
#Append Random Play Function
if iarl_data['settings']['show_randomplay_item']:
items.append(plugin._listitemify({
'label' : '\xc2\xa0\xc2\xa0Random Play',
'path' : plugin.url_for('random_play'),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'lucky.jpg'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'lucky.jpg'),
'info' : {'genre': '\xc2\xa0\xc2\xa0', 'date': '01/01/2999', 'plot' : 'Play a random game from the archive.'},
'properties' : {'fanart_image' : os.path.join(iarl_data['addon_data']['addon_media_path'],'fanart.jpg'),
'banner' : os.path.join(iarl_data['addon_data']['addon_media_path'],'lucky_banner.jpg')}
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
items[-1].set_clearlogo(items[-1].get_property('clearlogo'))
items[-1].set_clearart(items[-1].get_property('clearlogo'))
#Append Last Played Function
if iarl_data['settings']['cache_list']: #Only show if history is turned ON
if iarl_data['settings']['show_history_item']: #And if enabled in settings
items.append(plugin._listitemify({
'label' : '\xc2\xa0\xc2\xa0\xc2\xa0Last Played',
'path' : plugin.url_for('last_played'),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'last_played.jpg'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'last_played.jpg'),
'info' : {'genre': '\xc2\xa0\xc2\xa0\xc2\xa0', 'date': '01/01/2999', 'plot' : 'View your game history.'},
'properties' : {'fanart_image' : os.path.join(iarl_data['addon_data']['addon_media_path'],'fanart.jpg'),
'banner' : os.path.join(iarl_data['addon_data']['addon_media_path'],'last_played_banner.jpg')}
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
items[-1].set_clearlogo(items[-1].get_property('clearlogo'))
items[-1].set_clearart(items[-1].get_property('clearlogo'))
#Append IARL Extras
if iarl_data['settings']['show_extras_item']:
extras_content = get_iarl_extras_update_content()
extras_plot = 'Download extra game lists from the community.'
extras_date = '01/01/2999'
if len(extras_content)>0:
try:
extras_date = extras_content.split('<last_update>')[1].split('</last_update>')[0]
extras_plot = extras_plot+'[CR]Last Updated: '+str(extras_date)+'[CR]Latest Additions: '+extras_content.split('<last_update_comment>')[1].split('</last_update_comment>')[0]
except:
extras_date = '01/01/2999'
extras_plot = 'Download extra game lists from the community.'
items.append(plugin._listitemify({
'label' : '\xc2\xa0IARL Extras',
'path' : plugin.url_for('get_iarl_extras'),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'iarl_extras.jpg'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'iarl_extras.jpg'),
'info' : {'genre': '\xc2\xa0',
'date': extras_date,
'plot' : extras_plot},
'properties' : {'fanart_image' : os.path.join(iarl_data['addon_data']['addon_media_path'],'fanart.jpg'),
'banner' : os.path.join(iarl_data['addon_data']['addon_media_path'],'extras_banner.png')}
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
items[-1].set_clearlogo(items[-1].get_property('clearlogo'))
items[-1].set_clearart(items[-1].get_property('clearlogo'))
#if TOU has not been agreed to, show TOU window first
if not iarl_data['settings']['hidden_setting_tou_agree']:
MyTOUWindow = TOUWindow('TOU.xml',iarl_data['addon_data']['addon_install_path'],'Default','720p')
MyTOUWindow.doModal()
if 'true' in xbmcaddon.Addon(id='plugin.program.iarl').getSetting(id='iarl_setting_tou'):
return plugin.finish(items, update_listing=True, sort_methods=[xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, xbmcplugin.SORT_METHOD_GENRE])
else:
return plugin.finish([], update_listing=True)
else:
return plugin.finish(items, update_listing=True, sort_methods=[xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, xbmcplugin.SORT_METHOD_GENRE])
@plugin.route('/Emulator/<category_id>/<page_id>')
def get_rom_page(category_id,page_id):
#Re-scrape the current archive data if the index was not first visited
if iarl_data['archive_data'] is None:
iarl_data['archive_data'] = get_archive_info()
#Define current archive data based on the route category_id
try:
current_index = iarl_data['archive_data']['category_id'].index(category_id)
except:
xbmc.log(msg='IARL: The archive '+str(category_id)+' could not be found.', level=xbmc.LOGERROR)
current_index = None
if current_index is not None:
iarl_data['current_archive_data'] = define_current_archive_data(iarl_data,current_index,page_id)
if ',' in page_id: #If the list was requested alphabetically, define the page and alpha ID
alpha_id = page_id.split(',')[0]
page_id = page_id.split(',')[-1]
else:
alpha_id = None
#Parse XML ROM List
try:
if alpha_id is None: #No Alpha ID = One Big List
rom_list = [plugin._listitemify(x) for x in get_rom_list(iarl_data,current_index)]
else: #Only games that start with the selected letter
if '#' in alpha_id: #List everything that doesnt start with a letter
rom_list = [plugin._listitemify(list_item) for list_item in get_rom_list(iarl_data,current_index) if not list_item['label'].lower().isalpha()]
else: #List everything that starts with the selected letter
rom_list = [plugin._listitemify(list_item) for list_item in get_rom_list(iarl_data,current_index) if (alpha_id.lower() in list_item['label'].lower()[0])]
except:
xbmc.log(msg='IARL: Unable to get ROM List: %s'%str(sys.exc_info()[0]), level=xbmc.LOGERROR)
rom_list = None
items = list()
for ii in range(0,len(rom_list)):
# items.append(plugin._listitemify(roms))
rom_list[ii].set_banner(rom_list[ii].get_property('banner'))
rom_list[ii].set_landscape(rom_list[ii].get_property('banner'))
rom_list[ii].set_poster(rom_list[ii].get_property('poster'))
rom_list[ii].set_clearlogo(rom_list[ii].get_property('clearlogo'))
rom_list[ii].set_clearart(rom_list[ii].get_property('clearlogo'))
#Paginate results
page = paginate.Page(rom_list, page=page_id, items_per_page=iarl_data['settings']['items_per_page_setting'])
#Create Page Controls
next_page = []
prev_page = []
if alpha_id is None: #One Big List
prev_page_str = str(page.previous_page)
next_page_str = str(page.next_page)
else:
prev_page_str = alpha_id+','+str(page.previous_page)
next_page_str = alpha_id+','+str(page.next_page)
prev_page.append(plugin._listitemify({
'label' : '\xc2\xa0Prev <<',
'path' : plugin.url_for('get_rom_page', category_id=category_id,page_id=prev_page_str),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'Previous.png'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'Previous.png'),
'info' : {'genre': '\xc2\xa0',
'date': '01/01/2999',
'plot' : 'Page ' + str(page.page) + ' of ' + str(page.page_count) + '. Prev page is ' + str(page.previous_page) + '. Total of ' + str(page.item_count) + ' games in this archive.'}
}))
next_page.append(plugin._listitemify({
'label' : '\xc2\xa0Next >>',
'path' : plugin.url_for('get_rom_page', category_id=category_id,page_id=next_page_str),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],'Next.png'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],'Next.png'),
'info' : {'genre': '\xc2\xa0',
'date': '01/01/2999',
'plot' : 'Page ' + str(page.page) + ' of ' + str(page.page_count) + '. Next page is ' + str(page.next_page) + '. Total of ' + str(page.item_count) + ' games in this archive.'}
}))
#Define the listitems to display
current_page = page.items
#Add next and prev page listitems
if iarl_data['settings']['hard_coded_include_back_link']:
if page.previous_page:
current_page.extend(prev_page)
if page.next_page:
current_page.extend(next_page)
# # plugin.finish(succeeded=True, update_listing=True,sort_methods=[xbmcplugin.SORT_METHOD_NONE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, xbmcplugin.SORT_METHOD_DATE, xbmcplugin.SORT_METHOD_GENRE, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE])
return plugin.finish(current_page, sort_methods=[xbmcplugin.SORT_METHOD_NONE, xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE, xbmcplugin.SORT_METHOD_DATE, xbmcplugin.SORT_METHOD_GENRE, xbmcplugin.SORT_METHOD_STUDIO_IGNORE_THE])
@plugin.route('/Emulator_Alpha/<category_id>')
def get_rom_starting_letter_page(category_id):
items = []
alpha_pages = ['#','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
for alpha_page in alpha_pages:
if '#' in alpha_page:
alpha_image_id = 'Numeric'
else:
alpha_image_id = alpha_page
items.append(plugin._listitemify({
'label' : alpha_page,
'path': plugin.url_for('get_rom_page', category_id=category_id,page_id=alpha_page+',1'),
'icon': os.path.join(iarl_data['addon_data']['addon_media_path'],alpha_image_id+'.png'),
'thumbnail' : os.path.join(iarl_data['addon_data']['addon_media_path'],alpha_image_id+'.png'),
'properties' : {'fanart_image' : os.path.join(iarl_data['addon_data']['addon_media_path'],'fanart.jpg'),
'banner' : os.path.join(iarl_data['addon_data']['addon_media_path'],alpha_image_id+'_banner.png')}
}))
items[-1].set_banner(items[-1].get_property('banner'))
items[-1].set_landscape(items[-1].get_property('banner'))
items[-1].set_poster(items[-1].get_property('poster'))
return plugin.finish(items, sort_methods=[xbmcplugin.SORT_METHOD_LABEL_IGNORE_THE])
# @plugin.cached(TTL=24*60*30) #Using custom cache saving functions now
def get_rom_list(iarl_data,current_index):
if iarl_data['settings']['cache_list']: #Try to load a cached list, otherwise parse and save it
if os.path.isfile(os.path.join(iarl_data['addon_data']['addon_list_cache_path'],iarl_data['archive_data']['category_id'][current_index]+'.pickle')): #Cached list exists
load_success, rom_list = load_userdata_list_cache_file(iarl_data['archive_data']['category_id'][current_index])
if not load_success:
xbmc.log(msg='IARL: Error loading cached list, re-parsing list instead', level=xbmc.LOGDEBUG)
rom_list = parse_xml_romfile(iarl_data,current_index,plugin)
for ii in range(0,len(rom_list)):
rom_list[ii]['context_menu'] = [update_context_favorite('%s'%str(rom_list[ii]['label2']),'Add to IARL Favorites')]
else:
rom_list = parse_xml_romfile(iarl_data,current_index,plugin)
for ii in range(0,len(rom_list)):
rom_list[ii]['context_menu'] = [update_context_favorite('%s'%str(rom_list[ii]['label2']),'Add to IARL Favorites')]
save_success = save_userdata_list_cache_file(rom_list,iarl_data['archive_data']['category_id'][current_index])
else: #Cached lists is not selected
rom_list = parse_xml_romfile(iarl_data,current_index,plugin)
for ii in range(0,len(rom_list)):
rom_list[ii]['context_menu'] = [update_context_favorite('%s'%str(rom_list[ii]['label2']),'Add to IARL Favorites')]
return rom_list
@plugin.route('/Emulator/<category_id>/Game/<romname>')
def get_selected_rom(category_id,romname):
ystr = lambda s: s if len(s) > 0 else None
list_item_available = False
try:
current_index = iarl_data['archive_data']['category_id'].index(category_id)
except:
xbmc.log(msg='IARL: The archive '+str(category_id)+' could not be found.', level=xbmc.LOGERROR)
current_index = None
if current_index is not None:
iarl_data['current_archive_data'] = define_current_archive_data(iarl_data,current_index,None)
if len(xbmc.getInfoLabel('Listitem.Title'))>0:
if len(xbmc.getInfoLabel('ListItem.Property(rom_filenames)'))>0:
if 'plugin://' not in xbmc.getInfoLabel('ListItem.Property(rom_filenames)'): #Added for favorites bookmarks
list_item_available = True
if not list_item_available:
#The listitem is not defined, so we'll need to rescrape the xml for the game (most likely a favorite or other URL route)
if iarl_data['archive_data'] is None:
iarl_data['archive_data'] = get_archive_info()
#Define current archive data based on the route category_id
rom_list = get_rom_list(iarl_data,current_index)
try:
rom_idx = [romnames['label2'] for romnames in rom_list].index(romname)
except:
xbmc.log(msg='IARL: Unable to find the requested game '+str(romname), level=xbmc.LOGERROR)
rom_idx = None
#Define current_data by the rescraped rom_idx
if rom_idx is not None:
iarl_data['current_rom_data']['rom_name'] = rom_list[rom_idx]['properties']['rom_name']
iarl_data['current_rom_data']['rom_icon'] = rom_list[rom_idx]['properties']['rom_icon']
iarl_data['current_rom_data']['rom_thumbnail'] = rom_list[rom_idx]['properties']['rom_thumbnail']
iarl_data['current_rom_data']['rom_title'] = rom_list[rom_idx]['properties']['rom_title']
iarl_data['current_rom_data']['rom_studio'] = rom_list[rom_idx]['properties']['rom_studio']
iarl_data['current_rom_data']['rom_genre'] = rom_list[rom_idx]['properties']['rom_genre']
iarl_data['current_rom_data']['rom_date'] = rom_list[rom_idx]['properties']['rom_date']
iarl_data['current_rom_data']['rom_year'] = rom_list[rom_idx]['properties']['rom_year']
iarl_data['current_rom_data']['rom_plot'] = rom_list[rom_idx]['properties']['rom_plot']
iarl_data['current_rom_data']['rom_trailer'] = rom_list[rom_idx]['properties']['rom_trailer']
iarl_data['current_rom_data']['rom_tag'] = rom_list[rom_idx]['properties']['tag']
iarl_data['current_rom_data']['rom_nplayers'] = rom_list[rom_idx]['properties']['nplayers']
iarl_data['current_rom_data']['rom_rating'] = rom_list[rom_idx]['properties']['rating']
iarl_data['current_rom_data']['rom_esrb'] = rom_list[rom_idx]['properties']['esrb']
iarl_data['current_rom_data']['rom_perspective'] = rom_list[rom_idx]['properties']['perspective']
iarl_data['current_rom_data']['rom_emu_command'] = ystr(rom_list[rom_idx]['properties']['rom_emu_command'])
try: #Leave as a try statement for now, to catch any issues with old lists that dont include these values
iarl_data['current_rom_data']['rom_override_cmd'] = ystr(rom_list[rom_idx]['properties']['rom_override_cmd'])
except:
iarl_data['current_rom_data']['rom_override_cmd'] = None
try: #Leave as a try statement for now, to catch any issues with old lists that dont include these values
iarl_data['current_rom_data']['rom_override_postdl'] = ystr(rom_list[rom_idx]['properties']['rom_override_postdl'])
except:
iarl_data['current_rom_data']['rom_override_postdl'] = None
try: #Leave as a try statement for now, to catch any issues with old lists that dont include these values
iarl_data['current_rom_data']['rom_override_downloadpath'] = ystr(rom_list[rom_idx]['properties']['rom_override_downloadpath'])
except:
iarl_data['current_rom_data']['rom_override_downloadpath'] = None
iarl_data['current_rom_data']['rom_label'] = rom_list[rom_idx]['properties']['rom_label']
iarl_data['current_rom_data']['rom_filenames'] = [ystr(x) for x in rom_list[rom_idx]['properties']['rom_filenames'].split(',')] #Split into list
iarl_data['current_rom_data']['rom_supporting_filenames'] = [ystr(x) for x in rom_list[rom_idx]['properties']['rom_supporting_filenames'].split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_filenames'] = [ystr(x) for x in rom_list[rom_idx]['properties']['rom_save_filenames'].split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_supporting_filenames'] = [ystr(x) for x in rom_list[rom_idx]['properties']['rom_save_supporting_filenames'].split(',')] #Split into list
iarl_data['current_rom_data']['rom_size'] = [int(x) for x in rom_list[rom_idx]['properties']['rom_file_sizes'].split(',')] #Split into list, convert to int
for ii in range(0,total_arts):
iarl_data['current_rom_data']['rom_fanarts'][ii] = ystr(rom_list[rom_idx]['properties']['fanart'+str(ii+1)])
iarl_data['current_rom_data']['rom_boxarts'][ii] = ystr(rom_list[rom_idx]['properties']['boxart'+str(ii+1)])
iarl_data['current_rom_data']['rom_banners'][ii] = ystr(rom_list[rom_idx]['properties']['banner'+str(ii+1)])
iarl_data['current_rom_data']['rom_snapshots'][ii] = ystr(rom_list[rom_idx]['properties']['snapshot'+str(ii+1)])
iarl_data['current_rom_data']['rom_logos'][ii] = ystr(rom_list[rom_idx]['properties']['logo'+str(ii+1)])
else:
#Define current_data by the selected list item
iarl_data['current_rom_data']['rom_name'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_name)'))
iarl_data['current_rom_data']['rom_icon'] = ystr(xbmc.getInfoLabel('ListItem.Icon'))
iarl_data['current_rom_data']['rom_thumbnail'] = ystr(xbmc.getInfoLabel('ListItem.Thumb'))
iarl_data['current_rom_data']['rom_title'] = ystr(xbmc.getInfoLabel('ListItem.Title'))
iarl_data['current_rom_data']['rom_studio'] = ystr(xbmc.getInfoLabel('ListItem.Studio'))
iarl_data['current_rom_data']['rom_genre'] = ystr(xbmc.getInfoLabel('ListItem.Genre'))
iarl_data['current_rom_data']['rom_date'] = ystr(xbmc.getInfoLabel('ListItem.Date'))
iarl_data['current_rom_data']['rom_year'] = ystr(xbmc.getInfoLabel('ListItem.Year'))
iarl_data['current_rom_data']['rom_plot'] = ystr(xbmc.getInfoLabel('ListItem.Plot'))
iarl_data['current_rom_data']['rom_trailer'] = ystr(xbmc.getInfoLabel('ListItem.Trailer'))
iarl_data['current_rom_data']['rom_tag'] = ystr(xbmc.getInfoLabel('ListItem.Property(tag)'))
iarl_data['current_rom_data']['rom_nplayers'] = ystr(xbmc.getInfoLabel('ListItem.Property(nplayers)'))
iarl_data['current_rom_data']['rom_rating'] = ystr(xbmc.getInfoLabel('ListItem.Property(rating)'))
iarl_data['current_rom_data']['rom_esrb'] = ystr(xbmc.getInfoLabel('ListItem.Property(esrb)'))
iarl_data['current_rom_data']['rom_perspective'] = ystr(xbmc.getInfoLabel('ListItem.Property(perspective)'))
iarl_data['current_rom_data']['rom_emu_command'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_emu_command)'))
try:
iarl_data['current_rom_data']['rom_override_cmd'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_cmd)'))
except:
iarl_data['current_rom_data']['rom_override_cmd'] = None
try:
iarl_data['current_rom_data']['rom_override_postdl'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_postdl)'))
except:
iarl_data['current_rom_data']['rom_override_postdl'] = None
try:
iarl_data['current_rom_data']['rom_override_downloadpath'] = ystr(xbmc.getInfoLabel('ListItem.Property(rom_override_downloadpath)'))
except:
iarl_data['current_rom_data']['rom_override_downloadpath'] = None
iarl_data['current_rom_data']['rom_label'] = ystr(xbmc.getInfoLabel('ListItem.Label'))
iarl_data['current_rom_data']['rom_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_supporting_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_supporting_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_save_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_save_supporting_filenames'] = [ystr(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_save_supporting_filenames)').split(',')] #Split into list
iarl_data['current_rom_data']['rom_size'] = [int(x) for x in xbmc.getInfoLabel('ListItem.Property(rom_file_sizes)').split(',')] #Split into list, convert to int
for ii in range(0,total_arts):
iarl_data['current_rom_data']['rom_fanarts'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(fanart'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_boxarts'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(boxart'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_banners'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(banner'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_snapshots'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(snapshot'+str(ii+1)+')'))
iarl_data['current_rom_data']['rom_logos'][ii] = ystr(xbmc.getInfoLabel('ListItem.Property(logo'+str(ii+1)+')'))
if 'plugin://plugin.program.iarl' in iarl_data['current_rom_data']['rom_filenames'][0]: #IARL Favorites bookmark link, will link back to original xml listing
plugin.redirect('plugin://'+iarl_data['current_rom_data']['rom_filenames'][0].split('plugin://')[-1])
else:
check_for_warn(iarl_data['current_rom_data']['rom_size']) #Added warning for file sizes over 100MB
#Show ROM Info window, skins can override the default window by including script-IARL-infodialog.xml in their skin
if 'ROM Info Page'.lower() in iarl_data['settings']['game_select_action'].lower():
MyROMWindow = ROMWindow('script-IARL-infodialog.xml',iarl_data['addon_data']['addon_install_path'],'Default','720p',iarl_data=iarl_data)
MyROMWindow.doModal()
#Download and launch selected in settings
elif 'Download and Launch'.lower() in iarl_data['settings']['game_select_action'].lower():
download_and_launch_rom(None,iarl_data)
#Download only selected in settings
elif 'Download Only'.lower() in iarl_data['settings']['game_select_action'].lower():
iarl_data['current_save_data'] = download_rom_only(iarl_data)
if iarl_data['current_save_data']['overall_download_success']:
current_dialog = xbmcgui.Dialog()
ok_ret = current_dialog.ok('Complete',iarl_data['current_rom_data']['rom_name']+' was successfully downloaded')
else:
xbmc.log(msg='IARL: Selected game action is unknown', level=xbmc.LOGERROR)
pass #Shouldn't ever see this
pass
@plugin.route('/Search_Results/<search_term>') #Not sure why normal routing with extra kwargs isn't working for this route...
def search_roms_results(search_term,**kwargs):
# xbmc.executebuiltin("Dialog.Close(all, true)")
search_results = []
current_search_term = search_term.lower().strip()
# args_in = plugin.request.args #This doesn't work in this intance when using urlfor?
try:
current_includes = kwargs['include_archives'].split(',')
except:
current_includes = 'all'
try:
current_adv_search = kwargs['adv_search']
except:
current_adv_search = 'False'
try:
current_region = kwargs['region'].lower().strip()
except:
current_region = 'any'
try: