@@ -455,6 +455,7 @@ static function handleMoveFiles($line)
455455 self ::$ DOWNLOADER [self ::$ jobindex ]['current ' ]++;
456456 return [
457457 "updateType " =>"done " ,
458+ "index " =>intval (self ::$ DOWNLOADER [self ::$ jobindex ]['current ' ])-1 ,
458459 "filename " =>$ fname
459460 ];
460461 }
@@ -872,23 +873,26 @@ function ConfirmErase($error="")
872873if (isset ($ _GET ['dljob ' ]) && isset ($ _GET ['dlidx ' ]))
873874{
874875 $ dljobid =$ _GET ['dljob ' ];
875- $ dlidx =basename ($ _GET ['dlidx ' ]);
876+ $ dlidx =intval ($ _GET ['dlidx ' ]);
876877 $ force_dl =isset ($ _GET ['force ' ]);
877878 if (YTDLP ::getJobIndex ($ dljobid )!==-1 )
878879 {
879- $ mode ="" ;
880880 $ path ="" ;
881+ $ job =YTDLP ::$ DOWNLOADER [YTDLP ::getJobIndex ($ dljobid )]??die ("job not found " );
882+ $ task =$ job ['tasks ' ][$ dlidx ]??die ("task not found " );
883+ $ mode =$ task ['mode ' ]??die ("mode not found " );
884+ $ fname =$ task ['filename ' ]??die ("filename not found " );
881885 $ path .=$ mode ==="mp3 " ?YTDLP ::$ dl_dir_mp3 :YTDLP ::$ dl_dir_common ;
882886 $ path .="/ " ;
883887 $ path .=$ dljobid ;
884888 $ path .="/ " ;
885- $ path .=$ dlidx ;
889+ $ path .=$ fname ;
886890 if (file_exists ($ path ))
887891 {
888892 $ ctype =($ mode ==="mp3 " )?"audio/mp3 " :"video/mp4 " ;
889893 if ($ force_dl )
890894 {
891- header ("Content-Disposition: attachment; filename= \"" .rawurlencode ($ dlidx )."\"" );
895+ header ("Content-Disposition: attachment; filename= \"" .rawurlencode ($ fname )."\"" );
892896 }
893897
894898 header ("Content-Type: " .$ ctype );
@@ -898,7 +902,9 @@ function ConfirmErase($error="")
898902 fclose ($ file );
899903 die;
900904 }
905+ die ("file not found " );
901906 }
907+ die ("job not found " );
902908}
903909
904910// only html beyond this point
@@ -978,10 +984,10 @@ function handleUpdate(update)
978984 s=document.createElement("a");
979985 s.id='stat'+taskid;
980986 s.dataset.status="done";
981- s.href="index.php?dljob="+update.jobid+"&dlidx="+encodeURIComponent( update.filename) ;
987+ s.href="index.php?dljob="+update.jobid+"&dlidx="+update.index ;
982988 td.appendChild(s);
983989 var forcelink=document.createElement("a");
984- forcelink.href="index.php?force=true&dljob="+update.jobid+"&dlidx="+encodeURIComponent( update.filename) ;
990+ forcelink.href="index.php?force=true&dljob="+update.jobid+"&dlidx="+update.index ;
985991 forcelink.append(" ⬇ ");
986992 td.appendChild(forcelink);
987993 break;
@@ -1142,9 +1148,9 @@ function DisplayJob(job)
11421148 window.ytdlp_done++;
11431149 percent_bar.dataset.progress=task.progress.percent;
11441150 percent_number.dataset.progress=task.progress.percent+"%";
1145- status_icon.href="index.php?dljob="+job.jobid+"&dlidx="+encodeURIComponent(task.filename) ;
1151+ status_icon.href="index.php?dljob="+job.jobid+"&dlidx="+i ;
11461152 var forcelink=document.createElement("a");
1147- forcelink.href="index.php?force=true&dljob="+job.jobid+"&dlidx="+encodeURIComponent(task.filename) ;
1153+ forcelink.href="index.php?force=true&dljob="+job.jobid+"&dlidx="+i ;
11481154 forcelink.append(" ⬇ ");
11491155 td_status.appendChild(forcelink);
11501156 break;
0 commit comments