PHP Class App\services\Media

Exibir arquivo Open project: phanan/koel Class Usage Examples

Protected Properties

Property Type Description
$allTags array Note that each isn't necessarily a valid ID3 tag name.
$tags array Tags to be synced.

Public Methods

Method Description
__construct ( )
gatherFiles ( string $path ) : array Gather all applicable files in a given directory.
getHash ( $path ) : string Generate a unique hash for a file path.
setTags ( array $tags = [] ) Construct an array of tags to be synced into the database from an input array of tags.
sync ( string | null $path = null, array $tags = [], boolean $force = false, SyncMedia $syncCommand = null ) Sync the media. Oh sync the media.
syncByWatchRecord ( App\Libraries\WatchRecord\WatchRecordInterface $record, SyncMedia $syncCommand = null ) Sync media using a watch record.
tidy ( ) Tidy up the library by deleting empty albums and artists.

Method Details

__construct() public method

public __construct ( )

gatherFiles() public method

Gather all applicable files in a given directory.
public gatherFiles ( string $path ) : array
$path string The directory's full path
return array An array of SplFileInfo objects

getHash() public method

Generate a unique hash for a file path.
public getHash ( $path ) : string
$path
return string

setTags() public method

If the input array is empty or contains only invalid items, we use all tags. Otherwise, we only use the valid items in it.
public setTags ( array $tags = [] )
$tags array

sync() public method

Sync the media. Oh sync the media.
public sync ( string | null $path = null, array $tags = [], boolean $force = false, SyncMedia $syncCommand = null )
$path string | null
$tags array The tags to sync. Only taken into account for existing records. New records will have all tags synced in regardless.
$force boolean Whether to force syncing even unchanged files
$syncCommand App\Console\Commands\SyncMedia The SyncMedia command object, to log to console if executed by artisan.

syncByWatchRecord() public method

Sync media using a watch record.
public syncByWatchRecord ( App\Libraries\WatchRecord\WatchRecordInterface $record, SyncMedia $syncCommand = null )
$record App\Libraries\WatchRecord\WatchRecordInterface The watch record.
$syncCommand App\Console\Commands\SyncMedia The SyncMedia command object, to log to console if executed by artisan.

tidy() public method

Tidy up the library by deleting empty albums and artists.
public tidy ( )

Property Details

$allTags protected_oe property

Note that each isn't necessarily a valid ID3 tag name.
protected array $allTags
return array

$tags protected_oe property

Tags to be synced.
protected array $tags
return array