Skip to content

Commit f0a68fe

Browse files
Correctly parse program properties whether they're strings or bitflags
1 parent 5c88c55 commit f0a68fe

1 file changed

Lines changed: 49 additions & 21 deletions

File tree

modules/tv/classes/Program.php

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -184,29 +184,57 @@ public function __construct($data) {
184184
$this->recordedid = $data['recordedid'];
185185

186186
// These db fields should really get renamed...
187-
$this->audioproperties = $data['stereo'];
188-
$this->videoproperties = $data['hdtv'];
189-
$this->subtitletype = $data['closecaptioned'];
187+
$this->audioproperties = $data['audioprop'];
188+
$this->videoproperties = $data['videoprop'];
189+
$this->subtitletype = $data['subtitletypes'];
190190
}
191191
// Assign shortcut names to the new audio/video/subtitle property flags
192-
$this->stereo = $this->audioproperties & 0x01;
193-
$this->mono = $this->audioproperties & 0x02;
194-
$this->surround = $this->audioproperties & 0x04;
195-
$this->dolby = $this->audioproperties & 0x08;
196-
$this->audiohardhear = $this->audioproperties & 0x10;
197-
$this->audiovisimpair = $this->audioproperties & 0x20;
198-
199-
$this->widescreen = $this->videoproperties & 0x0001;
200-
$this->hdtv = $this->videoproperties & 0x0002;
201-
$this->avc = $this->videoproperties & 0x0008;
202-
$this->hd_ready = $this->videoproperties & 0x0020;
203-
$this->fullhd = $this->videoproperties & 0x0040;
204-
$this->damaged = $this->videoproperties & 0x0400;
205-
206-
$this->closecaptioned = $this->subtitletype & 0x01;
207-
$this->has_subtitles = $this->subtitletype & 0x02;
208-
$this->subtitled = $this->subtitletype & 0x04;
209-
$this->deaf_signed = $this->subtitletype & 0x08;
192+
// Check if properties are strings (From MySQL SET columns or numeric bitflags
193+
if (!empty($this->audioproperties) && !is_numeric($this->audioproperties)) {
194+
// Parse comma-separated string values from MySQL SET columns
195+
$this->stereo = strpos($this->audioproperties, 'STEREO') !== false;
196+
$this->mono = strpos($this->audioproperties, 'MONO') !== false;
197+
$this->surround = strpos($this->audioproperties, 'SURROUND') !== false;
198+
$this->dolby = strpos($this->audioproperties, 'DOLBY') !== false;
199+
$this->audiohardhear = strpos($this->audioproperties, 'HARDHEAR') !== false;
200+
$this->audiovisimpair = strpos($this->audioproperties, 'VISUALIMPAIR') !== false;
201+
} elseif (is_numeric($this->audioproperties)) {
202+
// Parse numeric bitflags from mythproto (could be string '75' or int 75)
203+
$this->stereo = intval($this->audioproperties) & 0x01;
204+
$this->mono = intval($this->audioproperties) & 0x02;
205+
$this->surround = intval($this->audioproperties) & 0x04;
206+
$this->dolby = intval($this->audioproperties) & 0x08;
207+
$this->audiohardhear = intval($this->audioproperties) & 0x10;
208+
$this->audiovisimpair = intval($this->audioproperties) & 0x20;
209+
}
210+
211+
if (!empty($this->videoproperties) && !is_numeric($this->videoproperties)) {
212+
$this->widescreen = strpos($this->videoproperties, 'WIDESCREEN') !== false;
213+
$this->hdtv = strpos($this->videoproperties, 'HDTV') !== false;
214+
$this->avc = strpos($this->videoproperties, 'AVC') !== false;
215+
$this->hd_ready = strpos($this->videoproperties, '720') !== false;
216+
$this->fullhd = strpos($this->videoproperties, '1080') !== false;
217+
$this->damaged = strpos($this->videoproperties, 'DAMAGED') !== false;
218+
} elseif (is_numeric($this->videoproperties)) {
219+
$this->widescreen = intval($this->videoproperties) & 0x0001;
220+
$this->hdtv = intval($this->videoproperties) & 0x0002;
221+
$this->avc = intval($this->videoproperties) & 0x0008;
222+
$this->hd_ready = intval($this->videoproperties) & 0x0020;
223+
$this->fullhd = intval($this->videoproperties) & 0x0040;
224+
$this->damaged = intval($this->videoproperties) & 0x0400;
225+
}
226+
227+
if (!empty($this->subtitletype) && !is_numeric($this->subtitletype)) {
228+
$this->closecaptioned = strpos($this->subtitletype, 'HARDHEAR') !== false;
229+
$this->has_subtitles = strpos($this->subtitletype, 'NORMAL') !== false;
230+
$this->subtitled = strpos($this->subtitletype, 'ONSCREEN') !== false;
231+
$this->deaf_signed = strpos($this->subtitletype, 'SIGNED') !== false;
232+
} elseif (is_numeric($this->subtitletype)) {
233+
$this->closecaptioned = intval($this->subtitletype) & 0x01;
234+
$this->has_subtitles = intval($this->subtitletype) & 0x02;
235+
$this->subtitled = intval($this->subtitletype) & 0x04;
236+
$this->deaf_signed = intval($this->subtitletype) & 0x08;
237+
}
210238
// Generate the star string, since mysql has issues with REPEAT() and
211239
// decimals, and the backend doesn't do it for us, anyway.
212240
$this->starstring = @str_repeat(star_character, intVal($this->stars * max_stars));

0 commit comments

Comments
 (0)