Bugfix when artist was found direct

Bugfix when son was found direct
Bugfix when user entered a search

Took 1 hour 47 minutes
This commit is contained in:
2020-07-12 18:25:18 +02:00
parent 4f2eb00297
commit 0312c57ace
4 changed files with 28 additions and 15 deletions

View File

@ -11,8 +11,9 @@ class Downloader
}
}
private function login( )
private function login( ): void
{
echo "[LOGIN] Logging in...";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "http://usdb.animux.de/index.php?&link=home" );
@ -30,15 +31,10 @@ class Downloader
// Receive server response ...
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
$out = curl_exec( $ch );
if( strpos( $out, 'Datensatz nicht gefunden' ) !== false )
{
echo "Not found - Skip\n";
curl_close( $ch );
return false;
}
curl_close( $ch );
self::$loggedIn = true;
echo "OK\n";
}
@ -46,15 +42,17 @@ class Downloader
* @param int $a_id
*
* @return bool
*
* @throws Exception
*/
public function requestSong( int $a_id ): ?bool
public function requestSong( int $a_id ): bool
{
if( ( $out = $this->downloadFile( $a_id ) ) === false )
{
return false;
}
$this->saveFile( $out );
return true;
}
/**
@ -145,7 +143,7 @@ class Downloader
return false;
}
if( ( $file = fopen( DOWNLOAD_PATH . "/$artist/$artist - $title.txt", 'w+' ) ) === false )
if( ( $file = fopen( DOWNLOAD_PATH . "/$artist/$artist - $title.txt", 'wb+' ) ) === false )
{
throw new RuntimeException( "$artist - $title *** Cannot open file handler" );
}