Add php files necessary to serve website
This commit is contained in:
1 parent
cb9355ea25
commit
863b4116cd
5 files changed
+517
No files matched your search
@@ -0,0 +1,18 @@
|
||||
<?php if (!defined('token') or !token) die ('This file cannot be directly accessed.<meta http-equiv="refresh" content="3;url=/">'); ?>
|
||||
<!DOCTYPE html>
|
||||
<html xml:lang="en" lang="en" dir="ltr" prefix="og: http://ogp.me/ns#">
|
||||
<head>
|
||||
<style>body{background: #000; background-color: #000}</style>
|
||||
<noscript><?php require 'ns/h20a.php';?></noscript>
|
||||
<?php require 'header.php';?>
|
||||
<!-- Start external requirements -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"/>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.8.2/css/all.min.css"/>
|
||||
<!-- End external requirements -->
|
||||
<!-- Start homemade requirements -->
|
||||
<link rel="stylesheet" type="text/css" href="css/radio.css"/>
|
||||
<!-- End homemade requirements -->
|
||||
</head>
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
<title id="track-title">Dou.Bet Radio</title>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
|
||||
<meta name="description" content="Listen to Doubet Radio 24/7 with all the pop, rock, and electronic music songs you can handle!"/>
|
||||
<meta name="keywords" content="radio, internet radio, dou.bet, coding, blog, hobby, hobbies"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=0.75, maximum-scale=1.0"/>
|
||||
<meta name="msapplication-TileColor" content="#2d89ef"/>
|
||||
<meta name="theme-color" content="#ffffff"/>
|
||||
<meta content="https://radio.dou.bet/seo/android-chrome-512x512.png" id="metaimage2">
|
||||
<meta property="og:title" content="Dou.Bet Radio"/>
|
||||
<meta property="og:type" content="website"/>
|
||||
<meta property="og:url" content="https://radio.dou.bet/"/>
|
||||
<meta property="og:image" content="https://radio.dou.bet/seo/ddfb.png" id="metaimage1"/>
|
||||
<meta property="og:description" content="Listen to Doubet Radio 24/7 with all the pop, rock, and electronic music songs you can handle!"/>
|
||||
<meta property="og:site_name" content="Dou.Bet"/>
|
||||
<meta property="og:audio" content="http://radio.dou.bet/stream" />
|
||||
<meta property="og:audio:secure_url" content="https://radio.dou.bet/stream" />
|
||||
<meta property="og:audio:type" content="audio/mpeg" />
|
||||
<link id="metaimage3" rel="apple-touch-icon" sizes="180x180" href="seo/apple-touch-icon.png"/>
|
||||
<link id="metaimage4" rel="icon" type="image/png" sizes="32x32" href="seo/favicon-32x32.png"/>
|
||||
<link id="metaimage5" rel="icon" type="image/png" sizes="16x16" href="seo/favicon-16x16.png"/>
|
||||
<link rel="manifest" href="seo/site.webmanifest"/>
|
||||
<link rel="mask-icon" href="seo/safari-pinned-tab.svg" color="#666666"/>
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php date_default_timezone_set('America/Chicago'); define('token', 'index'); require 'h.php'; ?>
|
||||
<body>
|
||||
<noscript><?php include 'ns/i.php';?></noscript>
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
<br><img id="genius" title="unknown" alt="unknown album" width="86%" height="auto9" src="na.jpg"/><br>
|
||||
<img id="genius2" title="Daniel Doubet's Talk Show" alt="unknown album" width="86%" height="auto9" src="na.jpg" style="display:none"/><br>
|
||||
<br><h4 id="dwdnp"></h4><br>
|
||||
<audio controls autoplay title="" artist="" id="stream">
|
||||
<source src="https://radio.dou.bet/stream" type="audio/mp3"/>
|
||||
<source src="https://radio.dou.bet/stream" type="audio/mpeg"/>
|
||||
</audio><br><br>
|
||||
<!--<button id="controls2" class="coolbutton2">Talk Show</button><br><br>-->
|
||||
<button id="lbut" class="coolbutton" style="display:inline-block">Show Lyrics</button><br><br>
|
||||
|
||||
<span id="spoiler" class="hiddenl"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="last_played">Song List</div>
|
||||
<span id="spoiler2" class="hiddenl2"></span>
|
||||
<span id="peep"></span>
|
||||
<script id="nps" src="js/d.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+325
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
// Load environmental variables
|
||||
if (file_exists('.env')){
|
||||
$env = parse_ini_file('.env');
|
||||
$genius = $env['GENIUS_API_BASE64'];
|
||||
$debug = $env['DEBUG'] ? true : $env['DEBUG'];
|
||||
$show_err = $env['SHOW_ERRORS'] ? true : $env['SHOW_ERRORS'];
|
||||
} else {
|
||||
die('You forgot to create your .env file!');
|
||||
}
|
||||
|
||||
// Show errors
|
||||
if ($show_err){
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
// Set header info
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: private, max-age=90');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
// Genius URLs
|
||||
$geniusAPI = "https://api.genius.com/search?q=";
|
||||
$geniusID = "https://api.genius.com/songs/";
|
||||
$geniusurl = "https://genius.com/";
|
||||
$bearer = base64_decode($genius);
|
||||
|
||||
// Default variables
|
||||
$lyrics = '';
|
||||
$scrapeme = '';
|
||||
|
||||
// Get POST and/or GET variables for artist and song title
|
||||
$vartist = (empty($_POST['artist'])) ? (empty($_GET['artist'])) ? 'n' : $_GET['artist'] : $_POST['artist'];
|
||||
$vtitle = (empty($_POST['title'])) ? (empty($_GET['title'])) ? 'n' : $_GET['title'] : $_POST['title'];
|
||||
$vroute = (empty($_POST['route'])) ? (empty($_GET['route'])) ? 'n' : $_GET['route'] : $_POST['route'];
|
||||
if ($vartist === 'n' && $vtitle === 'n'){
|
||||
echo "offline";
|
||||
exit(0);
|
||||
}
|
||||
$json = rawurlencode($vartist . ' - ' . $vtitle);
|
||||
|
||||
// Curl function
|
||||
function curlThis($url, $auth, $header, $returnt, $timeoutc, $timeout, $bearer){
|
||||
$exe = curl_init();
|
||||
curl_setopt($exe, CURLOPT_URL, "$url");
|
||||
if ($auth === 1){
|
||||
curl_setopt($exe, CURLOPT_HTTPHEADER, ["Authorization: Bearer $bearer"]);
|
||||
}
|
||||
curl_setopt($exe, CURLOPT_HEADER, $header);
|
||||
curl_setopt($exe, CURLOPT_RETURNTRANSFER, $returnt);
|
||||
curl_setopt($exe, CURLOPT_CONNECTTIMEOUT, $timeoutc);
|
||||
curl_setopt($exe, CURLOPT_TIMEOUT, $timeout);
|
||||
$raw = curl_exec($exe);
|
||||
curl_close($exe);
|
||||
return $raw;
|
||||
}
|
||||
|
||||
// Clean up raw page scrapping function
|
||||
$d = '<br/>';
|
||||
$cleanArray = array(
|
||||
array("<head>", "</head>"),
|
||||
array("<noscript>", "</noscript>"),
|
||||
array("<script ", "</script>"),
|
||||
array("<script>", "</script>"),
|
||||
array("<footer ", "</footer>"),
|
||||
array("<svg", "</svg>"),
|
||||
array("<button ", "</button>")
|
||||
);
|
||||
function cleanMe($lyrics, $start, $end){
|
||||
if (strpos($lyrics, $start) !== false && strpos($lyrics, $end) !== false){
|
||||
$start_len = strlen($start);
|
||||
$start_pos = strpos($lyrics, $start);
|
||||
$end_pos = strpos($lyrics, $end);
|
||||
$remove_lyrics = substr($lyrics, $start_pos, $end_pos + $start_len + 1 - $start_pos);
|
||||
return str_replace($remove_lyrics, '', $lyrics);
|
||||
} else {
|
||||
return $lyrics;
|
||||
}
|
||||
}
|
||||
|
||||
// Query Genius API using artist and song title to get URL of lyrics by querying first result
|
||||
$url = $geniusAPI . $json;
|
||||
$json_genius = json_decode(curlThis($url, 1, 0, 1, 5, 4, $bearer));
|
||||
$result = $json_genius->response->hits[0]->result;
|
||||
$scrapeme = $result->url;
|
||||
$returnURL = '<a href="' . $scrapeme . '" target="_blank">Link</a><br><br>';
|
||||
|
||||
//echo $url . "\n\n";
|
||||
//print_r($json_genius) . "\n\n";
|
||||
|
||||
// Scrape lyrics from Genius
|
||||
if ($vroute !== 'n'){
|
||||
$raw3 = curlThis($scrapeme, 0, 0, 1, 5, 4, $bearer);
|
||||
$divsearch = '<div data-lyrics-container="true" class="Lyrics';
|
||||
$divinstum = '<div class="LyricsPlaceholder-';
|
||||
$divend = '<div class="LyricsFooter-';
|
||||
// Clean raw data
|
||||
foreach ($cleanArray as $cleanThis){
|
||||
$clean_start = $cleanThis[0];
|
||||
$clean_end = $cleanThis[1];
|
||||
while (strpos($raw3, $clean_start) !== false){
|
||||
$raw3 = cleanMe($raw3, $clean_start, $clean_end);
|
||||
}
|
||||
}
|
||||
$lyricsraw = explode($divsearch, $raw3);
|
||||
$lyric_para = count($lyricsraw);
|
||||
|
||||
// Find lyric containers scraped from webpage
|
||||
if ($lyric_para > 6){
|
||||
$lr6 = explode($d, $lyricsraw[6]);
|
||||
}
|
||||
if ($lyric_para > 5){
|
||||
$lr5 = explode($d, $lyricsraw[5]);
|
||||
}
|
||||
if ($lyric_para > 4){
|
||||
$lr4 = explode($d, $lyricsraw[4]);
|
||||
}
|
||||
if ($lyric_para > 3){
|
||||
$lr3 = explode($d, $lyricsraw[3]);
|
||||
}
|
||||
if ($lyric_para > 2){
|
||||
$lr2 = explode($d, $lyricsraw[2]);
|
||||
}
|
||||
if ($lyric_para > 1) {
|
||||
$lr1 = explode($d, $lyricsraw[1]);
|
||||
} else {
|
||||
$lyricsraw = explode($divinstum, $raw3);
|
||||
$lr1 = explode($d, $lyricsraw[3]);
|
||||
}
|
||||
|
||||
// Join lyric containers scraped from webpage
|
||||
$lyrics = '';
|
||||
if (isset($lr6)){
|
||||
$last_exp = explode('</div>', $lr1[0]);
|
||||
$last = array_key_last($last_exp);
|
||||
if ($debug){print_r($last_exp) . "\n\n";}
|
||||
if ($last){
|
||||
$lyrics = $lyrics . $last_exp[$last] . $d;
|
||||
}
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr2 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr3 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr4 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr5 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr6 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($lr5)){
|
||||
$last_exp = explode('</div>', $lr1[0]);
|
||||
$last = array_key_last($last_exp);
|
||||
if ($debug){print_r($last_exp) . "\n\n";}
|
||||
if ($last){
|
||||
$lyrics = $lyrics . $last_exp[$last] . $d;
|
||||
}
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr2 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr3 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr4 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr5 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($lr4)){
|
||||
$last_exp = explode('</div>', $lr1[0]);
|
||||
$last = array_key_last($last_exp);
|
||||
if ($debug){print_r($last_exp) . "\n\n";}
|
||||
if ($last){
|
||||
$lyrics = $lyrics . $last_exp[$last] . $d;
|
||||
}
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr2 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr3 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr4 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($lr3)){
|
||||
$last_exp = explode('</div>', $lr1[0]);
|
||||
$last = array_key_last($last_exp);
|
||||
if ($debug){print_r($last_exp) . "\n\n";}
|
||||
if ($last){
|
||||
$lyrics = $lyrics . $last_exp[$last] . $d;
|
||||
}
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr2 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr3 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($lr2)){
|
||||
$last_exp = explode('</div>', $lr1[0]);
|
||||
$last = array_key_last($last_exp);
|
||||
if ($debug){print_r($last_exp) . "\n\n";}
|
||||
if ($last){
|
||||
$lyrics = $lyrics . $last_exp[$last] . $d;
|
||||
}
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
}
|
||||
}
|
||||
foreach ($lr2 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif (isset($lr1)){
|
||||
foreach ($lr1 as $c1){
|
||||
if (substr($c1, 0, 2) !== "__" && substr($c1, 0, 2) !== "</"){
|
||||
if (strpos($c1, '</div>') === false){
|
||||
$lyrics = $lyrics . $c1 . $d;
|
||||
} else {
|
||||
$lyrics = $lyrics . substr($c1, 0, strpos($c1, '</div')) . $d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$lyrics = '';
|
||||
}
|
||||
|
||||
// Replace all href's with full link to Genius
|
||||
$lyrics = str_replace('href="/','target="_blank" href="' . $geniusurl, $lyrics);
|
||||
} else {
|
||||
$lyrics = 'N/A';
|
||||
}
|
||||
|
||||
// If routine couldn't find anything, return "unknown"
|
||||
if (!$lyrics || $lyrics === $d){$lyrics = "unknown";}
|
||||
|
||||
// Return data separated with delimeter "|,="
|
||||
if ($debug){
|
||||
echo "$returnURL$d$lyrics";
|
||||
} else {
|
||||
echo "$lyrics";
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
// Load environmental variables
|
||||
if (file_exists('.env')){
|
||||
$env = parse_ini_file('.env');
|
||||
$genius = $env['GENIUS_API_BASE64'];
|
||||
$debug = $env['DEBUG'] ? 1 : $env['DEBUG'];
|
||||
$show_err = $env['SHOW_ERRORS'] ? 1 : $env['SHOW_ERRORS'];
|
||||
} else {
|
||||
die('You forgot to create your .env file!');
|
||||
}
|
||||
|
||||
// Show errors
|
||||
if ($show_err){
|
||||
ini_set('display_errors', '1');
|
||||
ini_set('display_startup_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
}
|
||||
|
||||
// Set header info
|
||||
header('Access-Control-Allow-Origin: *');
|
||||
header('Content-Type: text/event-stream');
|
||||
header('Cache-Control: private, max-age=90');
|
||||
header('Cache-Control: no-cache');
|
||||
|
||||
// Genius URLs
|
||||
$geniusAPI = "https://api.genius.com/search?q=";
|
||||
$geniusID = "https://api.genius.com/songs/";
|
||||
$geniusurl = "https://genius.com/";
|
||||
$bearer = base64_decode($genius);
|
||||
|
||||
// Default variables
|
||||
$random_number = rand(0, 100);
|
||||
$art = '';
|
||||
$title = '';
|
||||
$ftitle = '';
|
||||
$lyrics = '';
|
||||
$scrapeme = '';
|
||||
$album = '';
|
||||
|
||||
// Get POST and/or GET variables for artist and song title
|
||||
$vartist = (empty($_POST['artist'])) ? (empty($_GET['artist'])) ? 'n' : $_GET['artist'] : $_POST['artist'];
|
||||
$vtitle = (empty($_POST['title'])) ? (empty($_GET['title'])) ? 'n' : $_GET['title'] : $_POST['title'];
|
||||
$vroute = (empty($_POST['route'])) ? (empty($_GET['route'])) ? 'n' : $_GET['route'] : $_POST['route'];
|
||||
if ($vartist === 'n' && $vtitle === 'n'){
|
||||
echo "offline|,=offline|,=offline|,=offline|,=offline|,=offline";
|
||||
exit(0);
|
||||
}
|
||||
$json = rawurlencode($vartist . ' - ' . $vtitle);
|
||||
|
||||
// Curl function
|
||||
function curlThis($url, $auth, $header, $returnt, $timeoutc, $timeout, $bearer){
|
||||
$exe = curl_init();
|
||||
curl_setopt($exe, CURLOPT_URL, "$url");
|
||||
if ($auth === 1){
|
||||
curl_setopt($exe, CURLOPT_HTTPHEADER, ["Authorization: Bearer $bearer"]);
|
||||
}
|
||||
curl_setopt($exe, CURLOPT_HEADER, $header);
|
||||
curl_setopt($exe, CURLOPT_RETURNTRANSFER, $returnt);
|
||||
curl_setopt($exe, CURLOPT_CONNECTTIMEOUT, $timeoutc);
|
||||
curl_setopt($exe, CURLOPT_TIMEOUT, $timeout);
|
||||
$raw = curl_exec($exe);
|
||||
curl_close($exe);
|
||||
return $raw;
|
||||
}
|
||||
|
||||
// Query Genius API using artist and song title to get URL of lyrics by querying first result
|
||||
$url = $geniusAPI . $json;
|
||||
$json_genius = json_decode(curlThis($url, 1, 0, 1, 5, 4, $bearer));
|
||||
$result = $json_genius->response->hits[0]->result;
|
||||
|
||||
$songid = $result->id;
|
||||
$scrapeme = $result->url;
|
||||
$artart = $result->primary_artist->image_url;
|
||||
|
||||
// Scrape lyrics from Genius
|
||||
$lyrics = 'N/A';
|
||||
|
||||
// Get album information from Genius API using songid
|
||||
$url = $geniusID . $songid;
|
||||
$get2 = json_decode(curlThis($url, 1, 0, 1, 5, 4, $bearer));
|
||||
$songInfo = $get2->response->song;
|
||||
$title = $songInfo->title;
|
||||
$ftitle = $songInfo->full_title;
|
||||
$album = $songInfo->album->name;
|
||||
$art = $songInfo->header_image_url;
|
||||
|
||||
// Double check if we have data and try something else if no data yet
|
||||
if (!$album){$album = $ftitle;}
|
||||
if (!$title){$title = $result->title;}
|
||||
if (!$ftitle){$ftitle = $result->full_title;}
|
||||
if (!$art){$art = $result->header_image_url;}
|
||||
|
||||
// Replace default Genius images with cool GIFs
|
||||
function badArt($arturl){
|
||||
$badart = ['https://radio.dou.bet/na.jpg','https://images.genius.com/9d53cf21e85632e8a774b470fc1af6d9.960x960x1.jpg','https://images.genius.com/5bb0d83dd9b4f5f97b7cea2e16091892.1000x1000x1.png','https://images.genius.com/4defb2d0b45e544711e5dbabe266a370.1000x1000x1.png',
|
||||
'https://images.genius.com/e3f28a8c15ae3b11ac9cc7aaef0396c1.512x512x1.jpg','https://images.genius.com/2aa2941e1d8ed0034c2ddc9dd5012af9.1000x1000x1.png','https://assets.genius.com/images/default_cover_image.png',
|
||||
'https://assets.genius.com/images/default_cover_image.jpg','https://images.genius.com/cc43e9f65bda58676823af326760364a.999x999x1.png'];
|
||||
$childish = ['https://images.genius.com/2114312d382ad914c2c7b6146fbfb6c2.300x300x1.jpg','https://images.genius.com/90d733d87dcdbe5bb5f89062e6fb381f.500x500x1.jpg','https://images.genius.com/90d733d87dcdbe5bb5f89062e6fb381f.500x500x1.jpg'];
|
||||
if (!$arturl || in_array($arturl, $badart)){
|
||||
if ($random_number <= 40){
|
||||
$art = "https://78.media.tumblr.com/a38fa7ca0f62769471df65b4ce8d177d/tumblr_pogjorskHk1w3y4ilo2_540.gif";
|
||||
} elseif ($random_number <= 70){
|
||||
$art = "https://i.imgur.com/PWw7VmH.gif";
|
||||
} else {
|
||||
$art = "https://i.pinimg.com/originals/d7/18/9b/d7189b9a574f7c279473847357a91f69.gif";
|
||||
}
|
||||
} else {
|
||||
$art = $arturl;
|
||||
}
|
||||
if (in_array($arturl, $childish)){
|
||||
$art = "https://miro.medium.com/v2/resize:fit:632/1*eswZSNBeUgzlczhy7qA9Nw.gif";
|
||||
}
|
||||
return $art;
|
||||
}
|
||||
|
||||
$art = badArt($art);
|
||||
|
||||
if ($vartist === 'BAW' && $vtitle === 'CHILDHOOD MEMORIES'){$art = "https://i1.sndcdn.com/artworks-zNyvrtxKfGAu60Yr-e7fGPA-t500x500.jpg";}
|
||||
|
||||
// If routine couldn't find anything, return "unknown"
|
||||
if (!$title){$title = $vtitle;}
|
||||
if (!$ftitle){$ftitle = "unknown";}
|
||||
if (!$lyrics){$lyrics = "unknown";}
|
||||
if (!$scrapeme){$scrapeme = "unknown";}
|
||||
if(!$album){$album = "unknown";}
|
||||
|
||||
// Return data separated with delimeter "|,="
|
||||
echo "$art|,=$title|,=$ftitle|,=$lyrics|,=$scrapeme|,=$album";
|
||||
Reference in new issue
Block a user