Jump to content
Robert1995

PHP Make my playlist

Recommended Posts

Posted

Link tot ce exista intr-un directoriu , recursiv daca inauntru mai sunt directoare

result :

http://robert1995.zxq.net/

Nu prea exista css , but who cares about that


<html>
<style>
.push{
margin-left:50px;
}
</style>
<body>
<?php
function link_my_dir($directory , $ignore = array()){
if ($handle = opendir($directory)) {
$tokens = explode(DIRECTORY_SEPARATOR , $directory);
echo '<div class="push">';
if(!empty($ignore)){
echo $tokens[count($tokens) - 1 ].'<br/>';
echo '<div class="push">';
}
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !='nfo.nfo') {
if(is_dir($directory.DIRECTORY_SEPARATOR.$file) && !in_array($directory.DIRECTORY_SEPARATOR.$file , $ignore)){
$ignore[] = $directory.DIRECTORY_SEPARATOR.$file;
link_my_dir($directory.DIRECTORY_SEPARATOR.$file , $ignore);
}else{
$to_echo = str_replace(array("[www.keepvid.com]", "_" , ".mp4" , ".mp3") , "" , $file);
$search_query = str_replace("-" , "" , $to_echo);
$search_query = str_replace(" " , "+" , $search_query);
$fix_space = explode("+" , $search_query);
foreach($fix_space as $k=>$f){
if($f == '')
unset($fix_space[$k]);
}
$search_query = implode("+" , $fix_space);
//echo "$to_echo . Link : http://www.youtube.com/results?search_query=$search_query&aq=f<br/>";
echo '<a target="_blank" href="http://www.youtube.com/results?search_query='.$search_query.'&aq=f">'.$to_echo .'</a><br/>';
}
}
}
echo '</div>';
echo '</div>';
closedir($handle);
}
}
echo "Results : <br/>";

link_my_dir('D:\My Documents\Muzica');
?>

</body>
</html>

  • Upvote 1
  • Downvote 1
Posted

N-au de ce sa nu accepte curl. Maxim schimbi agent-ul din php.ini sau ce-o fi si va merge si cu curl. Nu au de unde sti ca nu este un browser acolo. Da, cu checkboxuri ma gandeam, sa dea 2,3 sugestii si apoi sa alegi care e buna. Cum ziceam, astfel scapi de muzica din calculator si vei avea un playlist online cu tot ce-ti place. Eventual poti face cautari si in trilulilu pentru ca au doar audio si astfel nu mananci asa multa banda. vezi ca era ceva implementat pe fermademuzica.ro, poate te inspiri de acolo. poti oferi si un serviciu - domeniu sau subdomeniu pe undeva, si ai sanse cel putin sa te faci cunoscut, daca nu sa scoti chiar bani. Daca ai nevoie de ceva ma gasesti pe tromfilx ca poate te pot ajuta. Fa asta si cred ca te poti baga si la grupul de php de pe rst. ;)

Posted

:) nu stiu , poate o sa fac din placere odata si o sa fac public codul ... si chestia asta am scris-o doar pentru ca cineva mi-a cerut playlistul + l-am facut public pentru ca nu e mare branza

Edit :

Chestiile grozave nu prea sunt pe PHP curat .

Posted
N-au de ce sa nu accepte curl. Maxim schimbi agent-ul din php.ini sau ce-o fi si va merge si cu curl. Nu au de unde sti ca nu este un browser acolo. Da, cu checkboxuri ma gandeam, sa dea 2,3 sugestii si apoi sa alegi care e buna. Cum ziceam, astfel scapi de muzica din calculator si vei avea un playlist online cu tot ce-ti place. Eventual poti face cautari si in trilulilu pentru ca au doar audio si astfel nu mananci asa multa banda. vezi ca era ceva implementat pe fermademuzica.ro, poate te inspiri de acolo. poti oferi si un serviciu - domeniu sau subdomeniu pe undeva, si ai sanse cel putin sa te faci cunoscut, daca nu sa scoti chiar bani. Daca ai nevoie de ceva ma gasesti pe tromfilx ca poate te pot ajuta. Fa asta si cred ca te poti baga si la grupul de php de pe rst. ;)

