Initial import from Alltube app

Removed dependency on Config and LocaleManager classes
Avoid using generic exceptions
This commit is contained in:
Pierre Rudloff 2020-06-20 19:04:32 +02:00
commit 98b74fd6f2
16 changed files with 3935 additions and 0 deletions

View file

@ -0,0 +1,13 @@
<?php
namespace Alltube\Library\Exception;
use Exception;
/**
* Base class for Alltube exceptions.
*/
abstract class AlltubeLibraryException extends Exception
{
}

View file

@ -0,0 +1,20 @@
<?php
namespace Alltube\Library\Exception;
use Throwable;
/**
* Can't find avconv or ffmpeg.
*/
class AvconvException extends AlltubeLibraryException
{
/**
* AvconvException constructor.
* @param string $path Path to avconv or ffmpeg.
*/
public function __construct($path)
{
parent::__construct("Can't find avconv or ffmpeg at " . $path . '.');
}
}

View file

@ -0,0 +1,18 @@
<?php
/**
* EmptyUrlException class.
*/
namespace Alltube\Library\Exception;
/**
* Exception thrown when youtube-dl returns an empty URL.
*/
class EmptyUrlException extends AlltubeLibraryException
{
/**
* @var string Error message
*/
protected $message = 'youtube-dl returned an empty URL.';
}

View file

@ -0,0 +1,18 @@
<?php
namespace Alltube\Library\Exception;
/**
* Invalid conversion.
*/
class InvalidProtocolConversionException extends AlltubeLibraryException
{
/**
* InvalidProtocolConversionException constructor.
* @param string $protocol Protocol
*/
public function __construct($protocol)
{
parent::__construct($protocol . ' protocol is not supported in conversions.');
}
}

View file

@ -0,0 +1,19 @@
<?php
namespace Alltube\Library\Exception;
/**
* Invalid time.
*/
class InvalidTimeException extends AlltubeLibraryException
{
/**
* InvalidTimeException constructor.
* @param string $time Invalid time
*/
public function __construct($time)
{
parent::__construct('Invalid time: ' . $time);
}
}

View file

@ -0,0 +1,14 @@
<?php
/**
* PasswordException class.
*/
namespace Alltube\Library\Exception;
/**
* Exception thrown when a video requires a password.
*/
class PasswordException extends AlltubeLibraryException
{
}

View file

@ -0,0 +1,14 @@
<?php
namespace Alltube\Library\Exception;
/**
* Conversion of playlists is not supported.
*/
class PlaylistConversionException extends AlltubeLibraryException
{
/**
* @var string Error message
*/
protected $message = 'Conversion of playlists is not supported.';
}

View file

@ -0,0 +1,14 @@
<?php
namespace Alltube\Library\Exception;
/**
* Could not open popen stream.
*/
class PopenStreamException extends AlltubeLibraryException
{
/**
* @var string Error message
*/
protected $message = 'Could not open popen stream.';
}

View file

@ -0,0 +1,10 @@
<?php
namespace Alltube\Library\Exception;
/**
* Generic remux exception.
*/
class RemuxException extends AlltubeLibraryException
{
}

View file

@ -0,0 +1,14 @@
<?php
namespace Alltube\Library\Exception;
/**
* Wrong password.
*/
class WrongPasswordException extends AlltubeLibraryException
{
/**
* @var string Error message.
*/
protected $message = 'Wrong password.';
}

View file

@ -0,0 +1,10 @@
<?php
namespace Alltube\Library\Exception;
/**
* Generic youtube-dl error.
*/
class YoutubedlException extends AlltubeLibraryException
{
}