Move time remaining (webpage related) - for live broadcast

Discussion of chess software programming and technical issues.

Moderator: Ras

Martin Thoresen
Posts: 1833
Joined: Thu Jun 22, 2006 12:07 am

Move time remaining (webpage related) - for live broadcast

Post by Martin Thoresen »

Does anyone know how to do the following with the following html code:

Make a php script that can extract/calculate the time remaining for black and white during the games in my live broadcast?

A lot of people has asked for this feature but I am afraid that's a bit above my skill level to implement.

Time control is 120 minutes from move 1 then add 60 minutes after move 40 then add 15 minutes after move 60 with an increment of 30 sec added per move from move 61.

The number after this code <FONT color=red> 5:26 is the time used for this move. The move number is displayed like this <a href="javascript:g0(7,0)" id='a6' class='e0'>4.h4</a>
The code is similar all the way through.

So in this case after 4.h4 white has 120 minutes - 5:26 = 114 minutes and 34 seconds left.

Code: Select all

<P><B>
<a href="javascript:g0(1,0)" id='a0' class='e0' name="zeroAnchor">1.e4</a>
 <a href="javascript:g0(2,0)" id='a1' class='e0'>e5</a>
 <a href="javascript:g0(3,0)" id='a2' class='e0'>2.f4</a>
 <a href="javascript:g0(4,0)" id='a3' class='e0'>exf4</a>
 <a href="javascript:g0(5,0)" id='a4' class='e0'>3.Nf3</a>
 <a href="javascript:g0(6,0)" id='a5' class='e0'>g5</a>
 </B><FONT color=blue> -0.48/28 </FONT><FONT color=red> 5:26 </FONT> <B><a href="javascript:g0(7,0)" id='a6' class='e0'>4.h4</a>
 </B>(Bc4) <FONT color=blue> -0.22/21 </FONT><FONT color=red> 7:20 </FONT> <B><a href="javascript:g0(8,0)" id='a7' class='e0'>4...g4</a>
 </B><FONT color=blue> -0.28/31 </FONT><FONT color=red> 4:55 </FONT> <B><a href="javascript:g0(9,0)" id='a8' class='e0'>5.Ne5</a>
 </B><FONT color=blue> -0.22/20 </FONT><FONT color=red> 2:01 </FONT> <B><a href="javascript:g0(10,0)" id='a9' class='e0'>Qe7</a>
 </B>(h5) <FONT color=blue> -0.60/31 </FONT><FONT color=red> 4:32 </FONT> <B><a href="javascript:g0(11,0)" id='a10' class='e0'>6.d4</a>
 </B><FONT color=blue> -0.24/21 </FONT><FONT color=red> 5:34 </FONT> <B><a href="javascript:g0(12,0)" id='a11' class='e0'>d6</a>
 </B><FONT color=blue> -0.52/31 </FONT><FONT color=red> 5:15 </FONT> <B><a href="javascript:g0(13,0)" id='a12' class='e0'>7.Nxg4</a>
 </B><FONT color=blue> -0.33/21 </FONT><FONT color=red> 2:09 </FONT> <B><a href="javascript:g0(14,0)" id='a13' class='e0'>Qxe4+</a>
 </B><FONT color=blue> -0.44/31 </FONT><FONT color=red> 3:50 </FONT> <B><a href="javascript:g0(15,0)" id='a14' class='e0'>8.Qe2</a>
 </B><FONT color=blue> -0.33/22 </FONT><FONT color=red> 59 </FONT> <B><a href="javascript:g0(16,0)" id='a15' class='e0'>Qe7</a>
 </B><FONT color=blue> -0.44/32 </FONT><FONT color=red> 6:39 </FONT> <B><a href="javascript:g0(17,0)" id='a16' class='e0'>9.Qxe7+</a>
 </B><FONT color=blue> -0.33/21 </FONT><FONT color=red> 4:04 </FONT> <B><a href="javascript:g0(18,0)" id='a17' class='e0'>Bxe7</a>
 </B><FONT color=blue> -0.36/32 </FONT><FONT color=red> 2:59 </FONT> <B><a href="javascript:g0(19,0)" id='a18' class='e0'>10.Nf2</a>
 </B>(Be2) <FONT color=blue> -0.24/22 </FONT><FONT color=red> 3:54 </FONT> <B><a href="javascript:g0(20,0)" id='a19' class='e0'>10...Nc6</a>
 </B><FONT color=blue> -0.40/30 </FONT><FONT color=red> 7:07 </FONT> <B><a href="javascript:g0(21,0)" id='a20' class='e0'>11.c3</a>
 </B><FONT color=blue> -0.12/20 </FONT><FONT color=red> 1:41 </FONT> <B><a href="javascript:g0(22,0)" id='a21' class='e0'>Nf6</a>
 </B><FONT color=blue> -0.28/29 </FONT><FONT color=red> 4:44 </FONT> <B><a href="javascript:g0(23,0)" id='a22' class='e0'>12.Be2</a>
 </B><FONT color=blue> -0.10/21 </FONT><FONT color=red> 3:11 </FONT> <B><a href="javascript:g0(24,0)" id='a23' class='e0'>Rg8</a>
 </B>(Be6) <FONT color=blue> -0.32/30 </FONT><FONT color=red> 6:16 </FONT> <B><a href="javascript:g0(25,0)" id='a24' class='e0'>13.Bf3</a>
 </B><FONT color=blue> -0.10/22 </FONT><FONT color=red> 4:29 </FONT> <B><a href="javascript:g0(26,0)" id='a25' class='e0'>Be6</a>
 </B><FONT color=blue> -0.48/30 </FONT><FONT color=red> 2:27 </FONT> <B><a href="javascript:g0(27,0)" id='a26' class='e0'>14.Bxf4</a>
 </B><FONT color=blue> -0.10/21 </FONT><FONT color=red> 2:22 </FONT> <B><a href="javascript:g0(28,0)" id='a27' class='e0'>Bd5</a>
 </B>(Kd7) <FONT color=blue> -0.44/27 </FONT><FONT color=red> 2:05 </FONT> <B><a href="javascript:g0(29,0)" id='a28' class='e0'>15.Ke2</a>
 </B><FONT color=blue> -0.09/20 </FONT><FONT color=red> 2:05 </FONT> <B><a href="javascript:g0(30,0)" id='a29' class='e0'>Kd7</a>
 </B><FONT color=blue> -0.36/27 </FONT><FONT color=red> 2:19 </FONT> <B><a href="javascript:g0(31,0)" id='a30' class='e0'>16.Nd2</a>
 </B><FONT color=blue> -0.08/20 </FONT><FONT color=red> 2:43 </FONT> <B><a href="javascript:g0(32,0)" id='a31' class='e0'>Rae8</a>
 </B><FONT color=blue> -0.36/26 </FONT><FONT color=red> 2:05 </FONT> <B><a href="javascript:g0(33,0)" id='a32' class='e0'>17.Nde4</a>
 </B>(Rag1) <FONT color=blue> -0.07/20 </FONT><FONT color=red> 1:38 </FONT> <B><a href="javascript:g0(34,0)" id='a33' class='e0'>17...Nxe4</a>
 </B><FONT color=blue> -0.68/29 </FONT><FONT color=red> 1:56 </FONT> <B><a href="javascript:g0(35,0)" id='a34' class='e0'>18.Nxe4</a>
 </B><FONT color=blue> -0.07/20 </FONT><FONT color=red> 34 </FONT> <B><a href="javascript:g0(36,0)" id='a35' class='e0'>f5</a>
 </B><FONT color=blue> -0.40/31 </FONT><FONT color=red> 2:19 </FONT> <B><a href="javascript:g0(37,0)" id='a36' class='e0'>19.Nd2</a>
 </B><FONT color=blue> -0.13/20 </FONT><FONT color=red> 1:10 </FONT> <B><a href="javascript:g0(38,0)" id='a37' class='e0'>Bg5+</a>
 </B>(Bxf3+) <FONT color=blue> -0.44/32 </FONT><FONT color=red> 2:02 </FONT> <B><a href="javascript:g0(39,0)" id='a38' class='e0'>20.Kd3</a>
 </B><FONT color=blue> 0.00/20 </FONT><FONT color=red> 1:00 </FONT> <B><a href="javascript:g0(40,0)" id='a39' class='e0'>Be4+</a>
 </B><FONT color=blue> -0.32/33 </FONT><FONT color=red> 2:11 </FONT> <B><a href="javascript:g0(41,0)" id='a40' class='e0'>21.Bxe4</a>
 </B><FONT color=blue> 0.05/21 </FONT><FONT color=red> 37 </FONT> <B><a href="javascript:g0(42,0)" id='a41' class='e0'>fxe4+</a>
 </B><FONT color=blue> -0.48/28 </FONT><FONT color=red> 12 </FONT> <B><a href="javascript:g0(43,0)" id='a42' class='e0'>22.Nxe4</a>
 </B><FONT color=blue> 0.00/22 </FONT><FONT color=red> 39 </FONT> <B><a href="javascript:g0(44,0)" id='a43' class='e0'>Bxf4</a>
 </B><FONT color=blue> -0.28/33 </FONT><FONT color=red> 2:03 </FONT> <B><a href="javascript:g0(45,0)" id='a44' class='e0'>23.Nf6+</a>
 </B><FONT color=blue> 0.00/22 </FONT><FONT color=red> 39 </FONT> <B><a href="javascript:g0(46,0)" id='a45' class='e0'>Kd8</a>
 </B><FONT color=blue> -0.32/33 </FONT><FONT color=red> 2:13 </FONT> <B><a href="javascript:g0(47,0)" id='a46' class='e0'>24.Nxg8</a>
 </B><FONT color=blue> 0.00/25 </FONT><FONT color=red> 3:22 </FONT> <B><a href="javascript:g0(48,0)" id='a47' class='e0'>Rxg8</a>
 </B><FONT color=blue> -0.28/30 </FONT><FONT color=red> 10 </FONT> <B><a href="javascript:g0(49,0)" id='a48' class='e0'>25.Raf1</a>
 </B><FONT color=blue> 0.00/26 </FONT><FONT color=red> 4:29 </FONT> <B><a href="javascript:g0(50,0)" id='a49' class='e0'>Rg4</a>
 </B><FONT color=blue> -0.44/34 </FONT><FONT color=red> 2:42 </FONT> <B><a href="javascript:g0(51,0)" id='a50' class='e0'>26.Rf3</a>
 </B>(Ke4) <FONT color=blue> 0.00/26 </FONT><FONT color=red> 4:02 </FONT> <B><a href="javascript:g0(52,0)" id='a51' class='e0'>26...d5</a>
 </B>(h5) <FONT color=blue> -0.64/36 </FONT><FONT color=red> 2:53 </FONT> <B><a href="javascript:g0(53,0)" id='a52' class='e0'>27.g3</a>
 </B>(Rhf1) <FONT color=blue> -0.12/24 </FONT><FONT color=red> 3:40 </FONT> <B><a href="javascript:g0(54,0)" id='a53' class='e0'>27...Bd6</a>
 </B><FONT color=blue> -0.68/31 </FONT><FONT color=red> 2:53 </FONT> <B><a href="javascript:g0(55,0)" id='a54' class='e0'>28.Rg1</a>
 </B><FONT color=blue> -0.19/25 </FONT><FONT color=red> 13:08 </FONT> <B><a href="javascript:g0(56,0)" id='a55' class='e0'>Ke8</a>
 </B><FONT color=blue> -0.68/31 </FONT><FONT color=red> 1:53 </FONT> <B><a href="javascript:g0(57,0)" id='a56' class='e0'>29.Rf6</a>
 </B>(Rg2) <FONT color=blue> -0.19/24 </FONT><FONT color=red> 3:23 </FONT> <B><a href="javascript:g0(58,0)" id='a57' class='e0'>29...Ne7</a>
 </B><FONT color=blue> -0.88/36 </FONT><FONT color=red> 2:10 </FONT> <B><a href="javascript:g0(59,0)" id='a58' class='e0'>30.Rh6</a>
 </B><FONT color=blue> -0.20/24 </FONT><FONT color=red> 3:23 </FONT> <B><a href="javascript:g0(60,0)" id='a59' class='e0'>Rg7</a>
 </B><FONT color=blue> -0.92/36 </FONT><FONT color=red> 2:01 </FONT> <B><a href="javascript:g0(61,0)" id='a60' class='e0'>31.g4</a>
 </B><FONT color=blue> -0.19/23 </FONT><FONT color=red> 1:40 </FONT> <B><a href="javascript:g0(62,0)" id='a61' class='e0'>Rf7</a>
 </B><FONT color=blue> -0.80/32 </FONT><FONT color=red> 2:04 </FONT> <B><a href="javascript:g0(63,0)" id='a62' class='e0'>32.Kc2</a>
 </B>(Re6) <FONT color=blue> -0.20/24 </FONT><FONT color=red> 1:51 </FONT> <B><a href="javascript:g0(64,0)" id='a63' class='e0'>32...Ng8</a>
 </B>(Ng6) <FONT color=blue> -1.37/33 </FONT><FONT color=red> 3:02 </FONT> <B><a href="javascript:g0(65,0)" id='a64' class='e0'>33.Re6+</a>
 </B><FONT color=blue> -0.21/25 </FONT><FONT color=red> 2:16 </FONT> <B><a href="javascript:g0(66,0)" id='a65' class='e0'>Kd7</a>
 </B><FONT color=blue> -1.37/38 </FONT><FONT color=red> 2:29 </FONT> <B><a href="javascript:g0(67,0)" id='a66' class='e0'>34.Ree1</a>
 </B>(Re2) <FONT color=blue> -0.14/24 </FONT><FONT color=red> 2:23 </FONT> <B><a href="javascript:g0(68,0)" id='a67' class='e0'>34...Rf2+</a>
 </B>(Nf6) <FONT color=blue> -1.49/37 </FONT><FONT color=red> 2:40 </FONT> <B><a href="javascript:g0(69,0)" id='a68' class='e0'>35.Kb3</a>
 </B>(Kc1) <FONT color=blue> -0.18/27 </FONT><FONT color=red> 5:05 </FONT> <B><a href="javascript:g0(70,0)" id='a69' class='e0'>35...Nf6</a>
 </B><FONT color=blue> -1.69/39 </FONT><FONT color=red> 2:15 </FONT> <B><a href="javascript:g0(71,0)" id='a70' class='e0'>36.Ref1</a>
 </B><FONT color=blue> -0.19/27 </FONT><FONT color=red> 2:34 </FONT> <B><a href="javascript:g0(72,0)" id='a71' class='e0'>Rxf1</a>
 </B><FONT color=blue> -1.77/39 </FONT><FONT color=red> 6:19 </FONT> <B><a href="javascript:g0(73,0)" id='a72' class='e0'>37.Rxf1</a>
 </B><FONT color=blue> -0.19/28 </FONT><FONT color=red> 25 </FONT> <B><a href="javascript:g0(74,0)" id='a73' class='e0'>Ke6</a>
 </B><FONT color=blue> -1.61/36 </FONT><FONT color=red> 2:59 </FONT> <B><a href="javascript:g0(75,0)" id='a74' class='e0'>38.Rg1</a>
 </B>(Re1+) <FONT color=blue> -0.32/27 </FONT><FONT color=red> 6:15 </FONT> <B><a href="javascript:g0(76,0)" id='a75' class='e0'>38...Ne4</a>
 </B><FONT color=blue> -1.73/34 </FONT><FONT color=red> 2:51 </FONT> <B><a href="javascript:g0(77,0)" id='a76' class='e0'>39.a4</a>
 </B>(Re1) <FONT color=blue> -0.32/27 </FONT><FONT color=red> 3:16 </FONT> <B><a href="javascript:g0(78,0)" id='a77' class='e0'>39...Bg3</a>
 </B><FONT color=blue> -1.61/37 </FONT><FONT color=red> 2:15 </FONT> <B><a href="javascript:g0(79,0)" id='a78' class='e0'>40.a5</a>
 </B>(Rh1) <FONT color=blue> -0.35/27 </FONT><FONT color=red> 3:30 </FONT> <B><a href="javascript:g0(80,0)" id='a79' class='e0'>40...a6</a>
 </B><FONT color=blue> -1.65/36 </FONT><FONT color=red> 1:27 </FONT> <B><a href="javascript:g0(81,0)" id='a80' class='e0'>41.Rh1</a>
 </B><FONT color=blue> -0.41/26 </FONT><FONT color=red> 1:19 </FONT> <B><a href="javascript:g0(82,0)" id='a81' class='e0'>Kf7</a>
 </B>(Nf6) <FONT color=blue> -1.77/38 </FONT><FONT color=red> 2:11 </FONT> <B><a href="javascript:g0(83,0)" id='a82' class='e0'>42.Rh3</a>
 </B><FONT color=blue> -0.45/27 </FONT><FONT color=red> 2:46 </FONT> <B><a href="javascript:g0(84,0)" id='a83' class='e0'>Kg6</a>
 </B>(Kf6) <FONT color=blue> -1.89/39 </FONT><FONT color=red> 2:23 </FONT> <B><a href="javascript:g0(85,0)" id='a84' class='e0'>43.Kc2</a>
 </B>(Ka4) <FONT color=blue> -0.45/28 </FONT><FONT color=red> 4:06 </FONT> <B><a href="javascript:g0(86,0)" id='a85' class='e0'>43...c6</a>
 </B><FONT color=blue> -1.69/38 </FONT><FONT color=red> 2:13 </FONT> <B><a href="javascript:g0(87,0)" id='a86' class='e0'>44.Kb3</a>
 </B><FONT color=blue> -0.45/28 </FONT><FONT color=red> 1:34 </FONT> <B><a href="javascript:g0(88,0)" id='a87' class='e0'>Bc7</a>
 </B>(h5) <FONT color=blue> -1.85/39 </FONT><FONT color=red> 2:28 </FONT> <B><a href="javascript:g0(89,0)" id='a88' class='e0'>45.Ka4</a>
 </B><FONT color=blue> -0.53/26 </FONT><FONT color=red> 3:12 </FONT> <B><a href="javascript:g0(90,0)" id='a89' class='e0'>h6</a>
 </B>(Bd8) <FONT color=blue> -1.65/37 </FONT><FONT color=red> 2:07 </FONT> <B><a href="javascript:g0(91,0)" id='a90' class='e0'>46.Rf3</a>
 </B><FONT color=blue> -0.38/28 </FONT><FONT color=red> 2:35 </FONT> <B><a href="javascript:g0(92,0)" id='a91' class='e0'>Bd8</a>
 </B><FONT color=blue> -1.77/38 </FONT><FONT color=red> 2:20 </FONT> <B><a href="javascript:g0(93,0)" id='a92' class='e0'>47.h5+</a>
 </B>(Rh3) <FONT color=blue> -0.38/28 </FONT><FONT color=red> 1:45 </FONT> <B><a href="javascript:g0(94,0)" id='a93' class='e0'>47...Kg7</a>
 </B><FONT color=blue> -1.77/41 </FONT><FONT color=red> 2:42 </FONT> <B><a href="javascript:g0(95,0)" id='a94' class='e0'>48.Re3</a>
 </B><FONT color=blue> -0.38/29 </FONT><FONT color=red> 2:04 </FONT> <B><a href="javascript:g0(96,0)" id='a95' class='e0'>Bg5</a>
 </B>(Be7) <FONT color=blue> -1.81/41 </FONT><FONT color=red> 2:21 </FONT> <B><a href="javascript:g0(97,0)" id='a96' class='e0'>49.Re1</a>
 </B><FONT color=blue> -0.38/30 </FONT><FONT color=red> 3:42 </FONT> <B><a href="javascript:g0(98,0)" id='a97' class='e0'>Bf4</a>
 </B>(Kf7) <FONT color=blue> -1.69/40 </FONT><FONT color=red> 2:53 </FONT> <B><a href="javascript:g0(99,0)" id='a98' class='e0'>50.Rf1</a>
 </B><FONT color=blue> -0.38/28 </FONT><FONT color=red> 1:37 </FONT> <B><a href="javascript:g0(100,0)" id='a99' class='e0'>Be3</a>
 </B>(Bd6) <FONT color=blue> -1.73/41 </FONT><FONT color=red> 2:53 </FONT> <B><a href="javascript:g0(101,0)" id='a100' class='e0'>51.Rf5</a>
 </B>(Ka3) <FONT color=blue> -0.52/29 </FONT><FONT color=red> 3:36 </FONT> <B><a href="javascript:g0(102,0)" id='a101' class='e0'>51...Bc1</a>
 </B><FONT color=blue> -1.89/41 </FONT><FONT color=red> 3:50 </FONT> <B><a href="javascript:g0(103,0)" id='a102' class='e0'>52.Kb3</a>
 </B><FONT color=blue> -0.52/28 </FONT><FONT color=red> 45 </FONT> <B><a href="javascript:g0(104,0)" id='a103' class='e0'>Bg5</a>
 </B><FONT color=blue> -1.81/43 </FONT><FONT color=red> 2:57 </FONT> <B><a href="javascript:g0(105,0)" id='a104' class='e0'>53.Re5</a>
 </B>(Ka4) <FONT color=blue> -0.52/29 </FONT><FONT color=red> 1:57 </FONT> <B><a href="javascript:g0(106,0)" id='a105' class='e0'>53...Kf7</a>
 </B><FONT color=blue> -1.89/40 </FONT><FONT color=red> 2:32 </FONT> <B><a href="javascript:g0(107,0)" id='a106' class='e0'>54.Rf5+</a>
 </B><FONT color=blue> -0.52/29 </FONT><FONT color=red> 2:15 </FONT> <B><a href="javascript:g0(108,0)" id='a107' class='e0'>Ke8</a>
 </B><FONT color=blue> -1.97/45 </FONT><FONT color=red> 3:00 </FONT> <B><a href="javascript:g0(109,0)" id='a108' class='e0'>55.Kb4</a>
 </B><FONT color=blue> -0.53/30 </FONT><FONT color=red> 5:12 </FONT> <B><a href="javascript:g0(110,0)" id='a109' class='e0'>Bh4</a>
 </B>(Nd6) <FONT color=blue> -1.97/44 </FONT><FONT color=red> 3:54 </FONT> <B><a href="javascript:g0(111,0)" id='a110' class='e0'>56.Rf1</a>
 </B>(Rf3) <FONT color=blue> -0.79/28 </FONT><FONT color=red> 5:13 </FONT> <B><a href="javascript:g0(112,0)" id='a111' class='e0'>56...Nd2</a>
 </B><FONT color=blue> -1.77/42 </FONT><FONT color=red> 3:23 </FONT> <B><a href="javascript:g0(113,0)" id='a112' class='e0'>57.Rh1</a>
 </B><FONT color=blue> -0.87/30 </FONT><FONT color=red> 4:24 </FONT> <B><a href="javascript:g0(114,0)" id='a113' class='e0'>Bd8</a>
 </B>(Be7+) <FONT color=blue> -2.10/41 </FONT><FONT color=red> 4:42 </FONT> <B><a href="javascript:g0(115,0)" id='a114' class='e0'>58.Re1+</a>
 </B>(Rh2) <FONT color=blue> -0.82/28 </FONT><FONT color=red> 4:18 </FONT> <B><a href="javascript:g0(116,0)" id='a115' class='e0'>58...Kf7</a>
 </B>(Kd7) <FONT color=blue> -2.30/40 </FONT><FONT color=red> 4:42 </FONT> <B><a href="javascript:g0(117,0)" id='a116' class='e0'>59.Ka4</a>
 </B>(Rg1) <FONT color=blue> -0.82/29 </FONT><FONT color=red> 3:35 </FONT> <B><a href="javascript:g0(118,0)" id='a117' class='e0'>59...Nc4</a>
 </B>(Bg5) <FONT color=blue> -2.38/40 </FONT><FONT color=red> 3:08 </FONT> <B><a href="javascript:g0(119,0)" id='a118' class='e0'>60.Rf1+</a>
 </B><FONT color=blue> -0.85/28 </FONT><FONT color=red> 2:37 </FONT> <B><a href="javascript:g0(120,0)" id='a119' class='e0'>Kg7</a>
 </B><FONT color=blue> -2.26/39 </FONT><FONT color=red> 2:32 </FONT> <B><a href="javascript:g0(121,0)" id='a120' class='e0'>61.Re1</a>
 </B>(Rf2) <FONT color=blue> -0.85/29 </FONT><FONT color=red> 2:48 </FONT> <B><a href="javascript:g0(122,0)" id='a121' class='e0'>61...Nxb2+</a>
 </B><FONT color=blue> -2.42/37 </FONT><FONT color=red> 1:02 </FONT> <B><a href="javascript:g0(123,0)" id='a122' class='e0'>62.Kb3</a>
 </B><FONT color=blue> -0.85/29 </FONT><FONT color=red> 27 </FONT> <B><a href="javascript:g0(124,0)" id='a123' class='e0'>Nc4</a>
 </B><FONT color=blue> -2.58/38 </FONT><FONT color=red> 1:07 </FONT> <B><a href="javascript:g0(125,0)" id='a124' class='e0'>63.Re8</a>
 </B><FONT color=blue> -0.85/29 </FONT><FONT color=red> 27 </FONT> <B><a href="javascript:g0(126,0)" id='a125' class='e0'>Bg5</a>
 </B>(Bf6) <FONT color=blue> -2.26/37 </FONT><FONT color=red> 49 </FONT> <B><a href="javascript:g0(127,0)" id='a126' class='e0'>64.Ka4</a>
 </B><FONT color=blue> -1.20/28 </FONT><FONT color=red> 2:56 </FONT> <B><a href="javascript:g0(128,0)" id='a127' class='e0'>Bd2</a>
 </B>(Nd6) <FONT color=blue> -2.90/33 </FONT><FONT color=red> 49 </FONT> <B><a href="javascript:g0(129,0)" id='a128' class='e0'>65.Kb4</a>
 </B><FONT color=blue> -1.20/26 </FONT><FONT color=red> 3:50 </FONT> <B><a href="javascript:g0(130,0)" id='a129' class='e0'>Nd6</a>
 </B><FONT color=blue> -2.70/36 </FONT><FONT color=red> 50 </FONT> <B><a href="javascript:g0(131,0)" id='a130' class='e0'>66.Rb8</a>
 </B><FONT color=blue> -1.40/26 </FONT><FONT color=red> 44 </FONT> <B><a href="javascript:g0(132,0)" id='a131' class='e0'>Kf6</a>
 </B><FONT color=blue> -3.03/36 </FONT><FONT color=red> 55 </FONT> <B><a href="javascript:g0(133,0)" id='a132' class='e0'>67.Kb3</a>
 </B><FONT color=blue> -1.40/25 </FONT><FONT color=red> 3:56 </FONT> <B><a href="javascript:g0(134,0)" id='a133' class='e0'>Kg5</a>
 </B><FONT color=blue> -3.07/37 </FONT><FONT color=red> 44 </FONT> <B><a href="javascript:g0(135,0)" id='a134' class='e0'>68.Rg8+</a>