Ar fi misto un serviciu de genul,poate chiar si organizarea playlist-urilor in functie

de artisti sau taguri.

Posted (edited)

Imi place conceptul, felicitari... dar.

Am dezvoltat o versiune mai buna (mai functionala).

E facut cu jQuery, daca nu ai javascript pornit este acelasi script original, deci te duce pe search youtube. Daca ai javascript pornit se deschide un box cu primul video de pe youtube dupa keyword-ul fisierului pe care dai click.



<!doctype html>
<html lang="en">
<meta charset="UTF-8" />
<title>make my playlist v2</title>
<style>
body{
background-color:#fff;
text-align:left;
color:#444;
}
a{
text-decoration:none;
color:#000;
font-family:arial;
font-size:12px;
}
a:hover{
background-color:#0099ff;
}
#links{
display:block;
}
#box{
width:100%;
height:80%;
position:fixed;
top:10%;
bottom:10%;
display:none;
background-color:#fff;
border-top:2px solid #000;
border-bottom:2px solid #000;
text-align:Center;
z-index:1;
}
.push{
margin-left:50px;
}

#count{
font-size:30px;
font-family:arial;
}
#title{
font-size:24px;
background-color:rgba(0,100,200,0.5);
text-align:Center;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

/* SCRIPT YOUTUBE INSTANT -- SURSA - http://www.9lessons.info/2010/09/youtube-instant-search-with-jquery-and.html -- modificata de JohnDoe @ rstcenter.com/forum - http://rstcenter.com/forum/42750-php-make-my-playlist.rst */
function close(){
$('#box').html('').hide();
}
$(document).ready(function()
{


$('a').click(function() {

var keyword= $(this).attr('title');
// Youtube API
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=1&v=2&alt=jsonc';

$.ajax
({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{

if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;
var video_title=data.title;
var video_viewCount=data.viewCount;

// IFRAME Embed for YouTube

var video_frame="<iframe width='840' height='585' src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";

var final="<div id='title'>"+video_title+"</div><div>"+video_frame+"</div><div id='count'>"+video_viewCount+" Views</div>";

$("#box").fadeIn().html('<a href="javascript:close()">Close this box.</a><br />'+final); // Result

});
}
else
{
$("#box").fadeIn().html('<a href="javascript:close()">Close this box.</a><br /><div id=\'no\'>No Video</div>');
}
}

});


return false;
}


);
});
</script>
<body>
<section id="links">
<?php
function link_my_dir($directory , $ignore = array()){
if ($handle = opendir($directory)) {
$tokens = explode(DIRECTORY_SEPARATOR , $directory);
echo '<div class="push">';
if(!empty($ignore)){
echo $tokens[count($tokens) - 1 ].'<br/>';
echo '<div class="push">';
}
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !='nfo.nfo') {
if(is_dir($directory.DIRECTORY_SEPARATOR.$file) && !in_array($directory.DIRECTORY_SEPARATOR.$file , $ignore)){
$ignore[] = $directory.DIRECTORY_SEPARATOR.$file;
link_my_dir($directory.DIRECTORY_SEPARATOR.$file , $ignore);
}else{
$to_echo = str_replace(array("[www.keepvid.com]", "_" , ".mp4" , ".mp3") , "" , $file);
$search_query = str_replace("-" , "" , $to_echo);
$search_query = str_replace(" " , "+" , $search_query);
$fix_space = explode("+" , $search_query);
foreach($fix_space as $k=>$f){
if($f == '')
unset($fix_space[$k]);
}
$search_query = implode("+" , $fix_space);
//echo "$to_echo . Link : http://www.youtube.com/results?search_query=$search_query&aq=f<br/>";

echo '<a class="jqq" title="'.$to_echo.'" target="_blank" href="http://www.youtube.com/results?search_query='.$search_query.'&aq=f">'.$to_echo .'</a><br/>';
}
}
}
echo '</div>';
echo '</div>';
closedir($handle);
}
}
echo "Results : <br/>";

