public static function fetchFiles() { $tvShowPath = ezcConfigurationManager::getInstance()->getSetting( 'tv', 'GeneralSettings', 'SourcePath' ); $list = array(); try { try { //foreach( new UnsortedEpisodesFilter( $iterator ) as $file ) foreach( glob( "{$tvShowPath}/*/*.{mkv,avi}", GLOB_BRACE ) as $file ) { if ( sprintf( "%u", filesize( $file ) ) < ( 25 * 1024 * 1024 ) ) { continue; } $fileInfo = pathinfo( $file ); $basePath = "{$fileInfo['dirname']}/{$fileInfo['filename']}"; $subtitlesFiles = array( "$basePath.srt", "$basePath.ass" ); $list[] = basename( $file ); } } catch( Exception $e ) { echo "An exception has occured:\n"; print_r( $e ); return false; } } catch( Exception $e ) { echo "An exception has occured: " . $e->getMessage() . "<br />"; } return $list; }
public static function configureObject($id) { $options = array('ttl' => 300); switch ($id) { case 'scrapers': ezcCacheManager::createCache('scrapers', ROOT . DIRECTORY_SEPARATOR . ezcConfigurationManager::getInstance()->getSetting('movies', 'ScraperSettings', 'TempPath'), 'ezcCacheStorageFilePlain', $options); break; } }
/** * Shows the settings by using the manager */ function showSettings() { $title = ezcConfigurationManager::getInstance()->getSetting('settings', 'site', 'title'); print "Title is {$title}\n"; list($dbHost, $dbUser, $dbPassword) = ezcConfigurationManager::getInstance()->getSettingsAsList('settings', 'db', array('host', 'user', 'password')); print "Connecting to database at '{$dbHost}' with user '{$dbUser}' and password '{$dbPassword}'.\n"; if (ezcConfigurationManager::getInstance()->hasSetting('settings', 'db', 'socket')) { print 'Socket: ' . ezcConfigurationManager::getInstance()->getSetting('settings', 'db', 'socket') . "\n"; } }
function eZCopy() { $this->output = new ezcConsoleOutput(); $this->cfg = ezcConfigurationManager::getInstance(); $this->cfg->init('ezcConfigurationIniReader', 'settings'); $this->dbRootUser = $this->cfg->getSetting('ezcopy', 'DBRoot', 'username'); $this->dbRootPass = $this->cfg->getSetting('ezcopy', 'DBRoot', 'password'); $this->checkpoint = false; if ($this->cfg->hasSetting('ezcopy', 'General', 'checkpoints')) { if ($this->cfg->getSetting('ezcopy', 'General', 'checkpoints') == 'true') { $this->checkpoint = true; } } $this->dbDumpDir = '_dbdump/'; $this->local = false; }
/** * Figures out which view handler should be used. * * Will use the Accept-Type header to do so, unless a specific Content-Type * has been found out in the URI by {@link runPreRoutingFilters()} * * @return ezcMvcView */ function createView( ezcMvcRoutingInformation $routeInfo, ezcMvcRequest $request, ezcMvcResult $result ) { if ( strpos( $routeInfo->matchedRoute, '/ajax/' ) !== false || $routeInfo->matchedRoute == '/nfo/movie/update-info' ) { $view = new mmAjaxView( $request, $result ); } else { // the part of the route used for the template path of course doesn't include parameters $view = new mmHtmlView( $request, $result ); if ( strpos( $routeInfo->matchedRoute, ':' ) !== false ) $realRoute = trim( substr( $routeInfo->matchedRoute, 0, strpos( $routeInfo->matchedRoute, ':' ) ), '/' ); else $realRoute = $routeInfo->matchedRoute; switch ( $realRoute ) { default: if ( file_exists("../templates/{$realRoute}.php" ) ) { $view->contentTemplate = "{$realRoute}.php"; } else { $view->contentTemplate = 'default.php'; $result->variables['__request'] = $request; } } $topMenuConfig = ezcConfigurationManager::getInstance()->getSetting( 'mkvmanager', 'TopMenu', 'Items' ); $topMenu = array(); foreach ( $topMenuConfig as $topMenuIdentifier => $topMenuItem ) { list( $url, $text ) = explode( ";", $topMenuItem ); $topMenu[] = array( "url" => $url, "text" => $text, "identifier" => $topMenuIdentifier ); } $result->variables['top_menu'] = $topMenu; } return $view; }
public function testReInit() { $config = ezcConfigurationManager::getInstance(); $config->init('ezcConfigurationIniReader', 'Configuration/tests/files'); $setting = $config->getStringSetting('bug14701', 'Standard', 'Summer'); $this->assertEquals('summer', $setting); $config->init('ezcConfigurationIniReader', 'Configuration/tests/files/fr'); $setting = $config->getStringSetting('bug14701', 'Standard', 'Summer'); $this->assertEquals("l'été", $setting); }
* @package JetFuelCore * common.php bootstraps the eZ Components and JetFuel environment. */ require_once dirname(__FILE__) . '/../settings/environment.php'; if (defined('EZC_ROOT')) { set_include_path(EZC_ROOT . ":" . EZC_ROOT . "/trunk:" . ini_get("include_path")); } require_once EZC_BASE; function __autoload($className) { ezcBase::autoload($className); @(include SITE_ROOT . '/app/model/' . $className . '.php'); } define('SITE_ROOT', dirname(__FILE__) . '/..'); define('APP_ROOT', dirname(__FILE__) . '/../app'); $cfg = ezcConfigurationManager::getInstance(); $cfg->init('ezcConfigurationIniReader', SITE_ROOT . '/settings'); define('DIR_DEFINITIONS', SITE_ROOT . '/app/model/definitions'); ezcBase::addClassRepository('.', SITE_ROOT . '/core/autoloads'); $driver = $cfg->getSetting('config', 'Database', 'Driver'); $host = $cfg->getSetting('config', 'Database', 'Host'); $port = $cfg->getSetting('config', 'Database', 'Port'); $username = $cfg->getSetting('config', 'Database', 'User'); $password = $cfg->getSetting('config', 'Database', 'Password'); $database = $cfg->getSetting('config', 'Database', 'Database'); $dsn = $driver . '://' . $username . ':' . $password . '@' . $host . '/' . $database; define('DB_DSN', $dsn); $dbInstance = ezcDbFactory::create(DB_DSN); ezcDbInstance::set($dbInstance); @(include_once SITE_ROOT . '/settings/log.php'); /*
public function testDelayedInit() { ezcBaseInit::setCallback('ezcInitConfigurationManager', 'testDelayedInitConfigurationManager'); $cfg = ezcConfigurationManager::getInstance(); $this->assertAttributeEquals('ezcConfigurationIniReader', 'readerClass', $cfg); }
/** * Merge interface for movies * @param string $this->Folder The name of the movie folder */ public function doMovieMerge() { $moviesPath = ezcConfigurationManager::getInstance()->getSetting( 'movies', 'GeneralSettings', 'SourcePath' ); $result = new ezcMvcResult; $result->variables['page_title'] = "{$this->Folder} :: Movies :: MKV Manager"; $result->variables['movie'] = $this->Folder; $generator = new MKVMergeCommandGenerator(); // video file, mandatory $videoFiles = glob( "{$moviesPath}/{$this->Folder}/{$this->Folder}.{mkv,avi}", GLOB_BRACE ); if ( !count( $videoFiles ) ) { throw new InvalidArgumentException( "No files found matching pattern {$moviesPath}/{$this->Folder}/{$this->Folder}.{mkv,avi}" ); } $videoFiles = $videoFiles[0]; $generator->addInputFile( new MKVMergeMediaInputFile( $videoFiles ) ); // subtitle file(s), optional $subtitlesFiles = glob( "{$moviesPath}/{$this->Folder}/{$this->Folder}*.{srt,avi}", GLOB_BRACE ); if ( count( $subtitlesFiles ) ) { } foreach( $subtitlesFiles as $subtitlesFile ) { $generator->addInputFile( new MKVMergeSubtitleInputFile( $subtitlesFile, 'und' ) ); } $tracks = array(); foreach ( $generator->trackSets as $trackSet ) { foreach ( $trackSet as $track ) { $tracks[] = $track; } } // output file $generator->setOutputFile( "/media/storage/VIMES/Movies/{$this->Folder}/{$this->Folder}.mkv" ); $result->variables['tracks'] = $tracks; $result->variables['command'] = $generator->getCommandString(); $result->variables += mmApp::doMovies(); return $result; }
protected function renderView($controller) { $cfg = ezcConfigurationManager::getInstance(); $handlerName = $cfg->getSetting('config', 'View', 'Renderer'); header('Status: ' . $controller->status_code); switch ($handlerName) { case 'php': $this->renderViewPhp($controller); break; case 'ezt': case 'template': $this->renderViewTemplate($controller); break; default: throw new Exception("Invalid View Renderer '{$handlerName}'. Please enter either 'ezt' or 'php' in the Renderer setting in settings/config.ini"); } }
/** * Fetches the NFO for the movie id $AllocineId * * @param string AllocineId * @return array(nfo => string)) */ public function doSaveNfo($allocineId, $movieFolder) { $scraper = new MkvManagerScraperAllocine(); $infos = $scraper->getMovieDetails($allocineId); $writer = new \mm\Xbmc\Nfo\Writers\Movie($infos); $nfoPath = ezcConfigurationManager::getInstance()->getSetting('movies', 'GeneralSettings', 'SourcePath') . DIRECTORY_SEPARATOR . $movieFolder . DIRECTORY_SEPARATOR . "{$movieFolder}.nfo"; return array('nfo' => $writer->write($nfoPath)); }
/** * Searches the subtitles for a movie ID * @param string Release Movie ID URI (subsynchro) */ public function doMovieDownloadSubtitle() { $moviesPath = ezcConfigurationManager::getInstance()->getSetting( 'movies', 'GeneralSettings', 'SourcePath' ); $subtitleId = str_replace( array( '|', '~' ), array( '/', '.' ), $this->SubtitleId ); $releaseFolder = $this->Folder; $scraper = new MkvManagerScraperSubsynchro(); $downloadedPath = $scraper->downloadSubtitle( $subtitleId, "$moviesPath/$releaseFolder/$releaseFolder" ); $variables = array( 'status' => 'ok', 'path' => $downloadedPath ); $result = new ezcMvcResult(); $result->variables += $variables; return $result; }
public function testGetGroupNames() { $config = ezcConfigurationManager::getInstance(); $config->init('ezcConfigurationIniReader', 'Configuration/tests/files'); $expectedGroups = array('NotTheOnlyGroup', 'TheSecond'); $this->assertEquals($expectedGroups, $config->getGroupNames('two-groups')); }
public function __get( $property ) { $tvShowPath = ezcConfigurationManager::getInstance()->getSetting( 'tv', 'GeneralSettings', 'SourcePath' ); switch( $property ) { case 'hasSubtitleFile': $basedirAndFile = "{$tvShowPath}/{$this->showName}/{$this->fullname}"; return ( file_exists( "$basedirAndFile.srt" ) || file_exists( "$basedirAndFile.ass" ) ); break; case 'subtitleFile': $basedirAndFile = "{$tvShowPath}/{$this->showName}/{$this->fullname}"; if ( file_exists( "$basedirAndFile.ass" ) ) return "$basedirAndFile.ass"; elseif ( file_exists( "$basedirAndFile.srt" ) ) { return "$basedirAndFile.srt"; } else { throw new Exception("No subtitle found for $this->filename" ); } break; case 'path': return "{$tvShowPath}/{$this->showName}/{$this->filename}"; break; case 'downloadedFile': $db = ezcDbInstance::get( 'sickbeard' ); // show ID $q = $db->createSelectQuery(); $q->select( 'tvdb_id' ) ->from( 'tv_shows' ) ->where( $q->expr->eq( 'show_name', $q->bindValue( $this->showName ) ) ); /** * @var PDOStatement */ $stmt = $q->prepare(); $stmt->execute(); $showId = $stmt->fetchColumn(); // downloaded file name $q = $db->createSelectQuery(); $e = $q->expr; $q->select( 'resource' ) ->from( 'history' ) ->where( $e->lAnd( $e->eq( 'action', $q->bindValue( 404 ) ), $e->eq( 'showid', $q->bindValue( $showId) ), $e->eq( 'season', $q->bindValue( $this->seasonNumber) ), $e->eq( 'episode', $q->bindValue( $this->episodeNumber ) ) ) ); $stmt = $q->prepare(); $stmt->execute(); return new TVEpisodeDownloadedFile( basename( $downloadedFile = $stmt->fetchColumn() ) ); case 'fileSize': return mmMkvManagerDiskHelper::bigFileSize( $this->path ); default: throw new ezcBasePropertyNotFoundException( $property ); } }