Changeset 631
- Timestamp:
- Dec 8, 2013, 8:06:28 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/WoWHeadLoader/WoWHeadLoader.lpr
r617 r631 53 53 function GetEndtextData(data:string): string; 54 54 procedure GetTextQuest(Id: Integer); 55 procedure UpdateQuest;56 55 57 56 function GetMaxID(TextType: string): integer; … … 63 62 GroupDB: array [1..6] of string = ('TextAchievement','TextItem','TextCreature','TextGameObject','TextArea','TextQuest'); 64 63 Column2DB: array [1..6] of string = ('Description','Description','SubName','','',''); 65 64 ImportTable: integer = 6; 66 65 { TWoWHeadLoader } 67 66 // IdHTTP1.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)'; … … 74 73 begin 75 74 // quick check parameters 76 ErrorMsg:=CheckOptions('h ','help');75 ErrorMsg:=CheckOptions('hsuptai','helpschemauserpasswordhostCharsetimporttable'); 77 76 if ErrorMsg<>'' then begin 78 77 ShowException(Exception.Create(ErrorMsg)); … … 107 106 Database.Encoding := GetOptionValue('a', 'Charset'); 108 107 end else Database.Encoding := 'utf8'; 108 if HasOption('i', 'importtable') then begin 109 ImportTable := StrToInt(GetOptionValue('i', 'importtable')); 110 end else ImportTable := 6; 109 111 110 112 Database.Connect; … … 137 139 begin 138 140 { add your help code here } 139 writeln('Usage: ',ExeName,' -h'); 141 WriteLn('Usage: ', ExtractFileName(ExeName), ' [options]'); 142 WriteLn(' -h --help Show this help'); 143 WriteLn(' -u --user Database user name, default root'); 144 WriteLn(' -p --password Database password name'); 145 WriteLn(' -s --schema Database schema name, default wowpreklad'); 146 WriteLn(' -t --host Database host name, default localhost'); 147 WriteLn(' -a --Charset Database Charset, default utf8'); 148 WriteLn(' -i --importtable Table import: TextAchievement=1,TextItem=2,TextCreature=3,TextGameObject=4,TextArea=5,TextQuest=6, default 6'); 140 149 end; 141 150 … … 145 154 begin 146 155 // UpdateQuest; 156 { 157 GetText(1132,2); 158 GetText(1132,2); 159 GetText(1284,2); 160 GetText(1180,2); 161 GetText(1327,2); 162 GetText(1361,2); 163 GetText(1384,2); 147 164 GetText(1111,1); 148 GetText(98148,2);149 165 GetText(29,3); 150 166 GetText(55,4); 151 167 GetText(15,5); 152 168 GetText(4,6); 153 for t :=1 to Length(Group) do 154 for i := 0 to 1000 do begin //GetMaxID('quest') 155 GetText(i,t); 156 // write('.'); 169 } 170 // for t :=1 to Length(Group) do 171 for i := 1 to GetMaxID(Group[ImportTable]) do begin //GetMaxID('quest') 172 GetText(i,ImportTable); 173 write('.'); 157 174 end; 158 175 //čekej před uzavřením … … 270 287 begin 271 288 //text je stejný 272 Database.Query('UPDATE ` wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');273 Database.Query('UPDATE ` wowpreklad`.`TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');289 Database.Query('UPDATE `TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 290 Database.Query('UPDATE `TextQuest` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 274 291 UpdateTranslated('textquest'); 275 292 Exit; //konec: text je stejný upravili se jenom výsledné verze … … 286 303 begin 287 304 { 288 WriteLn('INSERT INTO ` wowpreklad`.`TextQuest` ('305 WriteLn('INSERT INTO `TextQuest` (' 289 306 +'`ID` ,`Entry` ,`Title` ,`Details` ,`Objectives` ,`OfferRewardText` ,`RequestItemsText` ,`EndText` ,' 290 307 +'`ObjectiveText1` ,`ObjectiveText2` ,`ObjectiveText3` ,`ObjectiveText4` ' … … 303 320 +'0, NULL, 1,0,NULL,'+IntToStr(ImportedVersion)+','+IntToStr(ImportedVersion)+',NOW())'); 304 321 } 305 Database.Query('INSERT INTO ` wowpreklad`.`TextQuest` ('322 Database.Query('INSERT INTO `TextQuest` (' 306 323 +'`ID` ,`Entry` ,`Title` ,`Details` ,`Objectives` ,`OfferRewardText` ,`RequestItemsText` ,`EndText` ,' 307 324 +'`ObjectiveText1` ,`ObjectiveText2` ,`ObjectiveText3` ,`ObjectiveText4` ' … … 365 382 end; 366 383 367 procedure TWoWHeadLoader.UpdateQuest;368 var369 data : string;370 i:integer;371 begin372 GetTextQuest(7081);373 GetTextQuest(7122);374 GetTextQuest(9192);375 376 GetTextQuest(12509);377 378 379 GetTextQuest(12580);380 381 GetTextQuest(13369);382 383 GetTextQuest(13425);384 385 GetTextQuest(13675);386 387 GetTextQuest(13426);388 389 390 391 392 for i := 0 to GetMaxID('quest') do begin393 GetTextQuest(i);394 write('.');395 end;396 end;397 398 384 procedure TWoWHeadLoader.GetText(Id: Integer; TextType: Integer); 399 385 var … … 425 411 foundtext:=false; 426 412 Exit; 413 end; 414 415 if ('item' = Group[TextType]) then begin 416 if (Pos('<span class="q2">Use:',data) >0) then begin 417 data := skipto('<span class="q2">Use:',data); 418 data := skipto('>',data); 419 // textdescription := TextStringReplace(Copy(data,0,Pos('</a',data)-1)); 420 //zatím nefunguje 421 end; 427 422 end; 428 423 … … 436 431 //description 437 432 data := skipto('</h1>',data); 438 for i:= 0 to 4 do begin 439 data := StringReplace(data,'<br>','$B',[rfIgnoreCase]); 440 data := StringReplace(data,'<br />','$B',[rfIgnoreCase]); 441 end; 433 442 434 if ('' <> Column2DB[TextType]) then 443 if ('item' = Group[TextType]) then begin 444 data := skipto('Use:',data); 445 data := skipto('<',data); 446 // textdescription := TextStringReplace(Copy(data,0,Pos('<',data)-1)); 447 end else begin 435 if ('item' <> Group[TextType]) then begin 448 436 data := skipto('<script type="text/javascript">',data); 449 437 data := skipto('</script>',data); … … 470 458 begin 471 459 //text je stejný 472 Database.Query('UPDATE ` wowpreklad`.`'+GroupDB[TextType]+'` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');473 Database.Query('UPDATE ` wowpreklad`.`'+GroupDB[TextType]+'` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';');460 Database.Query('UPDATE `'+GroupDB[TextType]+'` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Id` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 461 Database.Query('UPDATE `'+GroupDB[TextType]+'` SET `VersionEnd` = '+IntToStr(ImportedVersion)+' WHERE `Take` = '+DBRows.Data[0].Values['Id']+' AND `Entry` ='+IntToStr(Id)+';'); 474 462 WriteLn('update'); 475 463 UpdateTranslated(GroupDB[TextType]); … … 477 465 end; 478 466 end; 479 sql := 'INSERT INTO ` wowpreklad`.`'+GroupDB[TextType]+'` (`ID` ,`Entry` ,`Name`,';467 sql := 'INSERT INTO `'+GroupDB[TextType]+'` (`ID` ,`Entry` ,`Name`,'; 480 468 if (Column2DB[TextType] <> '') then sql += '`'+Column2DB[TextType]+'` ,'; 481 469 sql +='`Language` , `User` , `Complete` ,`CompleteParts` ,`Take` ,`VersionStart` ,`VersionEnd` ,`ModifyTime`)' … … 502 490 function TWoWHeadLoader.GetMaxID(TextType: string): integer; 503 491 var 504 data :string;505 maxid:integer=1000 0; //34000 pro questy492 data,cr:string; 493 maxid:integer=1000; //34000 pro questy 506 494 begin 507 495 // http://www.wowhead.com/quests?filter=cr=30;crs=1;crv=34000 508 repeat 509 510 data := IdHTTP1.Get('http://www.wowhead.com/'+TextType+'?filter=cr=30;crs=1;crv='+IntToStr(maxid)); 511 result := maxid; 512 maxid := maxid+400; 513 until (Pos('Your criteria did not match',data) > 0); 496 if (TextType = 'quest') then begin 497 maxid := 34000; 498 cr := '30'; 499 end; 500 if (TextType = 'npc') then begin 501 //http://www.wowhead.com/npcs?filter=cr=37;crs=1;crv=10000 502 maxid := 74000; 503 cr := '37'; 504 end; 505 if (TextType = 'achievement') then begin 506 //http://www.wowhead.com/achievements?filter=cr=9;crs=1;crv=8000 507 maxid := 8000; 508 cr := '9'; 509 end; 510 if (TextType = 'object') then begin 511 //http://www.wowhead.com/objects?filter=cr=15;crs=1;crv=230000 512 maxid := 230000; 513 cr := '15'; 514 end; 515 if (TextType = 'item') then begin 516 //http://www.wowhead.com/items?filter=cr=151;crs=1;crv=106000 517 maxid := 106000; 518 cr := '151'; 519 end; 520 if (TextType = 'zone') then begin 521 maxid := 10000; 522 result := maxid; 523 Exit; 524 cr := '30'; 525 end; 526 result := maxid; 527 try 528 repeat 529 data := IdHTTP1.Get('http://www.wowhead.com/'+TextType+'s?filter=cr='+cr+';crs=1;crv='+IntToStr(maxid)); 530 result := maxid; 531 WriteLn(TextType+'s MaxID='+IntToStr(maxid)); 532 maxid := maxid+400; 533 until (Pos('Your criteria did not match',data) > 0); 534 except 535 on E: EIdHTTPProtocolException do 536 begin 537 if E.ErrorCode = 404 then begin 538 end; 539 end; 540 on E:Exception do 541 end; 514 542 end; 515 543 … … 521 549 DBRows := Database.Query('SELECT * FROM ClientVersion WHERE `Title` != "" ORDER BY `ClientVersion`.`BuildNumber` DESC LIMIT 0 , 30'); 522 550 Result := StrToInt(DBRows.Data[0].Values['BuildNumber']); 523 Database.Query('UPDATE ` wowpreklad`.`ClientVersion` SET `Imported` = 1 WHERE `clientversion`.`BuildNumber` ='+DBRows.Data[0].Values['BuildNumber']+';');551 Database.Query('UPDATE `ClientVersion` SET `Imported` = 1 WHERE `clientversion`.`BuildNumber` ='+DBRows.Data[0].Values['BuildNumber']+';'); 524 552 end; 525 553
Note:
See TracChangeset
for help on using the changeset viewer.