</B><FONT color=blue> -2.35/24 </FONT><FONT color=red> 38 </FONT><B> *</B></P>
</TD></TR></TABLE></P><BR><BR></CENTER>
</span></p>
ppetrov
Posts: 24
Joined: Sun Mar 21, 2010 10:48 pm
Location: Sofia, Bulgaria

Re: Move time remaining (webpage related) - for live broadca

Post by ppetrov »

Hi Martin,

Here is a Python script/class which does exactly that. I'll integrate it into the ChessBomb relay later today. Hopefully you will be able to use it as well:

Code: Select all

#!/usr/bin/python


import re
import sys
import urllib2


class FritzTimeExtractor(object):
    
    def __init__(self, url):
        self.url = url
        
    def extract(self):
        try:
            result = self._extract()
            return result
        except:
            return (0, 0)
        
    def _extract(self):
        html = self._read()
        fragment = re.search(r'</h3>..?<P>(.*?)</P>',  html, re.DOTALL).group(1)
        moves = [m[0] for m in re.findall(r'(<a(.*?)</a>(..?.?</B>.*?<B>)?)', fragment, re.DOTALL)]
        times = []
        for move in moves:
            match = re.search(r'<FONT color=red> (.*?) </FONT>', move)
            if match:
                timestr = match.group(1)
                match = re.match(r'(.*):(.*):(.*)', timestr)
                if match:
                    time = (int(match.group(1)) * 3600) + (int(match.group(2)) * 60) + int(match.group(3))
                else:
                    match = re.match(r'(.*):(.*)', timestr)
                    if match:
                        time = (int(match.group(1)) * 60) + int(match.group(2))
                    else:
                        time = int(timestr)
                times.append(time)
            else:
                times.append(0)
        plies = len(moves)
        twhite = 120 * 60
        tblack = 120 * 60
        if plies >= 79: twhite += 60 * 60
        if plies >= 80: tblack += 60 * 60
        if plies >= 119: twhite += 15 * 60
        if plies >= 120: tblack += 15 * 60
        if plies >= 119: twhite += int((plies - 119) / 2) * 30
        if plies >= 120: tblack += int((plies - 120) / 2) * 30
        for i in xrange(len(times)):
            time = times[i]
            if (i % 2 == 0):
                twhite -= time
            else:
                tblack -= time
        return (twhite, tblack)
    
    def _read(self, timeout=15):
        result = urllib2.urlopen(self.url, timeout=timeout).read()
        return result.decode('iso-8859-1')


extractor = FritzTimeExtractor(sys.argv[1])
result = extractor.extract()
print result[0], result[1]
Martin Thoresen
Posts: 1833
Joined: Thu Jun 22, 2006 12:07 am

Re: Move time remaining (webpage related) - for live broadca

Post by Martin Thoresen »

Hello Peter, I didn't know you were registered here!

Thanks for the script, but unfortunately I have no clue about Python and I do not know how to integrate it into my php.

Looking forward to seeing it in action over at chessbomb though. :D
ppetrov
Posts: 24
Joined: Sun Mar 21, 2010 10:48 pm
Location: Sofia, Bulgaria

Re: Move time remaining (webpage related) - for live broadca

Post by ppetrov »

You could call it as an external script, e.g. like this:

Code: Select all

python fritz_time_extract.py file:/path/to/the/file.htm
It will even accept a HTTP URL as a parameter. The w/b times (in seconds) will be printed on the std output (they will be zeroes if there was a parse error, but I think we eliminated that).
Martin Thoresen
Posts: 1833
Joined: Thu Jun 22, 2006 12:07 am

Re: Move time remaining (webpage related) - for live broadca

Post by Martin Thoresen »

Peter, I've sent you an email. 8-)