link_my_dir('C:\music'); //unde ai muzica
?>

</section>
<div id="box"></div>

</body>
</html>

Image--

playlistjqversion.th.jpg

Uploaded with ImageShack.us

//edit

Am observat ca nu de fiecare data este returnat un video la cate te astepti (de ex daca pui o melodie si poate iti da numai demo-ul, sau o versiune mai scurta, sau poate vrei videoclip...). As putea sa dezvolt unpic mai mult codul astfel incat sa poti comuta video-urile ... daca nu iti place video-ul sa poti sa mergi pe urmatorul din lista celor returnate in functie de acel keyword care este in 'title' la fiecare link. Are rost sa mai fac si asta sau nu ?

Edited by JohnDoe
edit.
Posted (edited)

Check this :) mi-am folosit un popup care l-am scris mai demult , la mine daca dai click in afara divului de popup , acesta se inchide automat + zona e safe pentru alte clickuri

Demo : 2011-11-08_2043 - RusuAndreiRobert's library

Am updatat si pe site http://robert1995.zxq.net/


<!--
http://rstcenter.com/forum/42750-php-make-my-playlist.rst#post287493
PHP / Popup By Robert1995 @ rst
Thanks to JohnDoe @rst for help with embeding
-->
<html lang="en">
<meta charset="UTF-8" />
<title>make my playlist v2</title>
<style>
.push{
margin-left:25px;
}
body{
background-color:#fff;
text-align:left;
color:#444;
}
a{
text-decoration:none;
color:#000;
font-family:arial;
font-size:12px;
}
a:hover{
background-color:#0099ff;
}

#popup{
background: #fff;
padding: 20px;
border: 20px solid #ddd;
float: left;
font-size: 1.2em;
position: fixed;
top: 50%; left: 50%;
z-index: 99999;
/*--CSS3 Box Shadows--*/
-webkit-box-shadow: 0px 0px 20px #000;
-moz-box-shadow: 0px 0px 20px #000;
box-shadow: 0px 0px 20px #000;
/*--CSS3 Rounded Corners--*/
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">

