· 8 years ago · Aug 15, 2018, 10:20 PM
1'''
2 Script by Rocky5
3 Used to create static lists from your emulator and roms folder.
4
5 Atarijaguar have there roms placed inside there root directory.
6 NeoGeoCD must have its ISO files in folders inside its roms\system folder and the .cue file must match the name of the folder.
7 ( the script will generate static lists for emulators )
8'''
9
10import fileinput, glob, itertools, re, operator, os, shutil, struct, sys, time, xbmc, xbmcgui, zipfile, filecmp
11from xbe import *
12
13try:
14 Manual_Scan = sys.argv[1:][0]
15 Full_Scan = sys.argv[2:][0]
16except:
17 Manual_Scan = "0"
18 Full_Scan = "0"
19
20## Start markings for the log file.
21print "| .emustation\Scripts\create_rom_lists.py loaded."
22
23pDialog = xbmcgui.DialogProgress()
24dialog = xbmcgui.Dialog()
25
26## Sets paths.
27Root_Directory = xbmc.translatePath("Special://root/")
28if xbmc.getCondVisibility( 'Skin.String(Custom_Emulator_Path)' ):
29 Emulator_Folder_Path = xbmc.getInfoLabel( 'Skin.String(Custom_Emulator_Path)' )
30else:
31 Emulator_Folder_Path = os.path.join( Root_Directory, '.emustation\\emulators\\' )
32if xbmc.getCondVisibility( 'Skin.String(Custom_Roms_Path)' ):
33 Roms_Folder_Path = xbmc.getInfoLabel( 'Skin.String(Custom_Roms_Path)' )
34else:
35 Roms_Folder_Path = os.path.join( Root_Directory, '.emustation\\roms\\' )
36if xbmc.getCondVisibility( 'Skin.String(Custom_Media_Path)' ):
37 Media_Folder_Path = xbmc.getInfoLabel( 'Skin.String(Custom_Media_Path)' )
38else:
39 Media_Folder_Path = os.path.join( Root_Directory, '.emustation\\media\\' )
40Synopsis_Path = os.path.join( Root_Directory, '.emustation\\synopsis\\' )
41Scripts_Path = os.path.join( Root_Directory, '.emustation\\scripts\\' )
42Extensions = [ "adf","md","xbg","lnx","a78","a52","dim","nds","t64","d64","int","tap","z80","tzx","zip","bin","ccd","cue","j64","img","iso","rom","n64","z64","smd","smc","gb","gbc","gba","nes","sms","swc","gg","a26","a78","col","lnx","sfc","sg","fig","vms","exe" ]
43
44## Modified by me. Original by chunk_1970 - http://forum.kodi.tv/showthread.php?tid=24666&pid=125356#pid125356
45def Extract_XbeInfo(FileName): ## Need to use this as the xbe.py Get_title misses letter and causes string issues, even when using .encode or .decode
46 if os.path.isfile(FileName) and FileName.endswith('.xbe'):
47 xbe = open(FileName,'rb')
48 # Get XbeId Data #
49 xbe.seek(0x104)
50 tLoadAddr = xbe.read(4)
51 xbe.seek(0x118)
52 tCertLoc = xbe.read(4)
53 LoadAddr = struct.unpack('L',tLoadAddr)
54 CertLoc = struct.unpack('L',tCertLoc)
55 CertBase = CertLoc[0] - LoadAddr[0]
56 CertBase += 8
57 IdStart = xbe.seek(CertBase)
58 tIdData = xbe.read(4)
59 IdData = struct.unpack('L',tIdData)
60 # Get Xbe Title #
61 XbeTitle = ''
62 for dta in struct.unpack(operator.repeat('H',40),xbe.read(0x0050)):
63 try :
64 if dta != 00: XbeTitle += str(unichr(dta))
65 except : pass
66 XbeDta = str( str(XbeTitle) + '|' + str(hex(IdData[0])[2:10]).lower().zfill(8) )
67 xbe.close()
68 return XbeDta
69def Get_Title_Letter(Title_Letter):
70 Xbox_Thumb_Folder = {}
71 Title_Letter = Title_Letter.lower().lstrip(' ')
72 if Title_Letter.startswith("#") or Title_Letter.startswith("'") or Title_Letter.startswith("0") or Title_Letter.startswith("1") or Title_Letter.startswith("2") or Title_Letter.startswith("3") or Title_Letter.startswith("4") or Title_Letter.startswith("5") or Title_Letter.startswith("6") or Title_Letter.startswith("7") or Title_Letter.startswith("8") or Title_Letter.startswith("9"): Xbox_Thumb_Folder = "#"
73 if Title_Letter.startswith("a"): Xbox_Thumb_Folder = "A"
74 if Title_Letter.startswith("b"): Xbox_Thumb_Folder = "B"
75 if Title_Letter.startswith("c"): Xbox_Thumb_Folder = "C"
76 if Title_Letter.startswith("d"): Xbox_Thumb_Folder = "D"
77 if Title_Letter.startswith("e"): Xbox_Thumb_Folder = "E"
78 if Title_Letter.startswith("f"): Xbox_Thumb_Folder = "F"
79 if Title_Letter.startswith("g"): Xbox_Thumb_Folder = "G"
80 if Title_Letter.startswith("h"): Xbox_Thumb_Folder = "H"
81 if Title_Letter.startswith("i"): Xbox_Thumb_Folder = "I"
82 if Title_Letter.startswith("j"): Xbox_Thumb_Folder = "J"
83 if Title_Letter.startswith("k"): Xbox_Thumb_Folder = "K"
84 if Title_Letter.startswith("l"): Xbox_Thumb_Folder = "L"
85 if Title_Letter.startswith("m"): Xbox_Thumb_Folder = "M"
86 if Title_Letter.startswith("n"): Xbox_Thumb_Folder = "N"
87 if Title_Letter.startswith("o"): Xbox_Thumb_Folder = "O"
88 if Title_Letter.startswith("p"): Xbox_Thumb_Folder = "P"
89 if Title_Letter.startswith("q"): Xbox_Thumb_Folder = "Q"
90 if Title_Letter.startswith("r"): Xbox_Thumb_Folder = "R"
91 if Title_Letter.startswith("s"): Xbox_Thumb_Folder = "S"
92 if Title_Letter.startswith("t"): Xbox_Thumb_Folder = "T"
93 if Title_Letter.startswith("u"): Xbox_Thumb_Folder = "U"
94 if Title_Letter.startswith("v"): Xbox_Thumb_Folder = "V"
95 if Title_Letter.startswith("w"): Xbox_Thumb_Folder = "W"
96 if Title_Letter.startswith("x"): Xbox_Thumb_Folder = "X"
97 if Title_Letter.startswith("y"): Xbox_Thumb_Folder = "Y"
98 if Title_Letter.startswith("z"): Xbox_Thumb_Folder = "Z"
99 return Xbox_Thumb_Folder
100def Main_Code():
101 ## These are outside the loop so they don't reset every time.
102 ## Set the dialog create & found roms var.
103 CreateDialog = 1
104 Found_Roms = 0
105 intialrun = 0
106 Use_NoIntroNames = 0
107 _Resources = 0
108 Allow_Xbox_Overwrite = 0
109 ## Check if _emulators directory is selected instead of the emulator its self.
110 if os.path.isdir( Emulator_Folder_Path ):
111 ## Parse all folder in the Emulators_Path
112 if not os.path.isdir( os.path.join( Emulator_Folder_Path, "xbox" ) ): os.makedirs( os.path.join( Emulator_Folder_Path, "xbox" ) )
113 for Emu_Folder in sorted( os.listdir( Emulator_Folder_Path ) ):
114 ## Set a load of variable.
115 CountList = 0; JumpList = 0; Jump_Counter = 8000
116 Starts_with_0 = 0; Starts_with_A = 0; Starts_with_B = 0; Starts_with_C = 0; Starts_with_D = 0; Starts_with_E = 0; Starts_with_F = 0; Starts_with_G = 0; Starts_with_H = 0; Starts_with_I = 0; Starts_with_J = 0; Starts_with_K = 0; Starts_with_L = 0; Starts_with_M = 0; Starts_with_N = 0; Starts_with_O = 0; Starts_with_P = 0; Starts_with_Q = 0; Starts_with_R = 0; Starts_with_S = 0; Starts_with_T = 0; Starts_with_U = 0; Starts_with_V = 0; Starts_with_W = 0; Starts_with_X = 0; Starts_with_Y = 0; Starts_with_Z = 0;
117 Parse_CUE_CCD_ISO_File = 0; Parse_CUE_ZIP_ISO_ADF_File = 0; Parse_ISO_BIN_IMG_File = 0; Parse_CUE_File = 0; Parse_CCD_File = 0; Parse_ISO_File = 0; Parse_FBL_TXT = 0; Parse_Xbox_Games = 0; Parse_N64_TXT = 0; N64ID = "0"; FBA_Rom_Name = ""; Change_FBL_Rom_Path = 0; Change_Mame_Rom_Path = 0; Change_N64_Rom_Path = 0; Change_NeoGeoCD_Rom_Path = 0;
118 RomListCount = 0; RenameCount = 0; ArtworkCount = 0; ZipCount = 0;
119 Write_List_File = 1
120 Emu_XBE = "default.xbe"
121 Game_Directories = [ "E:\\Games\\", "F:\\Games\\", "G:\\Games\\", "E:\\Games1\\", "F:\\Games1\\", "G:\\Games1\\" ]
122 if ManualScan:
123 Select_Emu_Folder = dialog.select( "SELECT A SYSTEM",sorted( os.listdir( Emulator_Folder_Path ) ) )
124 if Select_Emu_Folder == -1: return
125 ## Set Emulators and Roms folder paths.
126 Emu_Path = os.path.join( Emulator_Folder_Path, sorted( os.listdir( Emulator_Folder_Path ) )[Select_Emu_Folder] )
127 Emu_Name = os.path.split(Emu_Path)[1]
128 Roms_Folder = os.path.join( Roms_Folder_Path, sorted( os.listdir( Emulator_Folder_Path ) )[Select_Emu_Folder] )
129 ## Convert Q:\\ to a direct path.
130 if Emu_Path.startswith("Q:\\"): Emu_Path = Emu_Path.replace( "Q:\\", Root_Directory )
131 ## Check for a default .xbe in the emulator path you selected.
132 if os.path.isfile( os.path.join( Emu_Path, "default.xbe" ) ) or Emu_Name == "xbox":
133 pass
134 else:
135 dialog.ok("ERROR","","No default.xbe found in this directory")
136 return Main_Code()
137 else:
138 ## Set emu_path/name variable for autoscan mode.
139 Emu_Path = os.path.join( Emulator_Folder_Path, Emu_Folder )
140 Emu_Name = os.path.split(Emu_Path)[1]
141 Roms_Folder = os.path.join( Roms_Folder_Path,Emu_Name )
142 if intialrun == 0:
143 intialrun = 1
144 ## Ask the user if they want to use the internal names from the synopsis files and if they want to use _Resources folders for Xbox game artwork.
145 if not Emu_Name == "xbox" and dialog.yesno("ROM DISPLAY NAMES","Do you want to use the names stored in the","synopsis files instead of the roms filenames?","If you select no, rom filenames will be used.") == 1:
146 Use_NoIntroNames = 1
147 if Emu_Name == "xbox" or Full_Scan == "auto":
148 if dialog.yesno("XBOX ARTWORK","Do you want to use _resources folders for art?","If you select no, covers will display your default.tbn","or an image will be extracted from the game xbe."): _Resources = 1
149 if dialog.yesno("UPDATE XBOX ARTWORK?","Selecting yes, will update any artwork that","differs from the currently cached artwork.","Selecting no will add only new artwork."): Allow_Xbox_Overwrite = 1
150 ## Set tbn and gameslist path variable.
151 Media_Path = os.path.join( Media_Folder_Path, Emu_Name )
152 Games_List_Path = os.path.join( Root_Directory, '.emustation\\gamelists', Emu_Name )
153 ## If genesis emulator is selected or found use megadrive synopsis files.
154 if Emu_Name == "genesis":
155 Synopsis_Zip = os.path.join( os.path.join( Synopsis_Path, 'megadrive' ) ) + '.zip'
156 elif Emu_Name == "famicom":
157 Synopsis_Zip = os.path.join( os.path.join( Synopsis_Path, 'nes' ) ) + '.zip'
158 elif Emu_Name == "tg16":
159 Synopsis_Zip = os.path.join( os.path.join( Synopsis_Path, 'pcengine' ) ) + '.zip'
160 elif Emu_Name == "tg-cd":
161 Synopsis_Zip = os.path.join( os.path.join( Synopsis_Path, 'pce-cd' ) ) + '.zip'
162 else:
163 Synopsis_Zip = os.path.join( os.path.join( Synopsis_Path, Emu_Name ) ) + '.zip'
164 if not Emu_Name == "xbox":
165 if not os.path.isdir( os.path.join( Media_Path,'boxart' ) ): os.makedirs( os.path.join( Media_Path,'boxart' ) )
166 if not os.path.isdir( os.path.join( Media_Path,'boxart3d' ) ): os.makedirs( os.path.join( Media_Path,'boxart3d' ) )
167 if not os.path.isdir( os.path.join( Media_Path,'logo' ) ): os.makedirs( os.path.join( Media_Path,'logo' ) )
168 if not os.path.isdir( os.path.join( Media_Path,'mix' ) ): os.makedirs( os.path.join( Media_Path,'mix' ) )
169 if not os.path.isdir( os.path.join( Media_Path,'videos' ) ): os.makedirs( os.path.join( Media_Path,'videos' ) )
170 if not os.path.isdir( os.path.join( Media_Path,'screenshots' ) ): os.makedirs( os.path.join( Media_Path,'screenshots' ) )
171 ## Check to see if the emulator is one of the below so I can change it rom type or path.
172 if Emu_Name == "fba" or Emu_Name == "fbl" or Emu_Name == "fblc" or Emu_Name == "fbaxxx":
173 Change_FBL_Rom_Path = 1
174 Parse_FBL_TXT = 1
175 elif Emu_Name == "amiga":
176 Parse_CUE_ZIP_ISO_ADF_File = 1
177 elif Emu_Name == "atarijaguar":
178 Roms_Folder = os.path.join( Emu_Path, 'roms' )
179 elif Emu_Name == "mame":
180 Change_Mame_Rom_Path = 1
181 elif Emu_Name == "n64":
182 Parse_N64_TXT = 1
183 Change_N64_Rom_Path = 1
184 elif Emu_Name == "neogeocd":
185 Change_NeoGeoCD_Rom_Path = 1
186 elif Emu_Name == "pce-cd":
187 Parse_CUE_File = 1
188 elif Emu_Name == "tg-cd":
189 Parse_CUE_File = 1
190 elif Emu_Name == "saturn":
191 Parse_CUE_CCD_ISO_File = 1
192 elif Emu_Name == "segacd":
193 Parse_CUE_File = 1
194 elif Emu_Name == "psx":
195 Parse_CUE_CCD_ISO_File = 1
196 elif Emu_Name == "xbox":
197 Parse_Xbox_Games = 1
198 Xbox_Games_Folder = "Z:\\temp\\xbox game list"
199 Roms_Folder = Xbox_Games_Folder
200 else:
201 pass
202 if Parse_CUE_File: Rom_Type_Total = (len(glob.glob1(Roms_Folder,'*.cue')))
203 if Parse_CUE_CCD_ISO_File: Rom_Type_Total = (len(glob.glob1(Roms_Folder,'*.cue')) + len(glob.glob1(Roms_Folder,'*.ccd')) + len(glob.glob1(Roms_Folder,'*.iso')))
204 if Parse_CUE_ZIP_ISO_ADF_File: Rom_Type_Total = (len(glob.glob1(Roms_Folder,'*.cue')) + len(glob.glob1(Roms_Folder,'*.zip')) + + len(glob.glob1(Roms_Folder,'*.adf')) + len(glob.glob1(Roms_Folder,'*.iso')))
205 ## Convert Q:\\ to a direct path
206 if Roms_Folder.startswith("Q:\\"): Roms_Folder = Roms_Folder.replace( "Q:\\", Root_Directory )
207 ## Check to see if the emulators = rom folder is empty and exit if it is.
208 ## below slower than just doing what I do below.
209 # if len(os.walk(Roms_Folder).next()[2]) > 0:
210 if len(os.listdir( Roms_Folder )) > 0 or Emu_Name == "xbox":
211 ## Check to see if vars are the value I need and create a new dialog.
212 if CreateDialog == 1:
213 #CreateDialog = 0
214 if ManualScan:
215 pDialog.create( "MANUAL SCAN MODE","Initializing" )
216 else:
217 pDialog.create( "AUTO SCAN MODE","Initializing" )
218 pDialog.update(0,'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Rom list','','This can take some time, please be patient.')
219 ## Checking for .png artwork files and changing them to .jpg.
220 if not Emu_Name == "xbox":
221 for dirName, subdirList, fileList in os.walk( Media_Path ):
222 pDialog.update(0,'Checking [B]' + Emu_Name + '[/B] artwork.','','This can take some time, please be patient.' )
223 for PNGs in fileList:
224 if PNGs.endswith('.png'):
225 if os.path.isfile( os.path.join( dirName,PNGs[:-4] + '.jpg' ) ):
226 os.remove( os.path.join( dirName,PNGs[:-4] + '.jpg' ) )
227 os.rename( os.path.join( dirName,PNGs ),os.path.join( dirName,PNGs[:-4] + '.jpg' ))
228 pDialog.update((ArtworkCount * 100) / len( os.listdir( Media_Path ) ),'Checking [B]' + Emu_Name + '[/B] artwork file extensions.','[B]' + PNGs + '[/B]' ,'This can take some time, please be patient.' )
229 ArtworkCount = ArtworkCount + 1
230 ## Checking filenames case and not leading with capital renaming it to do so.
231 if not Emu_Name == "xbox" and not Emu_Name == "fba" and not Emu_Name == "fbl" and not Emu_Name == "fblc" and not Emu_Name == "fbaxxx" and not Emu_Name == "mame":
232 pDialog.update(0,'Checking [B]' + Emu_Name + '[/B] Rom filename casing.','','This can take some time, please be patient.' )
233 for Roms in sorted( os.listdir( Roms_Folder ) ):
234 Items_Full_Path = os.path.join( Roms_Folder, Roms )
235 if Items_Full_Path != os.path.join( Roms_Folder, Roms.lower() ):
236 #if Items_Full_Path != os.path.join( Roms_Folder, Roms.capitalize() ):
237 tempname = Items_Full_Path[:-1]
238 if not os.path.isfile( tempname ):
239 os.rename( Items_Full_Path, tempname )
240 os.rename( tempname, os.path.join( Roms_Folder, Roms.lower() ) )
241 #os.rename( tempname, os.path.join( Roms_Folder, Roms.capitalize() ) )
242 pDialog.update((RenameCount * 100) / len( os.listdir( Roms_Folder ) ),'Lower-casing rom names.','[B]' + Roms + '[/B]' ,'This can take some time, please be patient.' )
243 RenameCount = RenameCount + 1
244 ## Setting a var again :/
245 Found_Roms = 1
246 ## Check if fbl was found and change its rom path to where the roms are located.
247 if Change_FBL_Rom_Path == 1:
248 if os.path.isfile(os.path.join( Emu_Path, 'Path.ini')):
249 for line in fileinput.input(os.path.join( Emu_Path, 'Path.ini'), inplace=1):
250 if 'ROMPath1=' in line:
251 line = line = 'ROMPath1=' + Roms_Folder + '\n'
252 print line,
253 Change_FBL_Rom_Path = 0
254 else:
255 with open(os.path.join( Emu_Path, 'Path.ini'), "w") as outputfblfile:
256 WriteFblFile = fbl_config % ( Roms_Folder )
257 outputfblfile.write( WriteFBlFile )
258 Change_FBL_Rom_Path = 0
259 ## Check if mame was found and change it rom path to where the roms are located.
260 if Change_Mame_Rom_Path == 1:
261 if not os.path.isdir(os.path.join( Emu_Path, "system")):
262 os.makedirs( os.path.join( Emu_Path, "system") )
263 if os.path.isfile(os.path.join( Emu_Path, "general\\DRIVERS.list" )): shutil.copy2(os.path.join( Emu_Path, "general\\DRIVERS.list" ), os.path.join( Emu_Path, "system") )
264 if os.path.isfile(os.path.join( Emu_Path, "system\\MAMEoX.ini")):
265 for line in fileinput.input(os.path.join( Emu_Path, "system\\MAMEoX.ini"), inplace=1):
266 if 'RomsPath0 = ' in line:
267 line = line = 'RomsPath0 = ' + Roms_Folder + '\n'
268 print line,
269 Change_Mame_Rom_Path = 0
270 else:
271 with open( os.path.join( Emu_Path, "system\\MAMEoX.ini"), "w") as outputmamefile:
272 WriteMameFile = mame_config % ( Roms_Folder )
273 outputmamefile.write( WriteMameFile )
274 Change_Mame_Rom_Path = 0
275 ## Creating Xbox game list so its in alphabetical order.
276 if Parse_Xbox_Games == 1:
277 if os.path.isdir( Roms_Folder ): shutil.rmtree( Roms_Folder )
278 if not os.path.isdir( Roms_Folder ): os.makedirs( Roms_Folder )
279 previouse_title = ""
280 dup_count = 1
281 altnumb = 1
282 for Game_Dirs in Game_Directories:
283 if os.path.isdir( Game_Dirs ):
284 for Item in sorted([f for f in os.listdir( Game_Dirs )]):
285 pDialog.update(0,'Sorting List Order & Artwork For [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Games','[B][UPPERCASE]' + Item + '[/UPPERCASE][/B]','This can take some time, please be patient.')
286 if os.path.isdir(os.path.join( Game_Dirs, Item)):
287 Game_Directory = os.path.join( Game_Dirs, Item )
288 if os.path.isfile( os.path.join( Game_Directory, "game.xbe" ) ):
289 XBEFile = os.path.join( Game_Directory, "game.xbe" )
290 elif os.path.isfile( os.path.join( Game_Directory, "tdgame.xbe" ) ):
291 XBEFile = os.path.join( Game_Directory, "tdgame.xbe" )
292 else:
293 XBEFile = os.path.join( Game_Directory, "default.xbe" )
294 if os.path.isfile( XBEFile ):
295 _Resources_PosterFile = os.path.join( Game_Directory, "_resources\\artwork\\poster.jpg" )
296 _Resources_Poster3dFile = os.path.join( Game_Directory, "_resources\\artwork\\dual3d.png" )
297 _Resources_CDFile = os.path.join( Game_Directory, "_resources\\artwork\\cd.png" )
298 _Resources_CDPosterFile = os.path.join( Game_Directory, "_resources\\artwork\\cdposter.png" )
299 _Resources_IconFile = os.path.join( Game_Directory, "_resources\\artwork\\icon.png" )
300 _Resources_ThumbFile = os.path.join( Game_Directory, "_resources\\artwork\\thumb.jpg" )
301 _Resources_FanartFile = os.path.join( Game_Directory, "_resources\\artwork\\fanart.jpg" )
302 _Resources_BannerFile = os.path.join( Game_Directory, "_resources\\artwork\\banner.png" )
303 _Resources_OpenCaseFile = os.path.join( Game_Directory, "_resources\\artwork\\opencase.png" )
304 _Resources_Screenshot = os.path.join( Game_Directory, "_resources\\screenshots\\screenshot-1.jpg" )
305 _Resources_Synopsis = os.path.join( Game_Directory, "_resources\\default.xml" )
306 TBNFile = os.path.join( Game_Directory, "default.tbn" )
307 FanartFile = os.path.join( Game_Directory, "fanart.jpg" )
308 Emu_XBE = XBEFile
309 # this is set to the default.xbe because some of the main game xbe files don't have names. Some games use default.xbe as the loader to game.xbe or tdgame.xbe
310 XBEInfo = Extract_XbeInfo( os.path.join( Game_Directory, "default.xbe" ) ).split('|')
311 XBETitle = XBEInfo[0].lstrip(' ')
312 XBEInfo = Extract_XbeInfo( XBEFile ).split('|')
313 XBEID = XBEInfo[1]
314 # use the folder name if the xbe title is corrupt or not there.
315 if XBETitle == "": XBETitle = Item.lstrip(' ')
316 XBETitle_List = xbmc.makeLegalFilename( Xbox_Games_Folder + '\\' + XBETitle.lower().replace('/','').replace('\\','').replace(' ','') )
317 # Get first letter of the games titleid and set a variable
318 Xbox_Thumb_Folder = Get_Title_Letter( XBETitle )
319 # Create folder structure for xbox games to speed up loading of images
320 if not os.path.isdir( os.path.join( Media_Path,'boxart',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'boxart',Xbox_Thumb_Folder ) )
321 if not os.path.isdir( os.path.join( Media_Path,'boxart3d',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'boxart3d',Xbox_Thumb_Folder ) )
322 if not os.path.isdir( os.path.join( Media_Path,'disc',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'disc',Xbox_Thumb_Folder ) )
323 if not os.path.isdir( os.path.join( Media_Path,'cdposter',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'cdposter',Xbox_Thumb_Folder ) )
324 if not os.path.isdir( os.path.join( Media_Path,'dual',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'dual',Xbox_Thumb_Folder ) )
325 if not os.path.isdir( os.path.join( Media_Path,'fanart',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'fanart',Xbox_Thumb_Folder ) )
326 if not os.path.isdir( os.path.join( Media_Path,'opencase',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'opencase',Xbox_Thumb_Folder ) )
327 if not os.path.isdir( os.path.join( Media_Path,'screenshots',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'screenshots',Xbox_Thumb_Folder ) )
328 if not os.path.isdir( os.path.join( Media_Path,'videos',Xbox_Thumb_Folder ) ): os.makedirs( os.path.join( Media_Path,'videos',Xbox_Thumb_Folder ) )
329 if os.path.isfile( os.path.join( Roms_Folder, 'idlist.xml' ) ):
330 if str(XBEID) in open( os.path.join( Roms_Folder, 'idlist.xml' ) ).read():
331 XBEID = str(XBEID)+"_"+str(dup_count)
332 dup_count = dup_count+1
333 if _Resources == 0:
334 if os.path.isfile( TBNFile ):
335 # Default.tbn
336 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
337 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) , TBNFile, shallow=0 ):
338 shutil.copy2( TBNFile, os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) )
339 else:
340 shutil.copy2( TBNFile, os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) )
341 else:
342 # TITLEIMAGE
343 try:
344 XBE( XBEFile ).Get_title_image().Write_PNG( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) )
345 except:
346 pass
347 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
348 if os.path.isfile( FanartFile ):
349 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) , FanartFile, shallow=0 ):
350 shutil.copy2( FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
351 else:
352 if os.path.isfile( FanartFile ):
353 shutil.copy2( FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
354 else:
355 # _Resources folder structure
356 # Poster
357 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
358 #print XBEID + " baxart already present"
359 if os.path.isfile( _Resources_PosterFile ):
360 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_PosterFile, shallow=0 ):
361 if os.path.isfile( _Resources_PosterFile ):
362 shutil.copy2( _Resources_PosterFile, Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
363 else:
364 if os.path.isfile( _Resources_PosterFile ):
365 shutil.copy2( _Resources_PosterFile, Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
366 # Default.tbn
367 elif os.path.isfile( TBNFile ):
368 shutil.copy2( TBNFile, Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
369 else:
370 # TITLEIMAGE
371 try:
372 XBE( XBEFile ).Get_title_image().Write_PNG( os.path.join( Media_Folder_Path + "xbox\\boxart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) )
373 except:
374 pass
375 # 3D Boxart
376 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\boxart3d\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
377 #print XBEID + " 3d boxart already present"
378 if os.path.isfile( _Resources_IconFile ):
379 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\boxart3d\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_IconFile, shallow=0 ):
380 if os.path.isfile( _Resources_IconFile ):
381 shutil.copy2( _Resources_IconFile, Media_Folder_Path + "xbox\\boxart3d\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
382 else:
383 if os.path.isfile( _Resources_IconFile ):
384 shutil.copy2( _Resources_IconFile, Media_Folder_Path + "xbox\\boxart3d\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
385 # CD
386 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\disc\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
387 #print XBEID + " cd already present"
388 if os.path.isfile( _Resources_CDFile ):
389 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\disc\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_CDFile, shallow=0 ):
390 if os.path.isfile( _Resources_CDFile ):
391 shutil.copy2( _Resources_CDFile, Media_Folder_Path + "xbox\\disc\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
392 else:
393 if os.path.isfile( _Resources_CDFile ):
394 shutil.copy2( _Resources_CDFile, Media_Folder_Path + "xbox\\disc\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
395 # Disc case
396 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\cdposter\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
397 #print XBEID + " disc case already present"
398 if os.path.isfile( _Resources_CDPosterFile ):
399 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\cdposter\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_CDPosterFile, shallow=0 ):
400 if os.path.isfile( _Resources_CDPosterFile ):
401 shutil.copy2( _Resources_CDPosterFile, Media_Folder_Path + "xbox\\cdposter\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
402 else:
403 if os.path.isfile( _Resources_CDPosterFile ):
404 shutil.copy2( _Resources_CDPosterFile, Media_Folder_Path + "xbox\\cdposter\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
405 # Dual 3D
406 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\dual\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
407 #print XBEID + " dual 3d already present"
408 if os.path.isfile( _Resources_Poster3dFile ):
409 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\dual\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_Poster3dFile, shallow=0 ):
410 if os.path.isfile( _Resources_Poster3dFile ):
411 shutil.copy2( _Resources_Poster3dFile, Media_Folder_Path + "xbox\\dual\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
412 else:
413 if os.path.isfile( _Resources_Poster3dFile ):
414 shutil.copy2( _Resources_Poster3dFile, Media_Folder_Path + "xbox\\dual\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
415 # Open Case
416 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\opencase\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
417 #print XBEID + " mix already present"
418 if os.path.isfile( _Resources_OpenCaseFile ):
419 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\opencase\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_OpenCaseFile, shallow=0 ):
420 if os.path.isfile( _Resources_OpenCaseFile ):
421 shutil.copy2( _Resources_OpenCaseFile, Media_Folder_Path + "xbox\\opencase\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
422 else:
423 if os.path.isfile( _Resources_OpenCaseFile ):
424 shutil.copy2( _Resources_OpenCaseFile, Media_Folder_Path + "xbox\\opencase\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
425 # Fanart
426 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
427 #print XBEID + " fanart already present"
428 if os.path.isfile( _Resources_FanartFile ):
429 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_FanartFile, shallow=0 ):
430 if os.path.isfile( _Resources_FanartFile ):
431 shutil.copy2( _Resources_FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
432 elif os.path.isfile( FanartFile ):
433 shutil.copy2( FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
434 else:
435 if os.path.isfile( _Resources_FanartFile ):
436 shutil.copy2( _Resources_FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
437 elif os.path.isfile( FanartFile ):
438 shutil.copy2( FanartFile, Media_Folder_Path + "xbox\\fanart\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
439 # Screenshots
440 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\screenshots\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ) ):
441 #print XBEID + " screenshots already present"
442 if os.path.isfile( _Resources_Screenshot ):
443 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\screenshots\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" ), _Resources_Screenshot, shallow=0 ):
444 if os.path.isfile( _Resources_Screenshot ):
445 shutil.copy2( _Resources_Screenshot, Media_Folder_Path + "xbox\\screenshots\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
446 else:
447 if os.path.isfile( _Resources_Screenshot ):
448 shutil.copy2( _Resources_Screenshot, Media_Folder_Path + "xbox\\screenshots\\" + Xbox_Thumb_Folder + '\\' + XBEID + ".jpg" )
449 # Videos
450 for Files in glob.glob( os.path.join( Game_Directory, "_resources\\media\\*.*") ):
451 if os.path.isfile( os.path.join( Media_Folder_Path + "xbox\\videos\\" + Xbox_Thumb_Folder + '\\' + XBEID + Files[-4:] ) ):
452 #print XBEID + " videos already present"
453 if os.path.isfile( Files ):
454 if Allow_Xbox_Overwrite == 1 and not filecmp.cmp( os.path.join( Media_Folder_Path + "xbox\\videos\\" + Xbox_Thumb_Folder + '\\' + XBEID + Files[-4:] ), Files, shallow=0 ):
455 if os.path.isfile( Files ):
456 shutil.copy2( Files, Media_Folder_Path + "xbox\\videos\\" + Xbox_Thumb_Folder + '\\' + XBEID + Files[-4:] )
457 else:
458 if os.path.isfile( Files ):
459 shutil.copy2( Files, Media_Folder_Path + "xbox\\videos\\" + Xbox_Thumb_Folder + '\\' + XBEID + Files[-4:] )
460 with open( os.path.join( Roms_Folder, 'idlist.xml' ), "a") as idlistfile:
461 idlistoutput = str(XBEID)+"\n"
462 idlistfile.write( idlistoutput )
463 if previouse_title == XBETitle_List:
464 with open( XBETitle_List[:56] + "_alt"+str(altnumb)+".xbg","w") as ouput:
465 ouput.write(XBETitle + " ( Duplicate Name " + str(altnumb) + " )\n")
466 ouput.write(Emu_XBE + "\n")
467 ouput.write(Xbox_Thumb_Folder + "\n")
468 ouput.write(XBEID)
469 altnumb = altnumb+1
470 else:
471 with open( XBETitle_List[:61] + ".xbg","w") as ouput:
472 ouput.write(XBETitle + "\n")
473 ouput.write(Emu_XBE + "\n")
474 ouput.write(Xbox_Thumb_Folder + "\n")
475 ouput.write(XBEID)
476 previouse_title = XBETitle_List
477 ## Extracting the rom name files from the zip.
478 if Parse_FBL_TXT == 1:
479 if os.path.isfile( os.path.join( Emu_Path, "info\\FBL Rom Names.zip" ) ):
480 with zipfile.ZipFile( os.path.join( Emu_Path, "info\\FBL Rom Names.zip" ) ) as zip:
481 if not os.path.isdir( os.path.join( Emu_Path, "info\\rom names" ) ): os.makedirs( os.path.join( Emu_Path, "info\\rom names" ) )
482 if ZipCount == 0:
483 #pDialog.create( "EXTRACTING ZIP","","Please wait..." )
484 Total_TXT_Files = len( zip.namelist() ) or 1
485 Devide = 100.0 / Total_TXT_Files
486 Percent = 0
487 for item in zip.namelist():
488 Percent += Devide
489 pDialog.update( int( Percent ),'Extracting FBA, FBAXXX, FBL or FBLC rom names','This only happens once per update','' )
490 zip.extract( item, os.path.join( Emu_Path, "info\\rom names\\" ) )
491 ZipCount = 1
492 os.remove( os.path.join( Emu_Path, "info\\FBL Rom Names.zip" ) )
493 Roms_Folder = os.path.join( Emu_Path, "info\\rom names" )
494 ## Used to name the rom name files so I can sort them by alphabetical order properly. ( this is only used by me )
495 # for files in sorted( os.listdir( os.path.join( Emu_Path, "info\\rom names" ) ) ):
496 # try:
497 # with open( os.path.join( Emu_Path, "info\\rom names", files[:-3] + 'txt' ), 'r') as txt:
498 # FBA_Rom_Name_Full = txt.readline()[:-2]
499 # FBA_Rom_Name = FBA_Rom_Name_Full[:20]
500 # FBA_Rom_Name = FBA_Rom_Name.replace( ',','' ); FBA_Rom_Name = FBA_Rom_Name.replace( ':','' ); FBA_Rom_Name = FBA_Rom_Name.replace( ';','' ); FBA_Rom_Name = FBA_Rom_Name.replace( '/','' ); FBA_Rom_Name = FBA_Rom_Name.replace( '?','' ); FBA_Rom_Name = FBA_Rom_Name.replace( '+','' ); FBA_Rom_Name = FBA_Rom_Name.replace( '*','' ); FBA_Rom_Name = FBA_Rom_Name.replace( 'amp','' ); FBA_Rom_Name = FBA_Rom_Name.replace( ' ','' );
501 # FBA_Rom_Name = FBA_Rom_Name.lower()
502 # for line in txt: FBA_Rom_System_Full = '\n'+line
503 # if not os.path.isdir( "F:\\rom names" ): os.makedirs( "F:\\rom names" )
504 # with open( os.path.join( "F:\\rom names", FBA_Rom_Name + '--' + files[:-3] + 'zip' ), 'w') as txt:
505 # txt.write( FBA_Rom_Name_Full.lower() )
506 # txt.write( FBA_Rom_System_Full.lower() )
507 # pDialog.update((CountList * 100) / len(os.listdir( os.path.join( Emu_Path, 'info\\rom names' ) ) ),'Processing Rom name files',files,'This can take some time, please be patient.' )
508 # CountList = CountList + 1
509 # except: pass
510 # return
511 ## Check for previous layout xml and if it exists remove it.
512 if os.path.isdir( Games_List_Path ): shutil.rmtree( Games_List_Path )
513 if not os.path.isdir( Games_List_Path ): os.makedirs( Games_List_Path )
514 if Parse_Xbox_Games == 1 and os.path.isfile( os.path.join( Media_Folder_Path, "xbox\\GameNames.txt" ) ): os.remove( os.path.join( Media_Folder_Path, "xbox\\GameNames.txt" ) )
515 ## Write new gamelist xml header.
516 with open( os.path.join( Games_List_Path, 'gamelist.xml' ), "wb") as outputmenufile:
517 WriteMenuFile = menu_entry_header
518 outputmenufile.write( WriteMenuFile )
519 ## Listing the content of the roms folder for parsing.
520 for Items in sorted([f for f in os.listdir( Roms_Folder )]):
521 ## Checking the file I find, extension against my table.
522 if Items.lower().endswith(tuple(Extensions)) or Emu_Name == "neogeocd":
523 ## More vars being set.
524 Rom_Name = Items.lower()
525 Rom_Name_noext = Rom_Name[:-4]
526 if Emu_Name == "xbox":
527 with open(os.path.join( Xbox_Games_Folder, Rom_Name ), "r") as input:
528 Rom_Name_noext = input.readline()
529 Emu_XBE = input.readline()
530 skip = input.readline()
531 XBE_ID = input.readline()
532 JumpList_Name = Rom_Name_noext.lower()
533 if not xbmc.getCondVisibility( 'Skin.String(' + Emu_Name + '_artworkfolder)' ): xbmc.executebuiltin('Skin.SetString(' + Emu_Name + '_artworkfolder,boxart)')
534 Thumbnail = Rom_Name_noext + '.jpg'
535 ## Check if fba was found and parse the name text files to get the correct rom names and system types for the list.
536 if Parse_FBL_TXT == 1:
537 Rom_Name_Full = Rom_Name
538 Rom_Name_Beg = Rom_Name.split('--', 1)[0]
539 Rom_Name = Rom_Name.split('--', 1)[1]
540 Rom_Name_noext = Rom_Name[:-4]
541 Thumbnail = Rom_Name_noext + '.jpg'
542 if os.path.isfile( os.path.join( Roms_Folder_Path, Emu_Name, Rom_Name ) ) and os.path.isfile( os.path.join( Emu_Path, "info\\rom names", Rom_Name_Beg + '--' + Rom_Name ) ):
543 with open( os.path.join( Emu_Path, "info\\rom names", Rom_Name_Beg + '--' + Rom_Name ), 'r') as txt:
544 FBA_Rom_Name = txt.readline()[:-1]
545 #FBA_Rom_Name = FBA_Rom_Name.split('(', 1)[0]
546 #FBA_Rom_Name = FBA_Rom_Name.split('/', 1)[0]
547 for line in txt:
548 System_Name = line.lower()[:-2]
549 Emu_XBE = "default.xbe"
550 if System_Name == "psikyo 68ec020" or System_Name == "ps3-v1" or System_Name == "ps4" or System_Name == "ps5" or System_Name == "fg-3" or System_Name == "tecmo" or System_Name == "polygamemaster" or System_Name == "polygamemaster based" or System_Name == "ps5v2": Emu_XBE = "psykio.xbe"
551 if System_Name == "neo geo aes" or System_Name == "neo geo mvs": Emu_XBE = "neogeocps2.xbe"
552 if System_Name == "cps2": Emu_XBE = "neogeocps2.xbe"
553 if System_Name == "cave": Emu_XBE = "cave.xbe"
554 if System_Name == "toaplan gp9001 based" or System_Name == "toaplan bcu-2 / fcu-2 based" or System_Name == "dual toaplan gp9001 based": Emu_XBE = "toaplan.xbe"
555 if System_Name == "to": Emu_XBE = "taito.xbe"
556 if System_Name == "sk" or System_Name == "cps-3" or System_Name == "nmk16" or System_Name == "ssv" or System_Name == "wr" or System_Name == "th2" or System_Name == "wr2" or System_Name == "fg-2" or System_Name == "mega system 1" or System_Name == "sf" or System_Name == "kaneko 16-bit": Emu_XBE = "new.xbe"
557 if System_Name == "de": Emu_XBE = "dataeast.xbe"
558 if System_Name == "kn": Emu_XBE = "konami.xbe"
559 if System_Name == "system 16a" or System_Name == "system 16b" or System_Name == "system 18" or System_Name == "x-board" or System_Name == "y-board" or System_Name == "out run" or System_Name == "hang-on": Emu_XBE = "sega.xbe"
560 if System_Name == "jc" or System_Name == "unico" or System_Name == "ss" or System_Name == "f1gp" or System_Name == "newer seta" or System_Name == "pwr": Emu_XBE = "xtra.xbe"
561 if System_Name == "im": Emu_XBE = "irem.xbe"
562 JumpList_Name = Rom_Name_Full.lower()
563 Write_List_File = 1
564 elif Rom_Name == "isgsm.zip":
565 Write_List_File = 0
566 elif Rom_Name == "neogeo.zip":
567 Write_List_File = 0
568 elif Rom_Name == "nmk004.zip":
569 Write_List_File = 0
570 elif Rom_Name == "pgm.zip":
571 Write_List_File = 0
572 else:
573 Write_List_File = 0
574 ## Check if n64 was found and parse the names from surreal.ini if the roms match.
575 if Parse_N64_TXT == 1:
576 if os.path.isfile(os.path.join( Emu_Path, 'surreal.ini' )):
577 if Change_N64_Rom_Path == 1:
578 if os.path.isdir( 'E:\\TDATA\\64ce64ce' ): shutil.rmtree( 'E:\\TDATA\\64ce64ce' )
579 for line in fileinput.input( os.path.join( Emu_Path, 'surreal.ini' ), inplace=1):
580 if 'Rom Path=' in line:
581 line = line = 'Rom Path=' + Roms_Folder + '\n'
582 print line,
583 os.makedirs( 'E:\\TDATA\\64ce64ce' )
584 with open( os.path.join( 'E:\\TDATA\\64ce64ce\\surreal-ce.ini' ), "w") as outputn64file:
585 WriteN64File = n64_config % ( Roms_Folder )
586 outputn64file.write( WriteN64File )
587 Change_N64_Rom_Path = 0
588 Bypass_N64_Check = 0
589 ## Extracting the rom names from the ini.
590 with open( os.path.join( Emu_Path, 'surreal.ini' ), 'r') as ini:
591 for line in itertools.islice(ini, 20, None):
592 N64ID = str(line.lower())
593 if not N64ID.startswith('['):
594 dialog.ok("ERROR","","Surreal.ini is corrupt or not formatted correctly[CR]Please recopy [B]EarthWormsJames[/B] N64 files over")
595 return
596 N64ID = N64ID[1:]
597 N64ID1 = N64ID.split('-')[0]
598 N64ID2 = N64ID.split('-')[1]
599 File_Name = ini.next().replace('Game Name=','')[:-1]
600 File_Name = File_Name.lower()
601 if os.path.isdir( os.path.join( Emu_Path, 'media\\Cbagys3DArt' ) ):
602 if File_Name == "007 goldeneye (ultrahle)720pno" or Bypass_N64_Check == 1:
603 Bypass_N64_Check = 1
604 if Rom_Name_noext == File_Name:
605 N64_Rom_Name = ini.next().replace('Alternate Title=','')[:-1]
606 N64_Rom_Name = N64_Rom_Name.split(' (', 1)[0]
607 try:
608 ini.next() # skip the comment line
609 ini.next() # skip the blank line
610 except: pass
611 for N64_Thumb in os.listdir( os.path.join( Emu_Path, 'media\\Cbagys3DArt' ) ):
612 N64_Thumb = N64_Thumb.lower()
613 if N64ID1 in N64_Thumb or N64ID2 in N64_Thumb:
614 if not os.path.isdir( os.path.join( Synopsis_Path, Emu_Name ) ): os.makedirs( os.path.join( Synopsis_Path, Emu_Name ) )
615 N64_Thumb_Location = os.path.join( Emu_Path, 'media\\Cbagys3DArt', N64_Thumb )
616 #shutil.copy2( N64_Thumb_Location, "E:\\1\\" )
617 N64_Thumb_Destination = os.path.join( Media_Path, 'boxart', File_Name + '.jpg' )
618 if os.path.isfile( N64_Thumb_Location ) and not os.path.isfile( N64_Thumb_Destination ): shutil.copy2( N64_Thumb_Location, N64_Thumb_Destination )
619 for N64_Thumb in os.listdir( os.path.join( Emu_Path, 'media\\Movies' ) ):
620 N64_Thumb = N64_Thumb.lower()
621 if N64ID1 in N64_Thumb or N64ID2 in N64_Thumb:
622 if not os.path.isdir( os.path.join( Media_Path, 'videos' ) ): os.makedirs( os.path.join( Media_Path, 'videos' ) )
623 N64_Thumb_Location = os.path.join( Emu_Path, 'media\\Movies', N64_Thumb )
624 N64_Thumb_Destination = os.path.join( Media_Path, 'videos', File_Name + N64_Thumb[-4:] )
625 if os.path.isfile( N64_Thumb_Location ) and not os.path.isfile( N64_Thumb_Destination ): shutil.copy2( N64_Thumb_Location, N64_Thumb_Destination )
626 for N64_Synopsis in os.listdir( os.path.join( Emu_Path, 'media\\synopsis' ) ):
627 N64_Synopsis = N64_Synopsis.lower()
628 if N64ID1 in N64_Synopsis or N64ID2 in N64_Synopsis:
629 N64_Synopsis_Location = os.path.join( Emu_Path, 'media\\synopsis', N64_Synopsis[:-3] + 'txt' )
630 #shutil.copy2( N64_Synopsis_Location, "E:\\2\\" )
631 N64_Synopsis_Destination = os.path.join( Synopsis_Path, Emu_Name, File_Name + '.txt' )
632 #if os.path.isfile( N64_Synopsis_Location ) and not os.path.isfile( N64_Synopsis_Destination ):
633 if os.path.isfile( N64_Synopsis_Location ):
634 with open( N64_Synopsis_Location ) as readn64tmp:
635 readn64 = readn64tmp.read()
636 readn64 = readn64.strip()
637 with open( N64_Synopsis_Destination, 'w' ) as n64tmp:
638 amended_n64tmp = 'Name: ' + readn64
639 n64tmp.write(amended_n64tmp)
640 #if os.path.isfile( N64_Synopsis_Location ): shutil.copy2( N64_Synopsis_Location, N64_Synopsis_Destination )
641 else:
642 try:
643 ini.next() # skip the rom name
644 ini.next() # skip the comment line
645 ini.next() # skip the blank line
646 except: pass
647 else:
648 dialog.ok("ERROR","","This isn't [B]EarthWormsJames[/B][CR]N64 emulator best of compilation")
649 return
650 else:
651 dialog.ok("ERROR","","Reinstall the [B]EarthWormsJames[/B] N64 emulator.[CR]The Cbagys3DArt folder is missing.")
652 return
653 else:
654 dialog.ok("ERROR","","Surreal.ini is missing from the","N64 Emulators directory")
655 return
656 ## Change neogeocd rom path.
657 if Change_NeoGeoCD_Rom_Path == 1:
658 if os.path.isfile(os.path.join( Emu_Path, "path.txt" )):
659 with open( os.path.join( os.path.join( Emu_Path, "path.txt" ) ), "w") as outputneogeocdfile:
660 WriteneogeocdFile = "rompath " + Roms_Folder + '\\\n'
661 outputneogeocdfile.write( WriteneogeocdFile )
662 Change_NeoGeoCD_Rom_Path = 0
663 else:
664 dialog.ok("ERROR","","path.txt is missing from the","Neogeocd Emulators directory")
665 return
666 ## Check for a synopsis zip for the current emulator.
667 if ZipCount == 0:
668 if os.path.isfile( Synopsis_Zip ):
669 ## Extracting the synopsis files from the zip.
670 with zipfile.ZipFile( Synopsis_Zip ) as zip:
671 if ZipCount == 0:
672 #pDialog.create( "EXTRACTING ZIP","","Please wait..." )
673 Total_TXT_Files = len( zip.namelist() ) or 1
674 Devide = 100.0 / Total_TXT_Files
675 Percent = 0
676 for item in zip.namelist():
677 Percent += Devide
678 pDialog.update( int( Percent ),'Extracting [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Synopsis files.',item,'' )
679 zip.extract( item, Synopsis_Path )
680 ZipCount = 1
681 os.remove( os.path.join( Synopsis_Zip ) )
682 else:
683 pass
684 ## Check for a synopsis file for the current emulator and parse it.
685 Synopsis_filename = '[B]Filename:[/B][CR] ' + Rom_Name; Synopsis_release_year = '[B]Released:[/B][CR] unknown '; Synopsis_players = '[B]Players:[/B][CR] at least 1'; Synopsis_genre = '[B]Genre:[/B][CR] unknown'; Synopsis_developer = '[B]Developer:[/B][CR] unknown'; Synopsis_publisher = '[B]Publisher:[/B][CR] unknown'; ynopsis_release_year = '[B]Released:[/B][CR] unknown'
686 Synopsis_filename_Set = 0; Synopsis_nointroname_Set = 0; Synopsis_rating_Set = 0; Synopsis_players_Set = 0; Synopsis_genre_Set = 0; Synopsis_developer_Set = 0; Synopsis_publisher_Set = 0; Synopsis_release_year_Set = 0
687 try:
688 if Emu_Name == "genesis":
689 Synopsis_File = os.path.join( Synopsis_Path, "megadrive", Rom_Name_noext + '.txt' )
690 elif Emu_Name == "famicom":
691 Synopsis_File = os.path.join( Synopsis_Path, "nes", Rom_Name_noext + '.txt' )
692 elif Emu_Name == "tg16":
693 Synopsis_File = os.path.join( Synopsis_Path, "pcengine", Rom_Name_noext + '.txt' )
694 elif Emu_Name == "tg-cd":
695 Synopsis_File = os.path.join( Synopsis_Path, "pce-cd", Rom_Name_noext + '.txt' )
696 elif Emu_Name == "fbl" or Emu_Name == "fblc" or Emu_Name == "fbaxxx":
697 Synopsis_File = os.path.join( Synopsis_Path, "fba", Rom_Name_noext + '.txt' )
698 elif Emu_Name == "xbox":
699 if '_' in XBE_ID:
700 Synopsis_File = os.path.join( Synopsis_Path, "xbox", XBE_ID.split('_', 1)[0] + '.txt' )
701 else:
702 Synopsis_File = os.path.join( Synopsis_Path, "xbox", XBE_ID + '.txt' )
703 else:
704 Synopsis_File = os.path.join( Synopsis_Path, Emu_Name, Rom_Name_noext + '.txt' )
705 with open( Synopsis_File ) as input:
706 Synopsis = input.read()
707 Synopsis1 = Synopsis.split('_________________________', 1)[0]
708 Synopsis1 = Synopsis1.split('\n')
709 for _ in range(11):
710 for line in Synopsis1:
711 line = line.lower()
712 if line.startswith('name:') and Use_NoIntroNames == 1:
713 if Emu_Name == "fba" or Emu_Name == "fbl" or Emu_Name == "fblc" or Emu_Name == "fbaxxx":
714 FBA_Rom_Name = line.split(': ',1)[1]
715 Synopsis_nointroname_Set = 1
716 elif Emu_Name == "n64":
717 Rom_Name_noext = line.split(': ',1)[1]
718 if Rom_Name_noext.startswith('the'):
719 N64_Rom_Name = Rom_Name_noext[4:] + ', the'
720 else:
721 N64_Rom_Name = Rom_Name_noext.split(' (',1)[0]
722 Synopsis_nointroname_Set = 1
723 else:
724 Rom_Name_noext = line.split(': ',1)[1]
725 if Rom_Name_noext.startswith('the'):
726 Rom_Name_noext = Rom_Name_noext[4:] + ', the'
727 else:
728 Rom_Name_noext = Rom_Name_noext.split(' (',1)[0]
729 Synopsis_nointroname_Set = 1
730 elif Synopsis_nointroname_Set == 0:
731 pass
732 if Emu_Name == "xbox":
733 with open(os.path.join( Xbox_Games_Folder, Rom_Name ), "r") as input:
734 skip = input.readline()
735 skip = input.readline()
736 skip = input.readline()
737 Synopsis_filename = input.readline()
738 if '_' in Synopsis_filename:
739 Synopsis_filename = '[B]TITLEID:[/B][CR] ' + Synopsis_filename.split('_', 1)[0]
740 else:
741 Synopsis_filename = '[B]TITLEID:[/B][CR] ' + Synopsis_filename
742 else:
743 if line.startswith('filename:'):
744 Synopsis_filename = line.split(': ',1)[1]
745 Synopsis_filename = '[B]Filename:[/B][CR] ' + Synopsis_filename
746 Synopsis_filename_Set = 1
747 elif Synopsis_filename_Set == 0:
748 Synopsis_filename = '[B]Filename:[/B][CR] ' + Rom_Name
749 # if line.startswith('rating:'):
750 # Synopsis_rating = line.split(': ',1)[1]
751 # Synopsis_rating = '[B]Rating:[/B][CR] ' + Synopsis_rating
752 # Synopsis_rating_Set = 1
753 # elif Synopsis_rating_Set == 0:
754 # Synopsis_rating = '[B]Rating:[/B][CR] unknown'
755 if line.startswith('players:'):
756 Synopsis_players = line.split(': ',1)[1]
757 Synopsis_players = '[B]Players:[/B][CR] ' + Synopsis_players
758 Synopsis_players_Set = 1
759 elif Synopsis_players_Set == 0:
760 Synopsis_players = '[B]Players:[/B][CR] at least 1'
761 if line.startswith('genre:'):
762 Synopsis_genre = line.split(': ',1)[1]
763 Synopsis_genre = '[B]Genre:[/B][CR] ' + Synopsis_genre
764 Synopsis_genre_Set = 1
765 elif Synopsis_genre_Set == 0:
766 Synopsis_genre = '[B]Genre:[/B][CR] unknown'
767 if line.startswith('developer:'):
768 Synopsis_developer = line.split(': ',1)[1]
769 Synopsis_developer = '[B]Developer:[/B][CR] ' + Synopsis_developer
770 Synopsis_developer_Set = 1
771 elif Synopsis_developer_Set == 0:
772 Synopsis_developer = '[B]Developer:[/B][CR] unknown'
773 if line.startswith('publisher:'):
774 Synopsis_publisher = line.split(': ',1)[1]
775 Synopsis_publisher = '[B]Publisher:[/B][CR] ' + Synopsis_publisher
776 Synopsis_publisher_Set = 1
777 elif Synopsis_publisher_Set == 0:
778 Synopsis_publisher = '[B]Publisher:[/B][CR] unknown'
779 if line.startswith('release year:'):
780 Synopsis_release_year = line.split(': ',1)[1]
781 Synopsis_release_year = '[B]Released:[/B][CR] ' + Synopsis_release_year
782 Synopsis_release_year_Set = 1
783 elif Synopsis_release_year_Set == 0:
784 Synopsis_release_year = '[B]Released:[/B][CR] unknown'
785 Synopsis1 = Synopsis_players + '[CR]' + Synopsis_genre + '[CR]' + Synopsis_developer + '[CR]' + Synopsis_publisher + '[CR]' + Synopsis_release_year + '[CR]' + Synopsis_filename
786 Synopsis2 = Synopsis.split('_________________________', 1)[1]
787 Synopsis2 = Synopsis2.strip('\n')
788 Synopsis2 = Synopsis2.replace( '\n', '[CR]' )
789 Synopsis2 = Synopsis2.replace( '&', '&' )
790 Synopsis2 = Synopsis2.replace( '>', '>' )
791 Synopsis2 = Synopsis2.replace( '<', '<' )
792 except:
793 if Emu_Name == "xbox":
794 with open(os.path.join( Xbox_Games_Folder, Rom_Name ), "r") as input:
795 skip = input.readline()
796 skip = input.readline()
797 skip = input.readline()
798 Synopsis_filename = input.readline()
799 if '_' in Synopsis_filename:
800 Synopsis_filename = '[B]TITLEID:[/B][CR] ' + Synopsis_filename.split('_', 1)[0]
801 else:
802 Synopsis_filename = '[B]TITLEID:[/B][CR] ' + Synopsis_filename
803 Synopsis1 = Synopsis_players + '[CR]' + Synopsis_genre + '[CR]' + Synopsis_developer + '[CR]' + Synopsis_publisher + '[CR]' + Synopsis_release_year + '[CR]' + Synopsis_filename
804 Synopsis2 = ""
805 ## Fix labels that use only numbers, XBMC will use its internal labeling system if I dont.
806 if FBA_Rom_Name == "1942": FBA_Rom_Name = "1942 "
807 if Rom_Name_noext == "1942": Rom_Name_noext = "1942 "
808 if Rom_Name_noext == "1943": Rom_Name_noext = "1943 "
809 if Rom_Name_noext == "720": Rom_Name_noext = "720 "
810 ## Set Rom_Names for different types of CD images.
811 Rom_Name_ISO = Rom_Name[:-4] + ".iso"
812 Rom_Name_BIN = Rom_Name[:-4] + ".bin"
813 Rom_Name_IMG = Rom_Name[:-4] + ".img"
814 Rom_Name_CUE = Rom_Name[:-4] + ".cue"
815 Rom_Name_CCD = Rom_Name[:-4] + ".ccd"
816 Rom_Name_ZIP = Rom_Name[:-4] + ".zip"
817 Rom_Name_ADF = Rom_Name[:-4] + ".adf"
818 Rom_Path = Rom_Name
819 ## Check and parse the directory for iso files.
820 if Parse_ISO_File == 1:
821 if Items.endswith( '.iso' ):
822 Rom_Path = Rom_Name_ISO
823 Rom_Type_Total = Rom_Type_Total
824 Write_List_File = 1
825 else:
826 Write_List_File = 0
827 ## Check and parse the directory for cue files.
828 if Parse_CUE_File == 1:
829 if Items.endswith( '.cue' ):
830 Rom_Path = Rom_Name_CUE
831 Rom_Type_Total = Rom_Type_Total
832 Write_List_File = 1
833 else:
834 Write_List_File = 0
835 ## Check and parse the directory for bin/iso/img files.
836 if Parse_ISO_BIN_IMG_File == 1:
837 if Items.endswith( '.bin' ):
838 Rom_Path = Rom_Name_BIN
839 Rom_Type_Total = Rom_Type_Total
840 Write_List_File = 1
841 elif Items.endswith( '.img' ):
842 Rom_Path = Rom_Name_IMG
843 Rom_Type_Total = Rom_Type_Total
844 Write_List_File = 1
845 elif Items.endswith( '.iso' ):
846 Rom_Path = Rom_Name_ISO
847 Rom_Type_Total = Rom_Type_Total
848 Write_List_File = 1
849 else:
850 Write_List_File = 0
851 ## Check and parse the directory for cue/ccd/iso files.
852 if Parse_CUE_CCD_ISO_File == 1:
853 if Items.endswith( '.cue' ):
854 Rom_Path = Rom_Name_CUE
855 Rom_Type_Total = Rom_Type_Total
856 Write_List_File = 1
857 elif Items.endswith( '.ccd' ):
858 Rom_Path = Rom_Name_CCD
859 Rom_Type_Total = Rom_Type_Total
860 Write_List_File = 1
861 elif Items.endswith( '.iso' ):
862 Rom_Path = Rom_Name_ISO
863 Rom_Type_Total = Rom_Type_Total
864 if os.path.isfile( os.path.join( Roms_Folder,Rom_Path[:-4]+'.cue' ) ):
865 Write_List_File = 0
866 else:
867 Write_List_File = 1
868 else:
869 Write_List_File = 0
870 ## Check and parse the directory for cue/zip/adf/iso files.
871 if Parse_CUE_ZIP_ISO_ADF_File == 1:
872 if Items.endswith( '.cue' ):
873 Rom_Path = Rom_Name_CUE
874 Rom_Type_Total = Rom_Type_Total
875 Write_List_File = 1
876 elif Items.endswith( '.zip' ):
877 Rom_Path = Rom_Name_ZIP
878 Rom_Type_Total = Rom_Type_Total
879 Write_List_File = 1
880 elif Items.endswith( '.adf' ):
881 Rom_Path = Rom_Name_ADF
882 Rom_Type_Total = Rom_Type_Total
883 Write_List_File = 1
884 elif Items.endswith( '.iso' ):
885 Rom_Path = Rom_Name_ISO
886 Rom_Type_Total = Rom_Type_Total
887 if os.path.isfile( os.path.join( Roms_Folder,Rom_Path[:-4]+'.cue' ) ):
888 Write_List_File = 0
889 else:
890 Write_List_File = 1
891 else:
892 Write_List_File = 0
893 ## Create the rest of the layout xml file.
894 if Write_List_File:
895 ## Show the progress bar progress and write rom list file.
896 RomListCount = RomListCount + 1
897 with open( os.path.join( Games_List_Path, 'gamelist.xml' ), "a") as outputmenufile:
898 if Emu_Name == "fba" or Emu_Name == "fbl" or Emu_Name == "fblc" or Emu_Name == "fbaxxx":
899 pDialog.update((CountList * 100) / len(os.listdir( os.path.join( Roms_Folder_Path, Emu_Name ) )),'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Rom list',FBA_Rom_Name,'This can take some time, please be patient.' )
900 WriteMenuFile = menu_entry % (CountList,FBA_Rom_Name,Synopsis1,Synopsis2,Thumbnail,"[ArtworkFolder]",'RunScript( Special://xbmc/.emustation/scripts/launcher.py,' + Emu_XBE + ',' + Rom_Name_noext + ',,' + str(CountList) + ' )',"ActivateWindow(1101)")
901 elif Emu_Name == "mame" or Emu_Name == "neogeocd":
902 pass
903 elif Emu_Name == "n64":
904 pDialog.update((CountList * 100) / len(os.listdir( Roms_Folder )),'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Rom list and coping media files',N64_Rom_Name,'This can take some time, please be patient.' )
905 WriteMenuFile = menu_entry % (CountList,N64_Rom_Name,Synopsis1,Synopsis2,Thumbnail,"[ArtworkFolder]",'RunScript( Special://xbmc/.emustation/scripts/launcher.py,' + Emu_XBE + ',' + Rom_Path + ',,' + str(CountList) + ' )',"ActivateWindow(1101)")
906 elif Emu_Name == "amiga" or Emu_Name == "pce-cd" or Emu_Name == "psx" or Emu_Name == "tg-cd" or Emu_Name == "segacd":
907 pDialog.update((CountList * 100) / Rom_Type_Total,'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Rom list',Rom_Name_noext,'This can take some time, please be patient.' )
908 WriteMenuFile = menu_entry % (CountList,Rom_Name_noext,Synopsis1,Synopsis2,Thumbnail,"[ArtworkFolder]",'RunScript( Special://xbmc/.emustation/scripts/launcher.py,' + Emu_XBE + ',' + Rom_Path + ',,' + str(CountList) + ' )',"ActivateWindow(1101)")
909 elif Emu_Name == "xbox":
910 with open(os.path.join( Xbox_Games_Folder, Rom_Name ), "r") as input:
911 GameTitle = input.readline()
912 GamePath = input.readline()
913 GameLetter = input.readline()
914 GameThumb = input.readline() + '.jpg'
915 with open( os.path.join( Media_Folder_Path, "xbox\\GameNames.txt" ),"a") as ouput:
916 ouput.write("Game Name: " + GameTitle + "SubFolder: " + GameLetter + "TitleID: " + GameThumb[:-4] + "\n\n")
917 pDialog.update((CountList * 100) / len(os.listdir( Roms_Folder )),'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Game list',GameTitle[:-1],'This can take some time, please be patient.' )
918 WriteMenuFile = menu_entry % (CountList,GameTitle[:-1],Synopsis1,Synopsis2,GameLetter[:-1]+'\\'+GameThumb,"[ArtworkFolder]",'RunScript( Special://xbmc/.emustation/scripts/launcher.py,' + GamePath[:-1] + ',empty,,' + str(CountList) + ' )',"ActivateWindow(1101)")
919 else:
920 pDialog.update((CountList * 100) / len(os.listdir( Roms_Folder )),'Creating [B][UPPERCASE]' + Emu_Name + '[/UPPERCASE][/B] Rom list',Rom_Name_noext,'This can take some time, please be patient.' )
921 WriteMenuFile = menu_entry % (CountList,Rom_Name_noext,Synopsis1,Synopsis2,Thumbnail,"[ArtworkFolder]",'RunScript( Special://xbmc/.emustation/scripts/launcher.py,' + Emu_XBE + ',' + Rom_Path + ',,' + str(CountList) + ' )',"ActivateWindow(1101)")
922 outputmenufile.write( WriteMenuFile )
923 ## Write favourites menu entries.
924 with open( os.path.join( Games_List_Path, 'favslist.xml' ), "a") as favsmenufile:
925 if Emu_Name == "fba" or Emu_Name == "fbl" or Emu_Name == "fblc" or Emu_Name == "fbaxxx":
926 WriteMenuFile = favourites_entry % (FBA_Rom_Name,Emu_XBE,Rom_Name_noext)
927 elif Emu_Name == "mame" or Emu_Name == "neogeocd":
928 pass
929 elif Emu_Name == "n64":
930 WriteMenuFile = favourites_entry % (N64_Rom_Name,Emu_XBE,Rom_Path)
931 elif Emu_Name == "xbox":
932 with open(os.path.join( Xbox_Games_Folder, Rom_Name ), "r") as input:
933 Rom_Name_noext = input.readline()
934 Emu_XBE = input.readline()
935 WriteMenuFile = favourites_entry % (Rom_Name_noext[:-1],Emu_XBE[:-1],"null")
936 else:
937 WriteMenuFile = favourites_entry % (Rom_Name_noext,Emu_XBE,Rom_Path)
938 favsmenufile.write( WriteMenuFile )
939 ## Write menu entry for quick jump.
940 with open( os.path.join( Games_List_Path, 'jumplist.xml' ), "a") as outputmenuselectfile:
941 if not Starts_with_0:
942 if JumpList_Name.startswith("#") or JumpList_Name.startswith("'") or JumpList_Name.startswith("0") or JumpList_Name.startswith("1") or JumpList_Name.startswith("2") or JumpList_Name.startswith("3") or JumpList_Name.startswith("4") or JumpList_Name.startswith("5") or JumpList_Name.startswith("6") or JumpList_Name.startswith("7") or JumpList_Name.startswith("8") or JumpList_Name.startswith("9"):
943 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"#","SetFocus(9000," + str(JumpList) + ")" )
944 Starts_with_0 = 1
945 Jump_Counter = Jump_Counter + 1
946 outputmenuselectfile.write( WriteSearchFile )
947 if not Starts_with_A:
948 if JumpList_Name.startswith("a"):
949 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"A","SetFocus(9000," + str(JumpList) + ")" )
950 Starts_with_A = 1
951 Jump_Counter = Jump_Counter + 1
952 outputmenuselectfile.write( WriteSearchFile )
953 if not Starts_with_B:
954 if JumpList_Name.startswith("b"):
955 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"B","SetFocus(9000," + str(JumpList) + ")" )
956 Starts_with_B = 1
957 Jump_Counter = Jump_Counter + 1
958 outputmenuselectfile.write( WriteSearchFile )
959 if not Starts_with_C:
960 if JumpList_Name.startswith("c"):
961 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"C","SetFocus(9000," + str(JumpList) + ")" )
962 Starts_with_C = 1
963 Jump_Counter = Jump_Counter + 1
964 outputmenuselectfile.write( WriteSearchFile )
965 if not Starts_with_D:
966 if JumpList_Name.startswith("d"):
967 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"D","SetFocus(9000," + str(JumpList) + ")" )
968 Starts_with_D = 1
969 Jump_Counter = Jump_Counter + 1
970 outputmenuselectfile.write( WriteSearchFile )
971 if not Starts_with_E:
972 if JumpList_Name.startswith("e"):
973 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"E","SetFocus(9000," + str(JumpList) + ")" )
974 Starts_with_E = 1
975 Jump_Counter = Jump_Counter + 1
976 outputmenuselectfile.write( WriteSearchFile )
977 if not Starts_with_F:
978 if JumpList_Name.startswith("f"):
979 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"F","SetFocus(9000," + str(JumpList) + ")" )
980 Starts_with_F = 1
981 Jump_Counter = Jump_Counter + 1
982 outputmenuselectfile.write( WriteSearchFile )
983 if not Starts_with_G:
984 if JumpList_Name.startswith("g"):
985 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"G","SetFocus(9000," + str(JumpList) + ")" )
986 Starts_with_G = 1
987 Jump_Counter = Jump_Counter + 1
988 outputmenuselectfile.write( WriteSearchFile )
989 if not Starts_with_H:
990 if JumpList_Name.startswith("h"):
991 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"H","SetFocus(9000," + str(JumpList) + ")" )
992 Starts_with_H = 1
993 Jump_Counter = Jump_Counter + 1
994 outputmenuselectfile.write( WriteSearchFile )
995 if not Starts_with_I:
996 if JumpList_Name.startswith("i"):
997 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"I","SetFocus(9000," + str(JumpList) + ")" )
998 Starts_with_I = 1
999 Jump_Counter = Jump_Counter + 1
1000 outputmenuselectfile.write( WriteSearchFile )
1001 if not Starts_with_J:
1002 if JumpList_Name.startswith("j"):
1003 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"J","SetFocus(9000," + str(JumpList) + ")" )
1004 Starts_with_J = 1
1005 Jump_Counter = Jump_Counter + 1
1006 outputmenuselectfile.write( WriteSearchFile )
1007 if not Starts_with_K:
1008 if JumpList_Name.startswith("k"):
1009 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"K","SetFocus(9000," + str(JumpList) + ")" )
1010 Starts_with_K = 1
1011 Jump_Counter = Jump_Counter + 1
1012 outputmenuselectfile.write( WriteSearchFile )
1013 if not Starts_with_L:
1014 if JumpList_Name.startswith("l"):
1015 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"L","SetFocus(9000," + str(JumpList) + ")" )
1016 Starts_with_L = 1
1017 Jump_Counter = Jump_Counter + 1
1018 outputmenuselectfile.write( WriteSearchFile )
1019 if not Starts_with_M:
1020 if JumpList_Name.startswith("m"):
1021 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"M","SetFocus(9000," + str(JumpList) + ")" )
1022 Starts_with_M = 1
1023 Jump_Counter = Jump_Counter + 1
1024 outputmenuselectfile.write( WriteSearchFile )
1025 if not Starts_with_N:
1026 if JumpList_Name.startswith("n"):
1027 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"N","SetFocus(9000," + str(JumpList) + ")" )
1028 Starts_with_N = 1
1029 Jump_Counter = Jump_Counter + 1
1030 outputmenuselectfile.write( WriteSearchFile )
1031 if not Starts_with_O:
1032 if JumpList_Name.startswith("o"):
1033 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"O","SetFocus(9000," + str(JumpList) + ")" )
1034 Starts_with_O = 1
1035 Jump_Counter = Jump_Counter + 1
1036 outputmenuselectfile.write( WriteSearchFile )
1037 if not Starts_with_P:
1038 if JumpList_Name.startswith("p"):
1039 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"P","SetFocus(9000," + str(JumpList) + ")" )
1040 Starts_with_P = 1
1041 Jump_Counter = Jump_Counter + 1
1042 outputmenuselectfile.write( WriteSearchFile )
1043 if not Starts_with_Q:
1044 if JumpList_Name.startswith("q"):
1045 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"Q","SetFocus(9000," + str(JumpList) + ")" )
1046 Starts_with_Q = 1
1047 Jump_Counter = Jump_Counter + 1
1048 outputmenuselectfile.write( WriteSearchFile )
1049 if not Starts_with_R:
1050 if JumpList_Name.startswith("r"):
1051 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"R","SetFocus(9000," + str(JumpList) + ")" )
1052 Starts_with_R = 1
1053 Jump_Counter = Jump_Counter + 1
1054 outputmenuselectfile.write( WriteSearchFile )
1055 if not Starts_with_S:
1056 if JumpList_Name.startswith("s"):
1057 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"S","SetFocus(9000," + str(JumpList) + ")" )
1058 Starts_with_S = 1
1059 Jump_Counter = Jump_Counter + 1
1060 outputmenuselectfile.write( WriteSearchFile )
1061 if not Starts_with_T:
1062 if JumpList_Name.startswith("t"):
1063 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"T","SetFocus(9000," + str(JumpList) + ")" )
1064 Starts_with_T = 1
1065 Jump_Counter = Jump_Counter + 1
1066 outputmenuselectfile.write( WriteSearchFile )
1067 if not Starts_with_U:
1068 if JumpList_Name.startswith("u"):
1069 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"U","SetFocus(9000," + str(JumpList) + ")" )
1070 Starts_with_U = 1
1071 Jump_Counter = Jump_Counter + 1
1072 outputmenuselectfile.write( WriteSearchFile )
1073 if not Starts_with_V:
1074 if JumpList_Name.startswith("v"):
1075 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"V","SetFocus(9000," + str(JumpList) + ")" )
1076 Starts_with_V = 1
1077 Jump_Counter = Jump_Counter + 1
1078 outputmenuselectfile.write( WriteSearchFile )
1079 if not Starts_with_W:
1080 if JumpList_Name.startswith("w"):
1081 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"W","SetFocus(9000," + str(JumpList) + ")" )
1082 Starts_with_W = 1
1083 Jump_Counter = Jump_Counter + 1
1084 outputmenuselectfile.write( WriteSearchFile )
1085 if not Starts_with_X:
1086 if JumpList_Name.startswith("x"):
1087 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"X","SetFocus(9000," + str(JumpList) + ")" )
1088 Starts_with_X = 1
1089 Jump_Counter = Jump_Counter + 1
1090 outputmenuselectfile.write( WriteSearchFile )
1091 if not Starts_with_Y:
1092 if JumpList_Name.startswith("y"):
1093 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"Y","SetFocus(9000," + str(JumpList) + ")" )
1094 Starts_with_Y = 1
1095 Jump_Counter = Jump_Counter + 1
1096 outputmenuselectfile.write( WriteSearchFile )
1097 if not Starts_with_Z:
1098 if JumpList_Name.startswith("z"):
1099 WriteSearchFile = search_menu_entry % ( str(Jump_Counter),"Z","SetFocus(9000," + str(JumpList) + ")" )
1100 Starts_with_Z = 1
1101 Jump_Counter = Jump_Counter + 1
1102 outputmenuselectfile.write( WriteSearchFile )
1103 ## Add 1 to the Countlist and JumpList.
1104 CountList = CountList + 1
1105 JumpList = JumpList + 1
1106 ## Add the footer to the layout xml file.
1107 with open( os.path.join( Games_List_Path, 'gamelist.xml' ), "a") as outputmenufile:
1108 WriteMenuFile = menu_entry_footer
1109 outputmenufile.write( WriteMenuFile )
1110 else:
1111 if os.path.isdir( Games_List_Path ): shutil.rmtree( Games_List_Path )
1112 if ManualScan == 1:
1113 dialog.ok("Error","","No roms/images found for this system")
1114 return Main_Code()
1115 ## Set the rom count and remove any direct launch rom list.xml files.
1116 xbmc.executebuiltin('Skin.SetString('+ Emu_Name +'_games,'+ str( RomListCount ) + ')')
1117 if Emu_Name == "atarijaguar" or Emu_Name == "neogeocd":
1118 if os.path.isdir( Games_List_Path ): shutil.rmtree( Games_List_Path )
1119 if os.path.isdir( Media_Path ): shutil.rmtree( Media_Path )
1120 if Emu_Name == "mame":
1121 if os.path.isfile( os.path.join( Emu_Path, "system\\ROMS.list" )): os.remove( os.path.join( Emu_Path, "system\\ROMS.list" ))
1122 if os.path.isfile( os.path.join( Emu_Path, "system\\ROMS.metadata" )): os.remove( os.path.join( Emu_Path, "system\\ROMS.metadata" ))
1123 if os.path.isdir( Games_List_Path ): shutil.rmtree( Games_List_Path )
1124 if os.path.isdir( Media_Path ): shutil.rmtree( Media_Path )
1125 ## ManualMode - Set a property so I can run the next script without this one running on.
1126 if Found_Roms == 1 and ManualScan == 1:
1127 xbmcgui.Window(xbmcgui.getCurrentWindowId()).setProperty("MyScript.ExternalRunning", "True")
1128 ## Running the scan script to update the counters.
1129 xbmc.executebuiltin('RunScript(' + Scripts_Path + 'refresh_carousel.py,0,' + Emu_Name + ',0,0)' )
1130 ## Loop.
1131 while (xbmcgui.Window(xbmcgui.getCurrentWindowId()).getProperty("MyScript.ExternalRunning") == "True"):
1132 time.sleep(0.2)
1133 if os.path.isdir( os.path.join( Emulator_Folder_Path, "xbox" ) ): shutil.rmtree( os.path.join( Emulator_Folder_Path, "xbox" ) )
1134 pDialog.close()
1135 return
1136 ## AutoMode - Set a property so I can run the next script without this one running on.
1137 if Found_Roms == 1 and ManualScan == 0:
1138 xbmcgui.Window(xbmcgui.getCurrentWindowId()).setProperty("MyScript.ExternalRunning", "True")
1139 ## Running the scan script to update the counters.
1140 xbmc.executebuiltin('RunScript(' + Scripts_Path + 'refresh_carousel.py,scan_emus,0,0,0)' )
1141 ## Loop.
1142 while (xbmcgui.Window(xbmcgui.getCurrentWindowId()).getProperty("MyScript.ExternalRunning") == "True"):
1143 time.sleep(0.2)
1144 if os.path.isdir( os.path.join( Emulator_Folder_Path, "xbox" ) ): shutil.rmtree( os.path.join( Emulator_Folder_Path, "xbox" ) )
1145 else:
1146 if os.path.isdir( os.path.join( Emulator_Folder_Path, "xbox" ) ): shutil.rmtree( os.path.join( Emulator_Folder_Path, "xbox" ) )
1147 pDialog.close()
1148 return
1149
1150menu_entry_header = '<content>\n<!--\nTags used in the xml files:\nname = $INFO[listitem.Label]\ndetails = $INFO[listitem.Label2]\nsynopsis = $INFO[listitem.ActualIcon]\nthumbnail = $INFO[listitem.Thumb]\nmediapath = $INFO[listitem.SortLetter]\n-->'
1151menu_entry = '\n <item id="%s">\n <name>%s</name>\n <details>%s</details>\n <synopsis>%s</synopsis>\n <thumbnail>%s</thumbnail>\n <mediapath>%s</mediapath>\n <onclick>%s</onclick>\n <onclick>%s</onclick>\n </item>'
1152menu_entry_footer = '\n</content>'
1153search_menu_entry = '<control type="button" id="%s">\n <label>[UPPERCASE]jump to letter[/UPPERCASE]</label>\n <label2>< [UPPERCASE]%s[/UPPERCASE] ></label2>\n <include>MenuButtonCommonValues</include>\n <onclick>Dialog.Close(1120)</onclick>\n <onclick>%s</onclick>\n</control>\n'
1154favourites_entry = '<favourites>%s|%s|%s</favourites>\n'
1155n64_config = '[Settings]\nskinname=Default\nonhd=true\nHideLaunchScreens=true\nEnableXMVPreview=false\nEnableVideoAudio=false\nEnableInfoPanel=false\nEnableBGMusic=false\nRandomBGMusic=false\nAudioBoost=false\nPathRoms=%s\\\nPathMedia=D:\Media\\\nPathSkins=D:\Skins\\\nPathSaves=D:\Saves\\\nPathScreenshots=D:\Screenshots\\'
1156mame_config = '[Directories]\nALTDrive = t\nC_Mapping = \\device\\harddisk0\\partition1\nE_Mapping = \\device\\harddisk0\\partition1\nF_Mapping = \\device\\harddisk0\\partition6\nG_Mapping = \\device\\harddisk0\\partition7\nH_Mapping = \\device\\cdrom0\nRomsPath0 = %s\nRomsPath1 = d:\\roms\nRomsPath2 = d:\\roms\nRomsPath3 = d:\\roms\nArtPath = d:\\artwork\nAudioPath = d:\\samples\nConfigPath = d:\\cfg\nGeneralPath = d:\\general\nHDImagePath = d:\\hdimages\nHiScoresPath = d:\\hiscores\nNVRamPath = d:\\nvram\nBackupPath = d:\\roms\\backup\nScreenshotPath = d:\\screenshots\nAutoBootSavePath = d:\\autobootsaves\n\n\n[General]\nbios = 0\nCheatsEnabled = 1\nCheatFilename = cheat.dat\nSkipDisclaimer = 1\nSkipGameInfo = 1\nSkipWarnings = 1\nScreenSaverTimeout = 10\n\n\n[Input]\nLightgun1_Left = 4294934529\nLightgun1_CenterX = 0\nLightgun1_Right = 32767\nLightgun1_Top = 32767\nLightgun1_CenterY = 0\nLightgun1_Bottom = 4294934529\nLightgun2_Left = 4294934529\nLightgun2_CenterX = 0\nLightgun2_Right = 32767\nLightgun2_Top = 32767\nLightgun2_CenterY = 0\nLightgun2_Bottom = 4294934529\nLightgun3_Left = 4294934529\nLightgun3_CenterX = 0\nLightgun3_Right = 32767\nLightgun3_Top = 32767\nLightgun3_CenterY = 0\nLightgun3_Bottom = 4294934529\nLightgun4_Left = 4294934529\nLightgun4_CenterX = 0\nLightgun4_Right = 32767\nLightgun4_Top = 32767\nLightgun4_CenterY = 0\nLightgun4_Bottom = 4294934529\n\n\n[Network]\nDisableNetworking = 0\nIPAddress = \nGateway = \nSubnet = \nNameServer = \n\n\n[ROMListOptions]\nDisplayMode = 1\nSortMode = 0\nShowROMStatus = 0\nShowFAVEStatus = 1\nHideFilteredROMs = 0\nFilterMode = 0\nCursorPosition = 0.000000\nPageOffset = 0.000000\nSuperscrollIndex = 0\n\n\n[SkinOptions]\nSelectedSkin = Original\n\n\n[Sound]\nSoundEnable = 1\nSampleRate = 44100\nUseSamples = 1\nUseFilter = 1\n\n\n[VMMOptions]\nForceVMM = 0\nThreshold = 4194304\nCommitSize = 1048576\nDistribute = 65535\n\n\n[VectorOptions]\nVectorWidth = 640\nVectorHeight = 480\nBeamWidth = 2\nFlickerEffect = 0.000000\nBeamIntensity = 1.500000\nTranslucency = 1\n\n\n[Video]\nVSYNC = 1\nThrottleFramerate = 1\nAspectRatioCorrection = 1\nMinificationFilter = 2\nMagnificationFilter = 2\nFrameskip = 4294967295\nGraphicsFilter = 0\nSoftDisplayFilter = 0\nFlickerFilter = 5\nScreenRotation = 0\nBrightness = 1.000000\nPauseBrightness = 0.650000\nGamma = 1.000000\nScreenUsage_X = 0.850000\nScreenUsage_Y = 0.850000\nScreenPos_X = 0.000000\nScreenPos_Y = 0.000000\nArtwork = 1\n\n\n'
1157fbl_config = 'UsePathINI=1\nROMPath1=D:\\roms\nROMPath2=\nROMPath3=\nROMPath4=\nROMPath5=\nROMPath6=\nROMPath7=\nROMPath8=\nD:\\artwork\\Shots 1\nD:\\artwork\\Shots 2\nD:\\artwork\\Shots 3\nD:\\artwork\\Shots 4\nD:\\artwork\\Shots 5\nD:\\artwork\\Shots 6\nD:\\artwork\\Shots 7\nD:\\artwork\\Shots 8\nD:\\nvram\nD:\\samples\nD:\\ini\nD:\\savestates\nD:\\config\nD:\\hiscores\nD:\\videos\n'
1158
1159if Manual_Scan == "manual" :
1160 ManualScan = 1
1161 Main_Code()
1162
1163if Full_Scan == "auto" :
1164 if dialog.yesno("QUESTION TIME","","Would you like to auto scan your roms?"):
1165 ManualScan = 0
1166 Main_Code()