We are no longer offering accounts on this server. Consider https://gitlab.freedesktop.org/ as a place to host projects.

Commit 6896699e authored by clint's avatar clint

same for artist

parent 06e5cf59
......@@ -29,18 +29,18 @@ function usernameFromSID($session_id)
global $adodb; // include the Database connector
// Delete any expired session ids
$adodb->Execute("DELETE FROM Scrobble_Sessions WHERE expires < " . time());
$adodb->Execute('DELETE FROM Scrobble_Sessions WHERE expires < ' . time());
try {
$res = $adodb->GetOne("SELECT username FROM Scrobble_Sessions WHERE sessionid = " . $adodb->qstr($session_id)); // get the username from the table
$res = $adodb->GetOne('SELECT username FROM Scrobble_Sessions WHERE sessionid = ' . $adodb->qstr($session_id)); // get the username from the table
}
catch (exception $e) {
die("FAILED ufs " . $e->getMessage() . "\n");
die('FAILED ufs ' . $e->getMessage() . '\n');
// die is there is an error, printing the error
}
if(!$res) {
die("BADSESSION\n");
die('BADSESSION\n');
// the user has no session
}
......@@ -56,19 +56,19 @@ function createArtistIfNew($artist) {
$artist = NoSpamTracks($artist);
try {
$res = $adodb->Execute("SELECT name FROM Artist WHERE name = " . ($artist));
$res = $adodb->GetOne('SELECT name FROM Artist WHERE lower(name) = lower(' . ($artist) . ')');
}
catch (exception $e) {
die("FAILED art " . $e->getMessage() . "\n");
die('FAILED art ' . $e->getMessage() . '\n');
}
if(!$res) {
// Artist doesn't exist, so we create them
try {
$res = $adodb->Execute("INSERT INTO Artist (name) VALUES (" . ($artist) . ")");
$res = $adodb->Execute('INSERT INTO Artist (name) VALUES (' . ($artist) . ')');
}
catch (exception $e) {
die("FAILED artc " . $e->getMessage() . "\n");
die('FAILED artc ' . $e->getMessage() . '\n');
}
}
}
......@@ -80,7 +80,7 @@ function createAlbumIfNew($artist, $album) {
$name = $adodb->GetOne('SELECT name FROM Album WHERE lower(name) = lower(' . ($album) . ') AND lower(artist_name) = lower(' . ($artist) . ')');
}
catch (exception $e) {
die("FAILED alb " . $e->getMessage() . "\n");
die('FAILED alb ' . $e->getMessage() . '\n');
}
if(!$name) {
......@@ -89,18 +89,18 @@ function createAlbumIfNew($artist, $album) {
$art = $adodb->qstr(getAlbumArt($artist, $album));
if ($art !="") {
$license = $adodb->qstr("amazon");
$license = $adodb->qstr('amazon');
$sql = "INSERT INTO Album (name, artist_name, image, artwork_license) VALUES (" . ($album) . ", " . ($artist) . ", " . ($art) . ", " . ($license) .")";
$sql = 'INSERT INTO Album (name, artist_name, image, artwork_license) VALUES (' . ($album) . ', ' . ($artist) . ', ' . ($art) . ', ' . ($license) .')';
} else {
$sql = "INSERT INTO Album (name, artist_name) VALUES (" . ($album) . ", " . ($artist) . ")";
$sql = 'INSERT INTO Album (name, artist_name) VALUES (' . ($album) . ', ' . ($artist) . ')';
}
try {
$adodb->Execute($sql);
}
catch (exception $e) {
die("FAILED albc " . $e->getMessage() . "\n");
die('FAILED albc ' . $e->getMessage() . '\n');
}
}
}
......@@ -113,26 +113,26 @@ function getTrackCreateIfNew($artist, $album, $track, $mbid) {
try {
if($album != 'NULL') {
$res = $adodb->GetOne("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND lower(album_name) = lower(" . ($album) . ")");
$res = $adodb->GetOne('SELECT id FROM Track WHERE lower(name) = lower(' . ($track) . ') AND lower(artist_name) = lower(' . ($artist) . ') AND lower(album_name) = lower(' . ($album) . ')');
} else {
$res = $adodb->GetOne("SELECT id FROM Track WHERE lower(name) = lower(" . ($track) . ") AND lower(artist_name) = lower(" . ($artist) . ") AND album_name IS NULL");
$res = $adodb->GetOne('SELECT id FROM Track WHERE lower(name) = lower(' . ($track) . ') AND lower(artist_name) = lower(' . ($artist) . ') AND album_name IS NULL');
}
}
catch (exception $e) {
die("FAILED trk " . $e->getMessage() . "\n");
die('FAILED trk ' . $e->getMessage() . '\n');
}
if(!$res) {
// Create new track
try {
$res = $adodb->Execute("INSERT INTO Track (name, artist_name, album_name, mbid) VALUES ("
. ($track) . ", "
. ($artist) . ", "
. ($album) . ", "
. ($mbid) . ")");
$res = $adodb->Execute('INSERT INTO Track (name, artist_name, album_name, mbid) VALUES ('
. ($track) . ', '
. ($artist) . ', '
. ($album) . ', '
. ($mbid) . ')');
}
catch (exception $e) {
die("FAILED trkc " . $e->getMessage() . "\n");
die('FAILED trkc ' . $e->getMessage() . '\n');
}
return getTrackCreateIfNew($artist, $album, $track, $mbid);
} else {
......@@ -144,30 +144,30 @@ function getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid, $tid) {
global $adodb;
try {
$res = $adodb->GetOne("SELECT id FROM Scrobble_Track WHERE name = lower("
. ($track) . ") AND artist = lower(" . ($artist) . ") AND album "
. (($album == 'NULL') ? "IS NULL" : ("= lower(" . ($album) . ")")) . " AND mbid "
. (($mbid == 'NULL') ? "IS NULL" : ("= lower(" . ($mbid) . ")")));
$res = $adodb->GetOne('SELECT id FROM Scrobble_Track WHERE name = lower('
. ($track) . ') AND artist = lower(' . ($artist) . ') AND album '
. (($album == 'NULL') ? 'IS NULL' : ('= lower(' . ($album) . ')')) . ' AND mbid '
. (($mbid == 'NULL') ? 'IS NULL' : ('= lower(' . ($mbid) . ')')));
}
catch (exception $e) {
die("FAILED st " . $e->getMessage() . "\n");
die('FAILED st ' . $e->getMessage() . '\n');
}
if(!$res) {
$sql = "INSERT INTO Scrobble_Track (name, artist, album, mbid, track) VALUES ("
. "lower(" . ($track) . "), "
. "lower(" . ($artist) . "), "
. (($album == 'NULL') ? "NULL" : "lower(" . ($album) . ")") . ", "
. (($mbid == 'NULL') ? "NULL" : "lower(" . ($mbid) . ")") . ", "
. ($tid) . ")";
$sql = 'INSERT INTO Scrobble_Track (name, artist, album, mbid, track) VALUES ('
. 'lower(' . ($track) . '), '
. 'lower(' . ($artist) . '), '
. (($album == 'NULL') ? 'NULL' : 'lower(' . ($album) . ')') . ', '
. (($mbid == 'NULL') ? 'NULL' : 'lower(' . ($mbid) . ')') . ', '
. ($tid) . ')';
try {
$res = $adodb->Execute($sql);
}
catch (exception $e) {
$msg = $e->getMessage() . " - " . $e->getUserInfo();
$msg = $e->getMessage() . ' - ' . $e->getUserInfo();
reportError($msg, $sql);
die("FAILED stc " . $res->getMessage() . "\n");
die('FAILED stc ' . $res->getMessage() . '\n');
}
return getScrobbleTrackCreateIfNew($artist, $album, $track, $mbid, $tid);
} else {
......@@ -179,10 +179,10 @@ function scrobbleExists($username, $artist, $track, $time) {
global $adodb;
try {
$res = $adodb->GetOne("SELECT time FROM Scrobbles WHERE username = " . ($username) . " AND artist = " . ($artist) . " AND track = " . ($track) . " AND time = " . ($time));
$res = $adodb->GetOne('SELECT time FROM Scrobbles WHERE username = ' . ($username) . ' AND artist = ' . ($artist) . ' AND track = ' . ($track) . ' AND time = ' . ($time));
}
catch (exception $e) {
die("FAILED se " . $e->getMessage() . "\n");
die('FAILED se ' . $e->getMessage() . '\n');
}
if(!$res) {
......@@ -195,7 +195,7 @@ function NoSpamTracks ($track) {
// This function exists to remove things like '(PREVIEW: buy it at www.magnatune.com)' from track names.
$track = str_replace(" (PREVIEW: buy it at www.magnatune.com)", "", $track);
$track = str_replace(' (PREVIEW: buy it at www.magnatune.com)', "", $track);
return $track;
......@@ -203,25 +203,25 @@ function NoSpamTracks ($track) {
function getAlbumArt($artist, $album) {
$Access_Key_ID = "1EST86JB355JBS3DFE82"; // this is mattl's personal key :)
$Access_Key_ID = '1EST86JB355JBS3DFE82'; // this is mattl's personal key :)
$SearchIndex='Music';
$Keywords=urlencode($artist.' '.$album);
$Operation = "ItemSearch";
$Version = "2007-07-16";
$ResponseGroup = "ItemAttributes,Images";
$Operation = 'ItemSearch';
$Version = '2007-07-16';
$ResponseGroup = 'ItemAttributes,Images';
$request=
"http://ecs.amazonaws.com/onca/xml"
. "?Service=AWSECommerceService"
. "&AssociateTag=" . $Associate_tag
. "&AWSAccessKeyId=" . $Access_Key_ID
. "&Operation=" . $Operation
. "&Version=" . $Version
. "&SearchIndex=" . $SearchIndex
. "&Keywords=" . $Keywords
. "&ResponseGroup=" . $ResponseGroup;
$aws_xml = simplexml_load_file($request) or die("xml response not loading\n");
'http://ecs.amazonaws.com/onca/xml'
. '?Service=AWSECommerceService'
. '&AssociateTag=' . $Associate_tag
. '&AWSAccessKeyId=' . $Access_Key_ID
. '&Operation=' . $Operation
. '&Version=' . $Version
. '&SearchIndex=' . $SearchIndex
. '&Keywords=' . $Keywords
. '&ResponseGroup=' . $ResponseGroup;
$aws_xml = simplexml_load_file($request) or die('xml response not loading\n');
$image = $aws_xml->Items->Item->MediumImage->URL;
$URI = $aws_xml->Items->Item->DetailPageURL;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment