-
Notifications
You must be signed in to change notification settings - Fork 0
/
getLinks.php~
35 lines (30 loc) · 1.03 KB
/
getLinks.php~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
if(!isset($_REQUEST['uri'])){
echo "No URI given!";
}
$uri = $_REQUEST['uri'];
$command = "/usr/bin/perl /var/www/spottube/spotify-scrape.pl '$uri'";
exec($command, $output);
foreach($output as &$title) {
if(($pos = strpos($title, '. ')) !== false)
{
$new_title = substr($title, $pos + 1);
}
else
{
$new_title = get_last_word($title);
}
$title = $new_title;
$transform = "echo '$title' | sed -e 's/ - / /g' | sed 's/ /+/g'";
$response = shell_exec($transform);
$yturl = "http://gdata.youtube.com/feeds/api/videos?q=".$response."&max-results=1&v=2";
$ytpage = file_get_contents($yturl);
$ytpage = str_replace("><",">\n<",$ytpage);
$ytline = strstr($ytpage, 'media:player');
$ytlinecut = strstr($ytline, 'http://www.youtube.com/watch?v=');
$ytlink = strstr($ytlinecut, "&", true);
//$linkcommand = "echo '$ytline'"; #| grep 'media:player' | sed \"s/<media:player url='//g\" |sed \"s/'\/>//g\"";
//$ytlink = shell_exec($linkcommand);
echo "<a href='$ytlink'>$ytlink</a>";
}
?>