-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect-shows-with-channels.php
133 lines (86 loc) · 4.21 KB
/
connect-shows-with-channels.php
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
<?php
require_once('CONFIG.php');
$q = 'SELECT id,name, active from shows';
$r = mysqli_query($db,$q);
$q2 = 'SELECT id,title from podcast_channels';
$r2 = mysqli_query($db,$q2);
$pod_chans = array();
$shows = array();
error_reporting(~E_WARNING);
while($pod_chan = mysqli_fetch_assoc($r2)){
$pod_chans []= $pod_chan;
}
echo count($pod_chans).' podcast channels found.<br/>';
while ($show_row = mysqli_fetch_assoc($r) ){
$is_fillin = strpos($show_row['name'],'Fill-in')!==false;
if(!$is_fillin)
$shows []= $show_row;
}
// $shows = array_reverse($shows);
foreach($shows as $i => $show){
$found = false;
foreach($pod_chans as $j => $pod){
if($pod['id'] == 43 && $show['id'] == '51'){
xdebug_break();
}
$pod_name_arr = explode('-- ', $pod['title']);
$pod_name = $pod_name_arr[count($pod_name_arr)-1];
$this_show_name = html_entity_decode($show['name'], ENT_QUOTES);
$this_show_name = str_replace("&", '', $this_show_name);
$this_show_name = str_replace("'", '', $this_show_name);
$this_show_name = str_replace("the", '', $this_show_name);
$this_show_name = str_replace("The", '', $this_show_name);
$this_show_name = str_replace("The", '', $this_show_name);
$this_show_name = str_replace(" ", '', $this_show_name);
$this_show_name = str_replace("radio", '', $this_show_name);
$this_show_name = str_replace("Radio", '', $this_show_name);
$this_show_name = str_replace("and", '', $this_show_name);
$this_show_name = str_replace("And", '', $this_show_name);
$this_show_name = str_replace("&", '', $this_show_name);
$this_show_name = str_replace("!", '', $this_show_name);
$pod_name = html_entity_decode($pod_name, ENT_QUOTES);
$pod_name = str_replace("&", '', $pod_name);
$pod_name = str_replace("'", '', $pod_name);
$pod_name = str_replace("the", '', $pod_name);
$pod_name = str_replace("The", '', $pod_name);
$pod_name = str_replace("The", '', $pod_name);
$pod_name = str_replace(" ", '', $pod_name);
$pod_name = str_replace("Radio", '', $pod_name);
$pod_name = str_replace("radio", '', $pod_name);
$pod_name = str_replace("and", '', $pod_name);
$pod_name = str_replace("And", '', $pod_name);
$pod_name = str_replace("&", '', $pod_name);
$pod_name = str_replace("!", '', $pod_name);
if(isset($pod_name) && isset($this_show_name)) {
$pos_1 = strpos($this_show_name, $pod_name);
$pos_2 = strpos($pod_name, $this_show_name);
}
if (!$found && (
(levenshtein($this_show_name, $pod_name) <3)
|| $pos_1!==false || $pos_2!==false
// (strpos($this_show_name,$pod_name)) ||
// (strpos($pod_name,$this_show_name))
)
){
echo '<br/>'.$this_show_name.'(show # '.$show['id'].') equals '.$pod['title'].'(pod#'.$pod['id'].')<br/>';
$found = true;
$update_q = 'UPDATE shows SET podcast_channel_id = "'.$pod['id'].'" WHERE name = "'.$show['name'].'"';
unset($pod_chans[$j]);
unset($shows[$i]);
if ($up_res = mysqli_query($db,$update_q)){} else {}
} else {
}
}
if (!$found){
// echo '<h2>no podcast automatically found: '.$show['name'].'</h2><br/><br/><br/>';
echo $show['name'].' - not found.(show #'.$show['id'].')...<br/>';
if($show['active'] == 0) {
unset($shows[$i]);
}
}
}
echo '</hr><div style="{position:absolute; top:0; right:0; height:100%; overflow:scroll;}">';
echo count($shows).' currently active shows need to have a podcast channel id set manually: (discorder radio is also wrong)<br/><pre>';
print_r($shows);
echo count($pod_chans).' podcast channels need to have a show set manually:<br/><pre>';
print_r($pod_chans);