Exemple #1
0
    /**
     * Saves a NFO
     *
     * @param string $this->folder
     * @param string $this->info
     *
     * @return ezcMvcResult
     */
    public function doNfoSave()
    {
        $result = new \ezcMvcResult();

        $result->variables['page_title'] = "{$this->folder} :: Save NFO :: MKV Manager";
        $result->variables['movie'] = $this->folder;

        $basepath =
            ezcConfigurationManager::getInstance()->getSetting( 'movies', 'GeneralSettings', 'SourcePath' ) .
            DIRECTORY_SEPARATOR .
            $this->folder . DIRECTORY_SEPARATOR;
        $nfoFilePath = "{$basepath}{$this->folder}.nfo";
        $posterFilepath = "{$basepath}{$this->folder}.tbn";
        $fanartFilepath = "{$basepath}{$this->folder}-fanart.jpg";
        $trailerFilepath = "{$basepath}{$this->folder}-trailer.flv";

        $nfoWriter = new NfoWriter( $this->info );

        $result->variables['operations'] = array();

        // write NFO to disk
        $nfoWriter->write( $nfoFilePath );
        $operation = Daemon\Queue::add(
            new Operations\NfoWriter( $this->info, $nfoFilePath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getMainPoster(), $posterFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getMainFanart(), $fanartFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        // trailer
        $operation = Daemon\Queue::add(
            new Operations\HttpDownload( $nfoWriter->getTrailer(), $trailerFilepath )
        );
        $result->variables['operations'][] = (object)array(
            'title' => $operation->title,
            'hash' => $operation->hash,
        );

        return $result;
    }