Page MenuHomePhorge

No OneTemporary

diff --git a/spotify_track_availability.php b/spotify_track_availability.php
index ee984f6..67afde6 100644
--- a/spotify_track_availability.php
+++ b/spotify_track_availability.php
@@ -1,55 +1,60 @@
<html>
<head>
<title>Spotify track availability checker</title>
</head>
<body>
<form action="" method="POST">
<p><strong>Enter a Spotify track URL:</strong> <input name="URL" id="URL"></p>
<p><button>Submit</button></p>
</form>
<?php
if($_POST['URL']) {
$url = $_POST['URL'];
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
die("Sorry, only valid URLs are currently supported. Take it up with Keith! He probably just forgot to make URIs work too. Or maybe what you pasted in isn't valid as either...");
}
# Run Python script (should rewrite in PHP sometime...)
$out = shell_exec("python3 check_track_availability.py $url");
- # Flag if missing key markets, hardcoded right now for Music League friends, maybe I should have a checklist or something?
- $missing_count = 0;
- $missing_list = [];
- $important = array('AU', 'CA', 'IE', 'NL', 'NZ', 'US');
- $friendlyn = array('AU' => "Australia", 'CA' => "Canada", 'IE' => "Ireland", 'NL' => "The Netherlands", 'NZ' => "New Zealand", 'US' => "The 'United' States of America");
- foreach($important as &$i) {
- if (!str_contains($out, $i)) {
- $missing_count++;
-
- $missing_list[] .= $friendlyn[$i];
+ if (strpos($out, "[]") === FALSE) {
+ # Flag if missing key markets, hardcoded right now for Music League friends, maybe I should have a checklist or something?
+ $missing_count = 0;
+ $missing_list = [];
+ $important = array('AU', 'CA', 'IE', 'NL', 'NZ', 'US');
+ $friendlyn = array('AU' => "Australia", 'CA' => "Canada", 'IE' => "Ireland", 'NL' => "The Netherlands", 'NZ' => "New Zealand", 'US' => "The 'United' States of America");
+ foreach($important as &$i) {
+ #if (!str_contains($out, $i)) { # Requires PHP 8+
+ if (strpos($out, $i) === FALSE) {
+ $missing_count++;
+
+ $missing_list[] .= $friendlyn[$i];
+ }
}
- }
- if ($missing_count > 0) {
- $missing_string = implode(", ", $missing_list);
- print("<p style='color:red'>This song is not available in some places we have Music Leaguers hailing from!</p> </p>Specifically, verboten in: $missing_string</p>");
+ if ($missing_count > 0) {
+ $missing_string = implode(", ", $missing_list);
+ print("<p style='color:red'>This song is not available in some places we have Music Leaguers hailing from!</p> </p>Specifically, verboten in: $missing_string</p>");
+ } else {
+ print("<p style='color:green'>Looks good!</p>");
+ }
+
+ print("<p>Full list of available markets: $out</p>");
} else {
- print("<p style='color:green'>Looks good!</p>");
+ print("Spotify's API returns the available markets list as '[]' which I thiiiink means it's available everywhere? 🤷🏼");
}
-
- print("<p>Full list of available markets: $out</p>");
#error_log("Okay, done");
} else {
#error_log("No URL?");
}
?>
</body>
</html>

File Metadata

Mime Type
text/x-diff
Expires
Mon, Aug 18, 9:37 AM (23 h, 9 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
184387
Default Alt Text
(2 KB)

Event Timeline