forked from ScriptureEarth/ScriptureEarth
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJesusFilmAPI.php
More file actions
693 lines (660 loc) · 37 KB
/
JesusFilmAPI.php
File metadata and controls
693 lines (660 loc) · 37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
<?php
// Change PHP.ini from max_input_vars = 1000 to max_input_vars = 3000 because POST has to be set for 3000!
include './include/session.php';
global $session;
/* Login attempt */
$retval = $session->checklogin();
if (!$retval) {
echo "<br /><div style='text-align: center; font-size: 16pt; font-weight: bold; padding: 10px; color: navy; background-color: #dddddd; '>You are not logged in!</div>";
/* Link back to main */
header("Location: login.php");
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Create txt using Jesus Film API with scripture_main table ISOs</title>
<style type="text/css">
html, body {
font: 100% Verdana, Arial, Helvetica, sans-serif;
color: black;
background-color: lightGrey;
height: 100%;
margin: 5px;
padding: 5px;
}
a, a:hover, a:link, a:active {
color: navy;
text-decoration: none;
border-style: none;
}
</style>
</head>
<body>
<?php
/*
1. call http://api.arclight.org/v2/media-languages?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&iso3=amu
2. do a search for "languageId" and save the number which is "8351"
3. call https://api.arclight.org/v2/media-components?apiKey=586ff4f28bd3b1.25434678&subTypes=featureFilm&languageIds=8351&metadataLanguageTags=en
4. do a search for "title" = "JESUS" and if found then save "mediaComponentId" above which is "1_jf-0-0"
5. call https://api.arclight.org/v2/media-components/1_jf-0-0/languages/8351?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&platform=web
6. do a search for "shareUrl" and if found call the linked URL is this case, "https://arc.gt/ghq0i?apiSessionId=58a232fe3e51a8.25642453"
*/
if (isset($_GET['ISO'])) {
$ISO = $_GET["ISO"]; //$_POST['ISO'];
if (!preg_match('/^([a-z]{3})$/', $ISO)) {
die('Die hacker!</body></html>');
}
require_once 'include/conn.inc.php'; // connect to the database named 'scripture'
$db = get_my_db();
$languageId = []; // initialize array
$mediaComponentId = []; // initialize array
$mediaComponentId_mag = [];
$mediaComponentId_sto = [];
$languageId_jes = []; // initialize array
$languageId_mag = []; // initialize array
$languageId_sto = []; // initialize array
$LN = []; // initialize array
$LN_jes = [];
$LN_mag = [];
$LN_sto = [];
$FileData = 0;
//require_once 'include/conn.inc.php'; // connect to the database named 'scripture'
//$db = get_my_db();
$query="SELECT ISO FROM scripture_main WHERE ISO = '$ISO'";
$result=$db->query($query);
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
$FileData = 1;
}
try {
$json = file_get_contents('http://api.arclight.org/v2/media-languages?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&iso3=' . $ISO);
}
catch (customException $e) {
echo '<br /><div style="color: red; font-size: 16pt; margin-left: 20px; font: 100% Verdana, Arial, Helvetica, sans-serif; ">Jesus Film video for ' . $ISO . ' isn\'t found.</div>';
$json = FALSE;
}
if ($json === FALSE) {
echo '<br /><div style="color: red; font-size: 16pt; margin-left: 20px; font: 100% Verdana, Arial, Helvetica, sans-serif; ">Jesus Film video for ' . $ISO . ' isn\'t found.</div>';
}
else {
$data = json_decode($json, true); // json_decode is json data
foreach ($data['_embedded']['mediaLanguages'] as $a => $value) {
$languageId[$a] = $data['_embedded']['mediaLanguages'][$a]['languageId'];
$LN[$a] = $data['_embedded']['mediaLanguages'][$a]['name'];
}
$comma_separated_language = implode(",", $languageId); // array to one string separated by ','s
$jes = 0;
$mag = 0;
$sto = 0;
for ($i=0; $i<count($languageId); $i++) {
$json = file_get_contents('https://api.arclight.org/v2/media-components?apiKey=586ff4f28bd3b1.25434678&subTypes=featureFilm&languageIds=' . $languageId[$i] . '&metadataLanguageTags=en');
$data = json_decode($json, true); // json_decode is json data
foreach ($data['_embedded']['mediaComponents'] as $a => $value) { // in case there are more then one ROD_Code
if ($data['_embedded']['mediaComponents'][$a]['title'] == 'JESUS') {
$mediaComponentId[$jes] = $data['_embedded']['mediaComponents'][$a]['mediaComponentId'];
$languageId_jes[$jes] = $languageId[$i];
$LN_jes[$jes] = $LN[$i];
$jes++;
}
//if ($data['_embedded']['mediaComponents'][$a]['title'] == "Magdalena") {
if (preg_match('/magdalena/i', $data['_embedded']['mediaComponents'][$a]['title'])) {
$mediaComponentId_mag[$mag] = $data['_embedded']['mediaComponents'][$a]['mediaComponentId'];
$languageId_mag[$mag] = $languageId[$i];
$LN_mag[$mag] = $LN[$i];
$mag++;
}
if ($data['_embedded']['mediaComponents'][$a]['title'] == 'The Story of JESUS for Children') {
$mediaComponentId_sto[$sto] = $data['_embedded']['mediaComponents'][$a]['mediaComponentId'];
$languageId_sto[$sto] = $languageId[$i];
$LN_sto[$sto] = $LN[$i];
$sto++;
}
}
}
if ($FileData == 1) {
$handle = fopen('data/' . $ISO . '/JesusFilmAPI_JESUS.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$handle = fopen('data/' . $ISO . '-JesusFilmAPI_JESUS.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
for ($i=0; $i<count($mediaComponentId); $i++) {
//for ($j=0; $j<count($languageId_jes); $j++) {
$html = '';
$json = file_get_contents('https://api.arclight.org/v2/media-components/' . $mediaComponentId[$i] . '/languages/' . $languageId_jes[$i] . '?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&platform=web');
$data = json_decode($json, true); // json_decode is json data
//$html = $data['shareUrl'];
/*$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data['shareUrl']);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$a = curl_exec($ch);*/
if ($i == 0)
for ($n = 0; $n < 50; $n++) echo "\r\n"; // clears the screen
//echo $a . '<br />';
/*if (preg_match('/location: (.+\.html\/.+\.html)/', $a, $r)) {
$html = trim($r[1]);
}*/
/*else {
echo 'skipped because $html is empty: '.$mediaComponentId[$i].'<br />';
continue;
}*/
$html = 'https://www.jesusfilm.org/watch/jesus.html/' . $LN_jes[$i] . '.html';
echo '<a href="' . $html . '" target="_blank">JESUS: ' . $ISO . ' : ' . $html . ' : ' . $LN_jes[$i] . ' : ' . $mediaComponentId[$i] . ' : ' . $languageId_jes[$i] . '</a><br />';
fwrite($handle, '<a href="' . $html . '" target="_blank">JESUS</a> ' . $ISO . ' : ' . $html . ' : ' . $LN_jes[$i] . ' : ' . $mediaComponentId[$i] . ' : ' . $languageId_jes[$i] . PHP_EOL);
// create JESUSFilm txt files
if (!is_dir('data/' . $ISO)) {
echo 'data/'. $ISO . ' does not exits. Are you running local?<br />';
continue;
}
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.en.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.en.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_en.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//echo $html . '<br />';
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.es.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.es.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_es.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.pt.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.pt.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_pt.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.fr.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.fr.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_fr.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.nl.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.nl.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_nl.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/JESUSFilm-' . $ISO . '.de.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-JESUSFilm-' . $ISO . '.de.' . $mediaComponentId[$i] . '.' . $languageId_jes[$i] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_JesusFilm_VideoPlaylist/JESUSFilm-template_de.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_jes[$i]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_jes[$i]);
//$langName = preg_replace('/,? /', '-', $LN_jes[$i]);
//$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
//$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1$LN_jes[$i].html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
//}
}
fclose($handle);
echo '<br />';
if ($FileData == 1) {
$handle = fopen('data/' . $ISO . '/JesusFilmAPI_Magdalena.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$handle = fopen('data/' . $ISO . '-JesusFilmAPI_Magdalena.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
for ($mag=0; $mag<count($mediaComponentId_mag); $mag++) {
//for ($j=0; $j<count($languageId_mag); $j++) {
$html = '';
$json = file_get_contents('https://api.arclight.org/v2/media-components/' . $mediaComponentId_mag[$mag] . '/languages/' . $languageId_mag[$mag] . '?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&platform=web');
$data = json_decode($json, true); // json_decode is json data
//$html = $data['shareUrl'];
/*$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data['shareUrl']);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$a = curl_exec($ch);*/
/*if (preg_match('/location: (.+\.html\/.+\.html)/', $a, $r)) {
$html = trim($r[1]);
}
else {
echo 'skipped because $html is empty: '.$mediaComponentId[$i].'<br />';
continue;
}*/
$html = 'https://www.jesusfilm.org/watch/magdalena.html/' . $LN_mag[$mag] . '.html';
echo '<a href="' . $html . '" target="_blank">Magdalena: ' . $ISO . ' : ' . $html . ' : ' . $LN_mag[$mag] . ' : ' . $mediaComponentId_mag[$mag] . ' : ' . $languageId_mag[$mag] . '</a><br />';
fwrite($handle, '<a href="' . $html . '" target="_blank">Magdalena</a> ' . $ISO . ' : ' . $html . ' : ' . $LN_mag[$mag] . ' : ' . $mediaComponentId_mag[$mag] . ' : ' . $languageId_mag[$mag] . PHP_EOL);
//}
/*
}
fclose($handle);
if ($FileData == 1) {
if (filesize('data/' . $ISO . '/JesusFilmAPI_Magdalena.txt') == 0) {
unlink('data/' . $ISO . '/JesusFilmAPI_Magdalena.txt');
}
}
else {
if (filesize('data/' . $ISO . '-JesusFilmAPI_Magdalena.txt') == 0) {
unlink('data/' . $ISO . '-JesusFilmAPI_Magdalena.txt');
}
}
*/
// create Magdalena txt files
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.en.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.en.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_en.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.es.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.es.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_es.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.pt.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.pt.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_pt.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.fr.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.fr.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_fr.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.nl.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.nl.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_nl.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
if ($FileData == 1) {
$txtFilename = fopen('data/' . $ISO . '/Magdalena-' . $ISO . '.de.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$txtFilename = fopen('data/' . $ISO . '-Magdalena-' . $ISO . '.de.' . $mediaComponentId_mag[$mag] . '.' . $languageId_mag[$mag] . '.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
$a = 0;
$template_lines = file('Bible_links/API_Magdalena_VideoPlaylist/Magdalena-template_de.txt');
foreach ($template_lines as $template_line_num => $template_line) {
if ($a == 0) {
$replace = preg_replace('/(.*)\[Language Name\](.*)/', "$1$LN_mag[$mag]$2", $template_line);
$replace = preg_replace('/(.*)\[ISO\](.*)/', "$1[$ISO]$2", $replace);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace); // Based on the fact that the check if the filename exists I will do ">>" instead of ">" and a 'dir" and find the size greater that the ones which had only set.
$a = 1;
}
else {
//$langName = str_replace(', ', '-', $LN_mag[$mag]);
$langName = preg_replace('/,? /', '-', $LN_mag[$mag]);
$langName = mb_strtolower($langName,'UTF-8');
//preg_match('/.+\.html\/(.+)\.html/', $html, $match);
$replace = preg_replace('/(.*)\[language name\]\.html/', "$1${langName}.html", $template_line);
$replace = preg_replace('/(.*)(\r\n|\r)$/', "$1\n", $replace); // change Mac CR to Linux LN
fwrite($txtFilename, $replace);
}
}
fclose($txtFilename);
//}
}
fclose($handle);
echo '<br />';
if ($FileData == 1) {
$handle = fopen('data/' . $ISO . '/JesusFilmAPI_Story.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
else {
$handle = fopen('data/' . $ISO . '-JesusFilmAPI_Story.txt', "w"); // Open for writing only; placing the file pointer at the end of the file.
}
for ($sto=0; $sto<count($mediaComponentId_sto); $sto++) {
//for ($j=0; $j<count($languageId_sto); $j++) {
$html = '';
$json = file_get_contents('https://api.arclight.org/v2/media-components/' . $mediaComponentId_sto[$sto] . '/languages/' . $languageId_sto[$sto] . '?apiKey=586ff4f28bd3b1.25434678&metadataLanguageTags=en&platform=web');
$data = json_decode($json, true); // json_decode is json data
//$html = $data['shareUrl'];
/*$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $data['shareUrl']);
curl_setopt($ch, CURLOPT_HEADER, TRUE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$a = curl_exec($ch);*/
/*if (preg_match('/location: (.+\.html\/.+\.html)/', $a, $r)) {
$html = trim($r[1]);
}
else {
echo 'skipped because $html is empty: '.$mediaComponentId[$i].'<br />';
continue;
}*/
$html = 'https://www.jesusfilm.org/watch/the-story-of-jesus-for-children.html/' . $LN_sto[$sto] . '.html';
echo '<a href="' . $html . '" target="_blank">Story: ' . $ISO . ' : ' . $html . ' : ' . $LN_sto[$sto] . ' : ' . $mediaComponentId_sto[$sto] . ' : ' . $languageId_sto[$sto] . '</a><br />';
fwrite($handle, '<a href="' . $html . '" target="_blank">Story</a> ' . $ISO . ' : ' . $html . ' : ' . $LN_sto[$sto] . ' : ' . $mediaComponentId_sto[$sto] . ' : ' . $languageId_sto[$sto] . PHP_EOL);
//}
}
fclose($handle);
if ($FileData == 1) {
if (filesize('data/' . $ISO . '/JesusFilmAPI_Story.txt') == 0) {
unlink('data/' . $ISO . '/JesusFilmAPI_Story.txt');
}
}
else {
if (filesize('data/' . $ISO . '-JesusFilmAPI_Story.txt') == 0) {
unlink('data/' . $ISO . '-JesusFilmAPI_Story.txt');
}
}
/* if there is one one ISO then it should be ok to add this (and if it isn't a part of PlaylistVideo)
$query="SELECT ROD_Code FROM scripture_main WHERE ISO = '$ISO' ORDER BY ROD_Code";
$result_SM=$db->query($query);
$num_rows = mysqli_num_rows($result_SM);
if ($row_SM = $result_SM->fetch_array()) { // and iterate ISO and Idioma from pueblos_idiomas_mexico table based on 'Languages'
//$ISO = $row_SM['ISO'];
$ROD_Code = $row_SM['ROD_Code'];
}
*/
}
?>
<form name='myForm' action='#'>
<br />
<br />
<div style='text-align: left; padding: 10px; '>
<input type="submit" onclick="myOK()" value="OK" /><br />
</div>
</form>
<div style="color: red; font-size: 16pt; margin-left: 20px; position: fixed; top: 450px; font: 100% Verdana, Arial, Helvetica, sans-serif; ">
You have create a temporary solution. The temporary solution is based on the ISO code however it is the best one.<br />
The five new txt files are at the subfolder called "data/[ISO code]" for the existing SE ISO codes,<br />
or the subfolder called "data" for the non existent SE ISO codes. But those Jesus Film API videos don’t have the ROD codes which is used by SE.<br />
Examine the txt files to find out which ROD code to use. Then, rename the txt file and move it into "data/[ISO code]/video" subfolder.<br />
In renaming the file don’t use the ROD code part of the filename if it is no ROD code. In the first line of the txt change the name of the language if need be.<br />
<br />
In other words, when you find the ROD code you rename this filename and then move it to the subfolder called "video" underneath the ISO code.<br />
In the end you will have:<br />
data/[ISO code]/video/JESUSFilm-[ISO code].en.txt<br />
or<br />
data/[ISO code]/video/JESUSFilm-[ISO code]([-ROD code]([-Variant code))].en.txt<br /><br />
with each of other 4 navigational languages (es, pl, fr, and nl) in seperate file names.
etc.
</div>
<script>
function myOK() {
window.location.assign("login.php");
}
</script>
<?php
}
else {
?>
<form name='myForm' action='#'>
<input type='text' style='color: navy; ' size='3' pattern="[a-z]{3}" title="Type the lowercase ISO code" name='ISO' id='ISO' value="" /> Search for the ISO code
<input type="submit" onclick="myISO(document.getElementById('ISO').value)" checked="checked" value="OK">
<input type="button" onclick="myCancel()" value="Go back">
</form>
<script>
function myISO(ISO) {
document.body.innerHTML = "";
document.write("<div style='color: red; font-size: 16pt; margin-left: 20px; position: fixed; top: 200px; font: 100% Verdana, Arial, Helvetica, sans-serif; '>Please wait...</div>");
window.location.assign("JesusFilmAPI.php?ISO=" + ISO);
}
function myCancel() {
window.location.assign("login.php");
}
window.onload = function() {
document.getElementById("ISO").focus();
};
</script>
<?php
echo '<div style="color: red; font-size: 16pt; margin-left: 20px; position: fixed; top: 450px; font: 100% Verdana, Arial, Helvetica, sans-serif; ">';
echo 'You are about to create an incomplete solution. This solution is only based on the language ISO code but without the ROD code<br />';
echo 'since the Jesus Film doesn’t have the ROD codes.<br />';
echo 'This script will search through the whole Jesus Film website (i.e. API)<br />';
echo 'and find the appropriate video(s). The five new txt files will be at the subfolder called "data/[ISO code]" for the existing SE ISO codes,<br />';
echo 'or the subfolder called "data" for the non existent SE ISO codes. But those Jesus Film API videos don’t have the ROD codes which is used by SE.<br />';
echo 'You must examine the txt files and find out which ROD code to use. Then, rename the txt file and move it into "data/[ISO code]/video" subfolder.<br />';
echo 'In renaming the file don’t use the ROD code part of the filename if it is no ROD code. In the first line of the txt change the name of the language if need be.<br />';
echo '<br />';
echo 'In other words, when you find the ROD code you rename this filename and then move it to the subfolder called "video" underneath the ISO code.<br />';
echo 'In the end you will have:<br />';
echo ' data/[ISO code]/video/JESUSFilm-[ISO code].en.txt<br />';
echo ' or<br />';
echo ' data/[ISO code]/video/JESUSFilm-[ISO code]([-ROD code]([-Variant code))].en.txt<br /><br />';
echo 'with each of other 4 navigational languages (es, pl, fr, and nl) in seperate file names.';
echo '</div>';
}
?>
</body>
</html>