Compare commits

..

7 Commits

Author SHA1 Message Date
3dc74e43b3 Create start.sh 2021-03-26 08:20:42 +01:00
ce0a9f8041 Update youtube-dl.exe 2021-03-26 08:19:05 +01:00
15f6f4e0e8 Update encoding 2021-01-01 01:04:43 +01:00
79db89f932 Update encoding 2020-12-31 20:29:44 +01:00
d37db84faf Update 2020-12-31 20:21:09 +01:00
7d0cc28981 Update to config version 2020-12-31 17:45:25 +01:00
5f1635dddc „youtube-dl.exe“ löschen 2020-12-31 17:30:23 +01:00
7 changed files with 67 additions and 12 deletions

View File

@ -157,7 +157,14 @@ class AudioVideoHandler
private function download( $file ) private function download( $file )
{ {
echo "[INFO] Downloading $file..."; echo "[INFO] Downloading $file...";
exec( 'youtube-dl.exe --extract-audio --no-warnings -q --embed-thumbnail --audio-format mp3 --recode-video mp4 --audio-quality 4 -k -o downloaded.%(ext)s "ytsearch: ' . $file . '"' ); if( USE_INTERNAL_YOUTUBEDL_EXE )
{
exec( __DIR__ . '/youtube-dl.exe --extract-audio --no-warnings -q --embed-thumbnail --audio-format mp3 --recode-video mp4 --audio-quality 4 -k -o downloaded.%(ext)s "ytsearch: ' . $file . '"' );
}
else
{
exec( YOUTUBE_DL_PATH . ' --extract-audio --no-warnings -q --embed-thumbnail --audio-format mp3 --recode-video mp4 --audio-quality 4 -k -o downloaded.%(ext)s "ytsearch: ' . $file . '"' );
}
echo "OK\n"; echo "OK\n";
list( $artist, $title ) = explode( ' - ', $file ); list( $artist, $title ) = explode( ' - ', $file );
if ( file_exists( './downloaded.f135.mp4' ) === true ) if ( file_exists( './downloaded.f135.mp4' ) === true )

View File

@ -24,8 +24,8 @@ class Downloader
curl_setopt( $ch, CURLOPT_POSTFIELDS, curl_setopt( $ch, CURLOPT_POSTFIELDS,
http_build_query( http_build_query(
array( array(
'user' => 'trump@whitehouse.gov', 'user' => ANIMUX_USERNAME,
'userpass3' => 'C7AFvca6Ri6VhZL' 'userpass3' => ANIMUX_PASSWORD
) ) ); ) ) );
// Receive server response ... // Receive server response ...
@ -115,11 +115,14 @@ class Downloader
$artist = str_replace( array( '#ARTIST:', '/' ), array( '', '-' ), strtok( $out, "\n" ) ); $artist = str_replace( array( '#ARTIST:', '/' ), array( '', '-' ), strtok( $out, "\n" ) );
$artist = preg_replace( "/[^a-zA-Z0-9_.!äöü\s-]/m/u", "", $artist ); $artist = utf8_encode( $artist );
$artist = str_replace( array( "ö", "ä", "ü" ), array( "oe", "ae", "ue" ), $artist );
$artist = preg_replace( '/[^a-zA-Z0-9\ \-]/', '', $artist );
$title = str_replace( array( '#TITLE:', '/' ), array( '', '-' ), strtok( "\n" ) ); $title = str_replace( array( '#TITLE:', '/' ), array( '', '-' ), strtok( "\n" ) );
$title = preg_replace( "/[^a-zA-Z0-9_.!äöü\s-]/m/u", "", $title ); $title = utf8_encode( $title );
$title = str_replace( array( "ö", "ä", "ü" ), array( "oe", "ae", "ue" ), $title );
$title = preg_replace( '/[^a-zA-Z0-9\ \-]/', '', $title );
echo "[INFO] Found $artist - $title\n"; echo "[INFO] Found $artist - $title\n";
@ -154,10 +157,10 @@ class Downloader
} }
fclose( $file ); fclose( $file );
echo "[SUCCESS] Downloaded \"$title - $artist\"\n"; echo "\n[SUCCESS] Downloaded \"$title - $artist\"\n";
return true; return true;
} }
} }

26
GetAll.php Normal file
View File

@ -0,0 +1,26 @@
<?php
system( "clear" );
require_once 'config.inc.php';
echo "\n";
echo "Please enter the number from->to to download karaoke-files";
echo "\n";
$from = readline( "@From[int] " );
echo "\n";
$to = readline( "@To[int] " );
$downloader = new Downloader();
for( $i=$from; $i <= $to; $i++ )
{
try
{
$downloader->requestSong( $i );
}catch ( RuntimeException $e )
{
echo "An error occurred while processing the download.\n";
echo $e->getMessage() . "\n";
}
}

View File

@ -0,0 +1,12 @@
# Willkommen zum Karaoke-Management System von Tobias Hopp
- Um einen Start zu ermöglichen, muss zuerst die config.inc.php angepasst werden.
- Für das Projekt ist die PHP-Version 7.3 empfohlen, da dieses mit ihr programmiert und getestet wurde.
Für andere Versionen kann keine Garantie gewährleistet werden.
## Variablen der config.inc.php
- DOWNLOAD_PATH: Dies ist der Pfad, der definiert wo die Dateien gespeichert werden. WICHTIG: Dieser Ordner muss lesbar und beschreibbar sein. Außerdem sollte er nicht während der Ausführung des Skripts manipuliert werden.
- USE_INTERNAL_YOUTUBEDL_EXE: Dies ist eine Optione für Windows und Linux User. Windows-User sollten hier den Wert auf "true" belassen. Dann wird die youtube-dl.exe benutzt, welche sich bereits in dem Ordner des Programms befindet. Linux User sollten hier "false" wählen.
- YOUTUBE_DL_PATH: Dies ist der alternative Pfad zu der youtube-dl. Wichtig hierbei ist, dass diese vom Programm ausführbar ist!
- ANIMUX_USERNAME: Hier sollte der Benutzername eures Animux-Benutzers eingegeben werden
- ANIMUX_PASSWORD: Hier sollte euer Passwort des Animux-Benutzers eingegeben werden.

View File

@ -1,12 +1,17 @@
<?php <?php
define( 'DOWNLOAD_PATH', 'C:/Users/hoppt/Documents/Karaoke' );
mb_internal_encoding("UTF-8"); mb_internal_encoding("UTF-8");
// Please change the following vars before the fist start!
define( 'DOWNLOAD_PATH', '/media/tobias/Steam-Spiel/Karaoke' );
define( 'USE_INTERNAL_YOUTUBEDL_EXE', false );
define( 'YOUTUBE_DL_PATH', '/usr/bin/youtube-dl' );
define( 'ANIMUX_USERNAME', 'idiota@idi.at' );
define( 'ANIMUX_PASSWORD', 'XANwe6ZhKCnaXky' );
//mb_internal_encoding("UTF-8");
error_reporting(0); error_reporting(0);
require_once 'AudioVideoHandler.php'; require_once 'AudioVideoHandler.php';
require_once 'Downloader.php'; require_once 'Downloader.php';
define( 'CURL_PHPSESSID', 'hi' );

2
start.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/bash
/usr/bin/php7.3 C:\Users\hoppt\PhpstormProjects\karaoke-management\karaoke-management.php

Binary file not shown.