$(document).ready(function()
{

jQuery.fn.center = function () {
this.css("position","absolute");
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px");
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px");
return this;
}

jQuery.fn.fullScreen = function ( z_index_value ) {
default_z_index_value = 100;

z_index_value = typeof z_index_value == "undefined" ? default_z_index_value : z_index_value;

this.css("position","absolute");
this.css("z-index",z_index_value);
this.css("left","0");
this.css("top","0");
this.css("height", ($(window).height() + "px"));
this.css("width" , ($(window).width() + "px"));
return this;
}

/** PopUp Dependent Variables */
var popup_id = "popup";
var popup_block_body_id = "body_block";
var popup_close_class = "close_popup";
/** Trick To Set Type Boolean */
var popup_active;popup_active = false;

function showPopUp(content){
if(popup_active == false){
/** Popup Active Constants */
popup_active = true;
/** Generate Popup content */
popup_content = "";
popup_content = popup_content + "<div id="+popup_id+">";
popup_content = popup_content + content;
popup_content = popup_content + "<div class=\"clear\"></div>";
popup_content = popup_content + "</div>";
/** Start To Show Popup */
/** Create Protection Div */
$("body").append("<div id="+popup_block_body_id+"></div>");
$("#"+popup_block_body_id).fullScreen("not");
$("#"+popup_block_body_id).append(popup_content);
$("#"+popup_id).center();
}
}

function removePopBlock(){
if(popup_active == true){
$("#"+popup_block_body_id).remove();
popup_active = false;
}
}
$("."+popup_close_class).live('click',function(event){
removePopBlock();
});

$("#"+popup_block_body_id).live('click',function(event){
if ($(event.target).attr("id") == popup_block_body_id && popup_active == true) {
event.preventDefault();
event.stopPropagation();
removePopBlock();
}
});
$('a').click(function(event) {
event.preventDefault();
event.stopPropagation();
var keyword= $(this).attr('title');
// Youtube API
var yt_url='http://gdata.youtube.com/feeds/api/videos?q='+keyword+'&format=5&max-results=1&v=2&alt=jsonc';

$.ajax
({
type: "GET",
url: yt_url,
dataType:"jsonp",
success: function(response)
{
if(response.data.items)
{
$.each(response.data.items, function(i,data)
{
var video_id=data.id;

// IFRAME Embed for YouTube

var video_frame="<iframe width='940' height='450' src='http://www.youtube.com/embed/"+video_id+"' frameborder='0' type='text/html'></iframe>";
var demo_content = '<div class='+popup_close_class+'>Close</div>'+video_frame;
showPopUp(demo_content);
});
} else {
var demo_content = '<div class='+popup_close_class+'>Close</div> No video available';
showPopUp(demo_content);
}
}

});


return false;
});
});
</script>
<body>
<section id="links">
<?php
function link_my_dir($directory , $ignore = array()){
if ($handle = opendir($directory)) {
$tokens = explode(DIRECTORY_SEPARATOR , $directory);
echo '<div class="push">';
if(!empty($ignore)){
echo $tokens[count($tokens) - 1 ].'<br/>';
echo '<div class="push">';
}
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file !='nfo.nfo') {
if(is_dir($directory.DIRECTORY_SEPARATOR.$file) && !in_array($directory.DIRECTORY_SEPARATOR.$file , $ignore)){
$ignore[] = $directory.DIRECTORY_SEPARATOR.$file;
link_my_dir($directory.DIRECTORY_SEPARATOR.$file , $ignore);
}else{
$to_echo = str_replace(array("[www.keepvid.com]", "_" , ".mp4" , ".mp3") , "" , $file);
$search_query = str_replace("-" , "" , $to_echo);
$search_query = str_replace(" " , "+" , $search_query);
$fix_space = explode("+" , $search_query);
foreach($fix_space as $k=>$f){
if($f == '')
unset($fix_space[$k]);
}
$search_query = implode("+" , $fix_space);
//echo "$to_echo . Link : http://www.youtube.com/results?search_query=$search_query&aq=f<br/>";

echo '<a class="jqq" title="'.$to_echo.'" target="_blank" href="http://www.youtube.com/results?search_query='.$search_query.'&aq=f">'.$to_echo .'</a><br/>';
}
}
}
echo '</div>';
echo '</div>';
closedir($handle);
}
}
echo "Results : <br/>";

link_my_dir('D:\My Documents\Muzica'); //unde ai muzica
?>

</section>
<div id="box"></div>

</body>
</html>

Edited by Robert1995
Posted

^Cand dau click nu imi deschide nimic,am firefox 3.6 si javascript activat

^^M-am uitat putin peste codul tau, am testat pe localhost si merge in afara faptului ca nu imi apare box-ul cu melodia cand dau click pe ea...daca dau disable javascript imi deschide in alt tab si e ok

Dar daca fisierul e pe un host,nu are cum sa iti preia lista de melodii,da o eroare de genul(failed to open dir: No such file or directory in) si din cate stiu eu,e normal sa dea eroarea aia pentru ca trebuie sa dai link catre un director de pe host,ca sa mearga,nu de pe pc!Daca am gresit cu ce am zis aici corectati-ma!

Posted (edited)

te corectez , pe host am pus direct versiunea html , hostul nu imi permite sa il inchid nu stiu de ce ( probabil pentru ca folosesc un fel de auto click pe close cand dai click inafara function ) , hostingul e unul free de cacat care nici htaccess nu permite

Later edit :

Merge , nu stiu ce nu era in ok

Edited by Robert1995

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...