From a6044e16a75ab47b1e5e77ee11338a8c8cbbef25 Mon Sep 17 00:00:00 2001 From: Ken Fallon Date: Tue, 14 Jan 2025 20:22:36 +0100 Subject: [PATCH] The show processing needs to be refactored #5 --- cms/say.php | 78 +++++++++++++++++----------- cms/schedule.php | 16 +++--- cms/shownotes.php | 126 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+), 34 deletions(-) create mode 100644 cms/shownotes.php diff --git a/cms/say.php b/cms/say.php index fb4f039..7dbb59d 100644 --- a/cms/say.php +++ b/cms/say.php @@ -1,11 +1,14 @@ $maxhost ) OR ( $num_get_args > 1 ) ){ - exit; + problem( "ea860134910fecd136229e45262709d7" ); + exit; } $query = "SELECT id FROM eps WHERE id = '$id'"; $result = @mysqli_query($connection, $query); if($result === FALSE) { - call412( "dc5b8dae7ea2a7e70ac0b7ea65ce2d12" ); + problem( "dc5b8dae7ea2a7e70ac0b7ea65ce2d12" ); } else { $db = mysqli_fetch_array($result, MYSQLI_ASSOC); if ( empty($db["id"]) ) { - call412( "2b6462ff2389405a796066dfc73ccf55" ); + problem( "2b6462ff2389405a796066dfc73ccf55" ); } } } else { - call412( "ae1f3471af22d32d3bf2efc9130a00ae" ); + problem( "ae1f3471af22d32d3bf2efc9130a00ae" ); exit; } -Header('Content-type: text/tab-separated-values'); -header("Content-disposition: inline; filename=say.txt"); $ep_retrieve = "SELECT UNIX_TIMESTAMP(eps.date) AS timestamp, @@ -88,42 +90,62 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { } } } -$HPR_summary = "This is Hacker Public Radio episode $id for " . date("l", $date) . " the " . date("jS", $date) . " of " . date("F Y", $date) . ". Todays show is entitled. ${title}."; +else { + http_response_code(404); + die(); +} + + + +$synopsis = "This is Hacker Public Radio episode $id for " . date("l", $date) . " the " . date("jS", $date) . " of " . date("F Y", $date) . ". Todays show is entitled. ${title}."; if ($series > "0"){ $series_query = mysqli_query($connection, "SELECT name, description FROM miniseries WHERE id = '$series'"); $series_result = mysqli_fetch_array($series_query); $series_title = $series_result['name']; $desc = $series_result['description']; - $HPR_summary = "${HPR_summary} It is part of the series \"$series_title\""; + $synopsis = "${synopsis} It is part of the series \"$series_title\""; } -$HPR_summary = "${HPR_summary} ${host_notes} and is about " . round($duration/60) . " minutes long. It carries "; +$synopsis = "${synopsis} ${host_notes} and is about " . round($duration/60) . " minutes long. It carries "; if ($explicit == 0) { - $HPR_summary = "${HPR_summary} a clean flag. "; + $synopsis = "${synopsis} a clean flag. "; $explicit = "Clean"; } else{ - $HPR_summary = "${HPR_summary} an explicit flag. "; + $synopsis = "${synopsis} an explicit flag. "; $explicit = "Explicit"; } if ( !empty( $summary ) ) { - $HPR_summary = "${HPR_summary}. The summary is. $summary"; + $synopsis = "${synopsis}. The summary is. $summary"; } if (strcmp($license, "CC-BY-SA" ) !== 0) { - $HPR_summary = "${HPR_summary}. Todays show is licensed under a $license_long_name license."; + $synopsis = "${synopsis}. Todays show is licensed under a $license_long_name license."; } -$HPR_summary = str_replace($host,$espeak_name,$HPR_summary); +$synopsis = str_replace($host,$espeak_name,$synopsis); -echo "HPR_summary: ${HPR_summary}\n"; -echo "HPR_album: Hacker Public Radio\n"; -echo "HPR_artist: ${host}\n"; -echo "HPR_hostid: ${hostid}\n"; -echo "HPR_comment: https://hackerpublicradio.org ${explicit}; $summary\n"; -echo "HPR_genre: Podcast\n"; -echo "HPR_license: ${license}\n"; -echo "HPR_title: ${title}\n"; -echo "HPR_track: $id\n"; -echo "HPR_year: " . date("Y", $date) . "\n"; -echo "HPR_duration: ${duration}\n"; -echo "HPR_explicit: ${explicit}\n"; -?> +// -------------------------------------------- +// Display the results + +$arr = array( + 'genre' => "Podcast", + 'album' => "Hacker Public Radio", + 'track' => "$id", + 'year' => date("Y", $date), + 'date' => date("Y-m-d", $date), + 'artist' => "${host}", + 'hostid' => "${hostid}", + 'title' => "${title}", + 'duration' => "${duration}", + 'license' => "${license}", + 'explicit' => "${explicit}", + 'summary' => "${summary}", + 'comment' => "https://hackerpublicradio.org ${explicit}; $summary", + 'synopsis' => "${synopsis}" +); + +header('Content-Type: application/json'); +header("Content-disposition: inline; filename=hpr_stats.json"); + +echo json_encode($arr); + +mysqli_close($connection); diff --git a/cms/schedule.php b/cms/schedule.php index deb0992..238376f 100644 --- a/cms/schedule.php +++ b/cms/schedule.php @@ -42,7 +42,7 @@ $current_episode_number = $current_episode_array[1]; // Populate array with future shows and reservations $show_array = array (); -// REQUEST_UNVERIFIED → SHOW_SUBMITTED → METADATA_PROCESSED → SHOW_POSTED → MEDIA_TRANSCODED → UPLOADED_TO_IA → UPLOADED_TO_RSYNC_NET +// REQUEST_UNVERIFIED → SHOW_SUBMITTED → METADATA_PROCESSED → SHOW_POSTED → MEDIA_TRANSCODED → UPLOADED_TO_IA → UPLOADED_TO_CCDN $ep_retrieve = "SELECT hosts.host, eps.id, eps.title, eps.date FROM eps, hosts WHERE eps.valid=1 AND eps.hostid = hosts.hostid AND eps.date >= '$current_episode_date' ORDER BY date DESC"; $ep_retrieve = "SELECT @@ -76,11 +76,12 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { $show_array[$id] = array ( "date" => date('Y-m-d', strtotime($date) ), "title" => $title, "host" => $host, - "status" => $status + "status" => $status, + "workflow" => $status ); } } -// REQUEST_UNVERIFIED → SHOW_SUBMITTED → METADATA_PROCESSED → SHOW_POSTED → MEDIA_TRANSCODED → UPLOADED_TO_IA → UPLOADED_TO_RSYNC_NET +// REQUEST_UNVERIFIED → SHOW_SUBMITTED → METADATA_PROCESSED → SHOW_POSTED → MEDIA_TRANSCODED → UPLOADED_TO_IA → UPLOADED_TO_CCDN // Populate array with currently processing shows EMAIL_LINK_CLICKED $ep_retrieve = " @@ -104,7 +105,8 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { $show_array[$id] = array ( "date" => date('Y-m-d', strtotime($date) ), "title" => $status, "host" => "Unverified", - "status" => "Processing" + "status" => "Processing", + "workflow" => $status ); } } @@ -122,7 +124,8 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { $show_array[$id] = array ( "date" => date('Y-m-d', strtotime($date) ), "title" => " Available again in $minutes minutes", "host" => "Unverified", - "status" => "Locked" + "status" => "Locked", + "workflow" => "Locked" ); } } @@ -153,7 +156,8 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { $show_array[$id] = array ( "date" => date('Y-m-d', strtotime($date) ), "title" => $title, "host" => $host, - "status" => "Finished" + "status" => "Finished", + "workflow" => "Finished" ); } } diff --git a/cms/shownotes.php b/cms/shownotes.php new file mode 100644 index 0000000..87d4685 --- /dev/null +++ b/cms/shownotes.php @@ -0,0 +1,126 @@ + $v) { + ++$num_get_args; + } + if ( (strval(intval($id)) != strval($id)) OR ( intval($id) <= 0 ) OR ( intval($id) > $maxhost ) OR ( $num_get_args > 1 ) ){ + problem( "5d45cb79dd9426e7e4ab5595ac647a62" ); + exit; + } + $query = "SELECT id FROM eps WHERE id = '$id'"; + $result = @mysqli_query($connection, $query); + if($result === FALSE) { + problem( "b26e5cea3779b66c76bf1c3c266e1a51" ); + } + else { + $db = mysqli_fetch_array($result, MYSQLI_ASSOC); + if ( empty($db["id"]) ) { + problem( "a5d5eab30290ba4460ceb337add11821" ); + } + } +} +else { + problem( "39122c23e90fcf5cb9ca9e03a5c5a3c5" ); + exit; +} + +$ep_retrieve = "SELECT + UNIX_TIMESTAMP(eps.date) AS timestamp, + eps.title, + eps.duration, + eps.summary, + eps.tags, + hosts.host, + hosts.email, + hosts.license as host_license, + hosts.profile, + eps.hostid, + eps.series, + eps.notes, + miniseries.name as series_name, + eps.license as show_license, + eps.explicit +FROM + eps + LEFT JOIN hosts ON eps.hostid = hosts.hostid + LEFT JOIN miniseries ON miniseries.id = eps.series +WHERE + hosts.valid = '1' + AND eps.id = '$id'"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + while ($row = mysqli_fetch_array($result)) { + $date = $row['timestamp']; + $title = $row['title']; + $duration = $row['duration']; + $summary = $row['summary']; + $host = $row['host']; + $hostid = $row['hostid']; + $host_email = $row['email']; + $host_license = $row['host_license']; + $host_profile = $row['profile']; + $series = $row['series']; + $series_name = $row['series_name']; + $show_license = $row['show_license']; + $explicit = $row['explicit']; + $tags = $row['tags']; + $notes = $row['notes']; + } +} +else { + http_response_code(404); + die(); +} + +if ($explicit == 0) { + $explicit = "Clean"; +} +else{ + $explicit = "Explicit"; +} + +// -------------------------------------------- +// Display the results + +$arr = array( + 'host' => array ( + 'Host_ID' => "${hostid}", + 'Host_Name' => "${host}", + 'Host_Email' => "${host_email}", + 'Host_License' => "${host_license}", + 'Host_Profile' => "${host_profile}" + ), + 'episode' => array ( + 'Title' => "${title}", + 'Summary' => "${summary}", + 'Explicit' => "${explicit}", + 'Show_License' => "${show_license}", + 'Series' => "${series}", + 'Series_Name' => "${series_name}", + 'Tags' => "${tags}", + 'Show_Notes' => "${notes}" + ), + 'metadata' => array ( + 'Episode_Number' => "${id}", + 'Episode_Date' => date("Y-m-d", $date) + ) +); + +header('Content-Type: application/json'); +header("Content-disposition: inline; filename=hpr_stats.json"); + +echo json_encode($arr); + +mysqli_close($connection);