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

Commit f21cb0e6 authored by elleo's avatar elleo

Implement radio handshaking and radio adjustment

Add album art image url processing
Add function for creating station titles from lastfm urls
parent 06adde6b
......@@ -18,14 +18,26 @@
*/
// fakes the radio tuning protocol
require_once("../database.php");
require_once("radio-utils.php");
if(!isset($_GET['session']) || !isset($_GET['url'])) {
die("FAILED\n");
}
// just pretend that we have successfully tuned
$session = $_GET["session"];
$url = $_GET["url"];
die("OK\n");
$res = $mdb2->query("SELECT username FROM Radio_Sessions WHERE session = " . $mdb2->quote($session, "text"));
if(!$res->numRows()) {
die("BADSESSION\n");
}
$mdb2->query("UPDATE Radio_Sessions SET url = " . $mdb2->quote($url, "text") . " WHERE session = " . $mdb2->quote($session, "text"));
echo "response=OK\n";
echo "url=http://libre.fm\n"; // Need to parse the station request and give a real URL
echo "stationname=" . radio_title_from_url($url) ."\n";
?>
......@@ -18,15 +18,26 @@
*/
// fakes the radio handshake protocol
require_once("../database.php");
if(!isset($_GET['username']) || !isset($_GET['passwordmd5'])) {
die("BADAUTH\n");
}
$username = $_GET['username'];
$passmd5 = $_GET['passwordmd5'];
echo "session=00000000000000000000000000000000\n";
$res = $mdb2->query("SELECT username FROM Users WHERE username = " . $mdb2->quote($username, "text") . " AND password = " . $mdb2->quote($passmd5, "text"));
if (!$res->numRows()) {
die("BADAUTH\n");
}
$session = md5($passmd5 . time());
$mdb2->query("INSERT INTO Radio_Sessions (username, session) VALUES ( " . $mdb2->quote($username, "text") . ", " . $mdb2->quote($session, "text") . ")");
echo "session=" . $session . "\n";
echo "stream_url=this.is.broken.$username.example.com\n";
echo "subscriber=0\n";
echo "framehack=0..\n";
......
<?
/* Libre.fm -- a free network service for sharing your music listening habits
Copyright (C) 2009 Libre.fm Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
function radio_title_from_url($url) {
if(substr($url, 0, 20) == "lastfm://globaltags/") {
$tag = substr($url, 20);
return "Libre.fm " . ucwords($tag) . " Tag Radio";
}
return $url;
}
?>
<?
<?php
/* Libre.fm -- a free network service for sharing your music listening habits
Copyright (C) 2009 Libre.fm Project
......@@ -18,60 +18,61 @@
*/
// fakes the radio xspf generation
require_once('../config.php');
require_once('../database.php');
require_once('../data/Track.php');
require_once("radio-utils.php");
if(!isset($_GET['sk']) || !isset($_GET['desktop'])) {
die("Uh-oh\n");
die("BADSESSION\n");
}
$session = $_GET["sk"];
$res = $mdb2->query("SELECT url FROM Radio_Sessions WHERE session = " . $mdb2->quote($session, "text"));
if(!$res->numRows()) {
die("BADSESSION\n");
}
$url = $res->fetchOne(0);
$title = radio_title_from_url($url);
echo "<playlist version=\"1\" xmlns:lastfm=\"http://www.audioscrobbler.net/dtd/xspf-lastfm\">\n";
echo "<title>Fake Jamendo Playlist</title>\n";
echo "<title>$title</title>\n";
echo "<creator>libre.fm</creator>\n";
echo "<link rel=\"http://www.last.fm/skipsLeft\">9999</link>\n";
echo "<trackList>\n";
$res = $mdb2->query("SELECT name, artist, album, duration, downloadurl, streamurl FROM Track WHERE license='http://creativecommons.org/licenses/by/3.0/' AND streamurl LIKE 'jamendo://track/stream/%' LIMIT 5");
$res = $mdb2->query("SELECT name, artist, album FROM Track WHERE streamurl != '' LIMIT 10");
while($row = $res->fetchRow(MDB2_FETCHMODE_ASSOC)) {
$name = $row["name"];
$artist = $row["artist"];
$album = $row["album"];
$duration = $row["duration"];
if($duration == "") {
$duration = "180000";
}
$downloadurl = $row["downloadurl"];
$streamurl = $row["streamurl"];
if(ereg("jamendo://track/stream/(.*)", $streamurl, $regs)) {
$jmtrack = $regs[1];
echo " <track>\n";
echo " <location>http://api.jamendo.com/get2/stream/track/redirect/?id=$jmtrack&amp;streamencoding=ogg2</location>\n";
echo " <title>$name</title>\n";
echo " <id>$jmtrack</id>\n";
echo " <album>$album</album>\n";
echo " <creator>$artist</creator>\n";
echo " <duration>$duration</duration>\n";
echo " <image></image>\n";
echo " <lastfm:trackauth>00000</lastfm:trackauth>\n";
echo " <lastfm:albumId>0000000</lastfm:albumId>\n";
echo " <lastfm:artistId>00000000</lastfm:artistId>\n";
echo " <link rel=\"http://www.last.fm/artistpage\"></link>\n";
echo " <link rel=\"http://www.last.fm/albumpage\"></link>\n";
echo " <link rel=\"http://www.last.fm/trackpage\"></link>\n";
echo " <link rel=\"http://www.last.fm/buyTrackURL\"></link>\n";
echo " <link rel=\"http://www.last.fm/buyAlbumURL\"></link>\n";
echo " <link rel=\"http://www.last.fm/freeTrackURL\">$downloadurl</link>\n";
echo " </track>\n";
}
}
$track = new Track($row["name"], $row["artist"]);
$album = new Album($row["album"], $row["artist"]);
$artist = new Artist($row["artist"]);
if($track->duration == 0) {
$track->duration = 1800;
}
echo " <track>\n";
echo " <location>" . htmlentities($track->streamurl) . "</location>\n";
echo " <title>" . $track->name . "</title>\n";
echo " <id>" . $track->name . "</id>\n";
echo " <album>" . $album->name . "</album>\n";
echo " <creator>" . $artist->name . "</creator>\n";
echo " <duration>" . $track->duration . "</duration>\n";
echo " <image>". $album->image . "</image>\n";
echo " <link rel=\"http://www.last.fm/artistpage\">" . htmlentities($artist->getURL()) . "</link>\n";
echo " <link rel=\"http://www.last.fm/albumpage\">" . htmlentities($album->getURL()) . "</link>\n";
echo " <link rel=\"http://www.last.fm/trackpage\">" . htmlentities($track->getURL()) . "</link>\n";
echo " <link rel=\"http://www.last.fm/buyTrackURL\"></link>\n";
echo " <link rel=\"http://www.last.fm/buyAlbumURL\"></link>\n";
echo " <link rel=\"http://www.last.fm/freeTrackURL\">" . htmlentities($track->downloadurl) . "</link>\n";
echo " </track>\n";
}
echo "</trackList>\n";
echo "</playlist>\n";
......
......@@ -18,6 +18,11 @@ function process_jamendo_url($url) {
return "http://api.jamendo.com/get2/bittorrent/file/plain/?album_id=" . $id . "&type=archive&class=ogg3";
}
if (substr($url, 10, 10) == "album/art/") {
$id = substr($url, 20);
return "http://api.jamendo.com/get2/image/album/redirect/?id=" . $id . "&imagesize=400";
}
// We don't know what this is
return $url;
}
......
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